Cleaned up build scripts.
Removed cruddy files from repo. Added support for API versioning. Version 1 is the current one.
This commit is contained in:
17
build.xml
17
build.xml
@ -3,24 +3,26 @@
|
|||||||
|
|
||||||
<target name="all" depends="clean,plugin" />
|
<target name="all" depends="clean,plugin" />
|
||||||
|
|
||||||
<target name="war">
|
<target name="jar">
|
||||||
<ant dir="src" target="build" />
|
<ant dir="src" target="build" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="plugin" depends="war">
|
<target name="plugin" depends="jar">
|
||||||
<!-- get version number -->
|
<!-- get version number -->
|
||||||
<buildnumber file="scripts/build.number" />
|
<buildnumber file="scripts/build.number" />
|
||||||
<property name="release.number" value="0.0.0" />
|
<property name="release.number" value="0.0.1" />
|
||||||
|
|
||||||
<!-- make the update xpi2p -->
|
<!-- make the update xpi2p -->
|
||||||
|
<mkdir dir="plugin/lib"/>
|
||||||
<copy file="LICENSE.txt" todir="plugin/" overwrite="true" />
|
<copy file="LICENSE.txt" todir="plugin/" overwrite="true" />
|
||||||
<copy file="README.txt" todir="plugin/" overwrite="true" />
|
<copy file="README.txt" todir="plugin/" overwrite="true" />
|
||||||
<copy file="scripts/clients.config" todir="plugin/" overwrite="true" />
|
<copy file="scripts/clients.config" todir="plugin/" overwrite="true" />
|
||||||
<!--<copy file="scripts/webapps.config" todir="plugin/console/" overwrite="true" /> Console WebApp disabled-->
|
|
||||||
<copy file="scripts/plugin.config" todir="plugin/" overwrite="true" />
|
<copy file="scripts/plugin.config" todir="plugin/" overwrite="true" />
|
||||||
|
|
||||||
<exec executable="echo" osfamily="unix" failonerror="true" output="plugin/plugin.config" append="true">
|
<exec executable="echo" osfamily="unix" failonerror="true" output="plugin/plugin.config" append="true">
|
||||||
<arg value="update-only=true" />
|
<arg value="update-only=true" />
|
||||||
</exec>
|
</exec>
|
||||||
|
|
||||||
<exec executable="echo" osfamily="unix" failonerror="true" output="plugin/plugin.config" append="true">
|
<exec executable="echo" osfamily="unix" failonerror="true" output="plugin/plugin.config" append="true">
|
||||||
<arg value="version=${release.number}-b${build.number}" />
|
<arg value="version=${release.number}-b${build.number}" />
|
||||||
</exec>
|
</exec>
|
||||||
@ -30,12 +32,7 @@
|
|||||||
<arg value="plugin/lib/I2PControl.jar.pack" />
|
<arg value="plugin/lib/I2PControl.jar.pack" />
|
||||||
<arg value="src/build/I2PControl.jar" />
|
<arg value="src/build/I2PControl.jar" />
|
||||||
</exec>
|
</exec>
|
||||||
<!--<exec executable="pack200" failonerror="true">
|
|
||||||
<arg value="-no-gzip"/> //Add a dash
|
|
||||||
<arg value="-effort=9"/> //Add a dash
|
|
||||||
<arg value="plugin/console/webapps/I2PControl.war.pack" />
|
|
||||||
<arg value="src/build/I2PControl.war.jar" />
|
|
||||||
</exec> -->
|
|
||||||
<exec executable="scripts/makeplugin.sh" failonerror="true" >
|
<exec executable="scripts/makeplugin.sh" failonerror="true" >
|
||||||
<arg value="plugin" />
|
<arg value="plugin" />
|
||||||
</exec>
|
</exec>
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
<html><head><title>ZzzOT Plugin Help</title></head>
|
|
||||||
<body style="background-color: #ddd; color: #a30;">
|
|
||||||
<h2>Welcome to the ZzzOT I2P Plugin!</h2>
|
|
||||||
|
|
||||||
A new eepsite tunnel and Jetty server have been started for your open tracker.
|
|
||||||
|
|
||||||
<p><a href="/tracker/index.jsp">Click here to see the current stats</a>.
|
|
||||||
This link is also at the top of your router console when ZzzOT is running.
|
|
||||||
|
|
||||||
<p>Report bugs or add comments on
|
|
||||||
<a href="http://zzz.i2p//forums/16">the plugin forum on zzz.i2p</a>.
|
|
||||||
|
|
||||||
<h3>Eepsite Key and Helpful Hints for I2P</h3>
|
|
||||||
|
|
||||||
<p>Your Base 32 address is <a href="http://$B32/">$B32</a>.
|
|
||||||
Others may access your eepsite using this address, even if you do not publish a hostname.
|
|
||||||
<p>Once you decide on a host name, you may
|
|
||||||
<a href="http://127.0.0.1:7657/susidns/addressbook.jsp?book=private&destination=$B64">add the key to your local addressbook here</a>.
|
|
||||||
<p>Your Base 64 key is: <textarea rows="1" style="height: 3em;" cols="40" readonly="readonly" wrap="off">$B64</textarea>
|
|
||||||
<br>You will need this key to register a hostname at <a href="http://stats.i2p/i2p/addkey.html">stats.i2p</a>.
|
|
||||||
<p>Your private key file is $PLUGIN/eepPriv.dat - back it up!!!
|
|
||||||
<p>Your eepsite document root is $PLUGIN/eepsite/docroot,
|
|
||||||
you may put other files there is you wish to have additional content on your eepsite.
|
|
||||||
<p>The supported announce URLs are:
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://$B32/a">http://$B32/a</a>
|
|
||||||
<li><a href="http://$B32/announce">http://$B32/announce</a>
|
|
||||||
<li><a href="http://$B32/announce.jsp">http://$B32/announce.jsp</a>
|
|
||||||
<li><a href="http://$B32/announce.php">http://$B32/announce.php</a>
|
|
||||||
<li><a href="http://$B32/tracker/a">http://$B32/tracker/a</a>
|
|
||||||
<li><a href="http://$B32/tracker/announce">http://$B32/tracker/announce</a>
|
|
||||||
<li><a href="http://$B32/tracker/announce.jsp">http://$B32/tracker/announce.jsp</a>
|
|
||||||
<li><a href="http://$B32/tracker/announce.php">http://$B32/tracker/announce.php</a>
|
|
||||||
</ul>
|
|
||||||
<p>The supported scrape URLs are:
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://$B32/scrape">http://$B32/scrape</a>
|
|
||||||
<li><a href="http://$B32/scrape.jsp">http://$B32/scrape.jsp</a>
|
|
||||||
<li><a href="http://$B32/scrape.php">http://$B32/scrape.php</a>
|
|
||||||
<li><a href="http://$B32/tracker/scrape">http://$B32/tracker/scrape</a>
|
|
||||||
<li><a href="http://$B32/tracker/scrape.jsp">http://$B32/tracker/scrape.jsp</a>
|
|
||||||
<li><a href="http://$B32/tracker/scrape.php">http://$B32/tracker/scrape.php</a>
|
|
||||||
</ul>
|
|
||||||
<p>Your eepsite tunnel is configured for 2 inbound and 2 outbound tunnels, 3 hops each.
|
|
||||||
You may change tunnel settings by editing $PLUGIN/i2ptunnel.config and restarting the plugin.
|
|
||||||
The tunnel will not appear in <a href="http://127.0.0.1:7657/i2ptunnel/index.jsp">i2ptunnel</a>.
|
|
||||||
If your tracker gets over 1000 peers, you will probably want to increase the number of tunnels.
|
|
||||||
<p>The Jetty webserver port is 7662. If you must change it, edit jetty.xml, i2ptunnel.config, and plugins.config
|
|
||||||
in the directory $PLUGIN. Then stop and restart the plugin.
|
|
||||||
<p>This help file is $PLUGIN/eepsite/docroot/help.html, you should probably move it
|
|
||||||
outside of the document root before you announce your eepsite as it may contain your user name.
|
|
||||||
<p>As you probably know, an open tracker does not require torrents to be registered,
|
|
||||||
and it does not host torrent files. You can, however, host torrent files elsewhere on
|
|
||||||
the eepsite, for example at <a href="http://$B32/torrents/">/torrents</a>.
|
|
||||||
|
|
||||||
</body></html>
|
|
@ -1,190 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
|
|
||||||
|
|
||||||
<!-- ========================================================================= -->
|
|
||||||
<!-- This file configures the Jetty server. -->
|
|
||||||
<!-- All changes require a restart of I2P. -->
|
|
||||||
<!-- -->
|
|
||||||
<!-- Commonly changed settings: -->
|
|
||||||
<!-- * host: Change 127.0.0.1 to 0.0.0.0 in the addListener section -->
|
|
||||||
<!-- to access the server directly (bypassing i2p) -->
|
|
||||||
<!-- from other computers. The included version of Jetty has -->
|
|
||||||
<!-- been patched to allow IPv6 addresses as well, -->
|
|
||||||
<!-- enclosed in brackets e.g. [::1] -->
|
|
||||||
<!-- * port: Default 7662 in the addListener section -->
|
|
||||||
<!-- * threads: Raise MaxThreads in the addListener section -->
|
|
||||||
<!-- if you have a high-traffic site and get a lot of warnings. -->
|
|
||||||
<!-- -->
|
|
||||||
<!-- I2P uses Jetty 5.1.15. We have no plans to upgrade to Jetty 6, due to -->
|
|
||||||
<!-- the significant changes in the API. If you need web server features not -->
|
|
||||||
<!-- found in Jetty 5, you may install and run Jetty 6 in a different JVM, -->
|
|
||||||
<!-- or run any other web server such as Apache. If you do run another -->
|
|
||||||
<!-- web server instead, be sure and disable the Jetty 5 server for your -->
|
|
||||||
<!-- eepsite on http://127.0.0.1/configclients.jsp . -->
|
|
||||||
<!-- -->
|
|
||||||
<!-- Jetty errors and warnings will appear in wrapper.log, check there -->
|
|
||||||
<!-- to diagnose problems. -->
|
|
||||||
<!-- ========================================================================= -->
|
|
||||||
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<!-- Configure the Jetty Server -->
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<Configure class="org.mortbay.jetty.Server">
|
|
||||||
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<!-- Configure the Request Listeners -->
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
||||||
<!-- Add and configure a HTTP listener to port 8080 -->
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
||||||
<Call name="addListener">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.mortbay.http.SocketListener">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.mortbay.util.InetAddrPort">
|
|
||||||
<Set name="host">127.0.0.1</Set>
|
|
||||||
<Set name="port">7662</Set>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
<Set name="MinThreads">3</Set>
|
|
||||||
<Set name="MaxThreads">10</Set>
|
|
||||||
<Set name="MaxIdleTimeMs">60000</Set>
|
|
||||||
<Set name="LowResourcePersistTimeMs">1000</Set>
|
|
||||||
<Set name="ConfidentialPort">8443</Set>
|
|
||||||
<Set name="IntegralPort">8443</Set>
|
|
||||||
<Set name="PoolName">main</Set>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<!-- Configure the Contexts -->
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
||||||
<!-- Add a all web application within the webapps directory. -->
|
|
||||||
<!-- + No virtual host specified -->
|
|
||||||
<!-- + Look in the webapps directory relative to jetty.home or . -->
|
|
||||||
<!-- + Use the default webdefault.xml in jetty's install -->
|
|
||||||
<!-- + Upack the war file -->
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
||||||
<Set name="rootWebApp">root</Set>
|
|
||||||
<Call name="addWebApplications">
|
|
||||||
<Arg></Arg>
|
|
||||||
<Arg>$PLUGIN/eepsite/webapps/</Arg>
|
|
||||||
<Arg></Arg>
|
|
||||||
<Arg type="boolean">true</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<Call name="addContext">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.mortbay.http.HttpContext">
|
|
||||||
<Set name="contextPath">/</Set>
|
|
||||||
<Set name="resourceBase">$PLUGIN/eepsite/docroot</Set>
|
|
||||||
<Call name="addHandler">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.mortbay.http.handler.ResourceHandler">
|
|
||||||
<Set name="redirectWelcome">FALSE</Set>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
<!-- This custom handler is like Jetty's ForwardHandler,
|
|
||||||
- but it passes CGI query parameters through.
|
|
||||||
- Note that it is somewhat misnamed - it does NOT
|
|
||||||
- return a 301/302, it handles the request directly.
|
|
||||||
-->
|
|
||||||
<Call name="addHandler">
|
|
||||||
<Arg>
|
|
||||||
<New class="net.i2p.zzzot.QForwardHandler">
|
|
||||||
<Call name="setHandleQueries">
|
|
||||||
<Arg type="boolean">true</Arg>
|
|
||||||
</Call>
|
|
||||||
<!-- Forward announce requests to /tracker/announce.jsp -->
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/a</Arg>
|
|
||||||
<Arg>/tracker/announce.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/announce</Arg>
|
|
||||||
<Arg>/tracker/announce.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/announce.jsp</Arg>
|
|
||||||
<Arg>/tracker/announce.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/announce.php</Arg>
|
|
||||||
<Arg>/tracker/announce.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<!-- Forward scrape requests to /tracker/scrape.jsp -->
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/scrape</Arg>
|
|
||||||
<Arg>/tracker/scrape.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/scrape.jsp</Arg>
|
|
||||||
<Arg>/tracker/scrape.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/scrape.php</Arg>
|
|
||||||
<Arg>/tracker/scrape.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<!-- Forward Seedless requests to /tracker/seedless.jsp -->
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/Seedless</Arg>
|
|
||||||
<Arg>/tracker/seedless.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/Seedless/</Arg>
|
|
||||||
<Arg>/tracker/seedless.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/Seedless/index.jsp</Arg>
|
|
||||||
<Arg>/tracker/seedless.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
<Call name="addForward">
|
|
||||||
<Arg>/Seedless/seedless</Arg>
|
|
||||||
<Arg>/tracker/seedless.jsp</Arg>
|
|
||||||
</Call>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<Call name="addContext">
|
|
||||||
<Arg>/cgi-bin/*</Arg>
|
|
||||||
<Set name="ResourceBase">$PLUGIN/eepsite/cgi-bin</Set>
|
|
||||||
<Call name="addServlet">
|
|
||||||
<Arg>Common Gateway Interface</Arg>
|
|
||||||
<Arg>/</Arg>
|
|
||||||
<Arg>org.mortbay.servlet.CGI</Arg>
|
|
||||||
<Put name="Path">/usr/local/bin:/usr/ucb:/bin:/usr/bin</Put>
|
|
||||||
</Call>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<!-- Configure the Request Log -->
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<Set name="RequestLog">
|
|
||||||
<New class="org.mortbay.http.I2PRequestLog">
|
|
||||||
<Arg>$PLUGIN/eepsite/logs/yyyy_mm_dd.request.log</Arg>
|
|
||||||
<Set name="retainDays">30</Set>
|
|
||||||
<Set name="append">true</Set>
|
|
||||||
<Set name="extended">false</Set>
|
|
||||||
<Set name="buffered">false</Set>
|
|
||||||
<Set name="LogTimeZone">GMT</Set>
|
|
||||||
</New>
|
|
||||||
</Set>
|
|
||||||
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<!-- Configure the Other Server Options -->
|
|
||||||
<!-- =============================================================== -->
|
|
||||||
<Set name="requestsPerGC">2000</Set>
|
|
||||||
<Set name="statsOn">false</Set>
|
|
||||||
|
|
||||||
</Configure>
|
|
@ -23,7 +23,7 @@
|
|||||||
</path>
|
</path>
|
||||||
|
|
||||||
<target name="all" depends="clean, build" />
|
<target name="all" depends="clean, build" />
|
||||||
<target name="build" depends="jar, war" />
|
<target name="build" depends="jar" />
|
||||||
<target name="builddep">
|
<target name="builddep">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -48,49 +48,6 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="precompilejsp" depends="compile" >
|
<target name="precompilejsp" depends="compile" >
|
||||||
<!-- disable console webapp
|
|
||||||
<mkdir dir="build" />
|
|
||||||
<mkdir dir="build/war/WEB-INF/classes" />
|
|
||||||
<path id="jspcp">
|
|
||||||
<path refid="cp" />
|
|
||||||
<pathelement location="build/obj" />
|
|
||||||
</path>
|
|
||||||
<java classname="org.apache.jasper.JspC" fork="true" classpathref="jspcp" failonerror="true">
|
|
||||||
<arg value="-d" />
|
|
||||||
<arg value="build/jspjava" />
|
|
||||||
<arg value="-v" />
|
|
||||||
<arg value="-p" />
|
|
||||||
<arg value="net.i2p.i2pcontrol" />
|
|
||||||
<arg value="-webinc" />
|
|
||||||
<arg value="build/web-fragment.xml" />
|
|
||||||
<arg value="-webapp" />
|
|
||||||
<arg value="jsp/" />
|
|
||||||
</java>
|
|
||||||
|
|
||||||
<javac
|
|
||||||
debug="true"
|
|
||||||
deprecation="on"
|
|
||||||
source="1.5" target="1.5"
|
|
||||||
destdir="build/war/WEB-INF/classes"
|
|
||||||
srcdir="./build/jspjava"
|
|
||||||
includes="**/*.java"
|
|
||||||
classpathref="jspcp"
|
|
||||||
failonerror="true" />
|
|
||||||
|
|
||||||
<copy file="jsp/WEB-INF/web.xml" tofile="build/web.xml" />
|
|
||||||
<loadfile property="jspc.web.fragment" srcfile="build/web-fragment.xml" />
|
|
||||||
<replace file="build/web.xml">
|
|
||||||
<replacefilter token="<!- precompiled servlets ->" value="${jspc.web.fragment}" /> //Add double dash
|
|
||||||
</replace>
|
|
||||||
-->
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="war" depends="precompilejsp">
|
|
||||||
<!-- Disable console webapp
|
|
||||||
<war destfile="build/I2PControl.war.jar" webxml="build/web.xml">
|
|
||||||
<fileset dir="build/war" />
|
|
||||||
</war>
|
|
||||||
-->
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="clean">
|
<target name="clean">
|
||||||
|
@ -22,6 +22,8 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletInputStream;
|
import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
@ -30,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
|
import net.i2p.i2pcontrol.I2PControlVersion;
|
||||||
import net.i2p.i2pcontrol.servlets.jsonrpc2handlers.AuthenticateHandler;
|
import net.i2p.i2pcontrol.servlets.jsonrpc2handlers.AuthenticateHandler;
|
||||||
import net.i2p.i2pcontrol.servlets.jsonrpc2handlers.EchoHandler;
|
import net.i2p.i2pcontrol.servlets.jsonrpc2handlers.EchoHandler;
|
||||||
import net.i2p.i2pcontrol.servlets.jsonrpc2handlers.GetRateHandler;
|
import net.i2p.i2pcontrol.servlets.jsonrpc2handlers.GetRateHandler;
|
||||||
@ -89,6 +92,7 @@ public class JSONRPC2Servlet extends HttpServlet{
|
|||||||
|
|
||||||
if (msg instanceof JSONRPC2Request) {
|
if (msg instanceof JSONRPC2Request) {
|
||||||
jsonResp = disp.dispatch((JSONRPC2Request)msg, null);
|
jsonResp = disp.dispatch((JSONRPC2Request)msg, null);
|
||||||
|
jsonResp.toJSON().put("API", I2PControlVersion.API_VERSION);
|
||||||
_log.debug("Request: " + msg);
|
_log.debug("Request: " + msg);
|
||||||
_log.debug("Response: " + jsonResp);
|
_log.debug("Response: " + jsonResp);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,13 @@ public class JSONRPC2ExtendedError extends JSONRPC2Error {
|
|||||||
/** Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000) */
|
/** Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000) */
|
||||||
public static final JSONRPC2Error TOKEN_EXPIRED = new JSONRPC2ExtendedError(-32004, "Provided authentication token was expired and will be removed.");
|
public static final JSONRPC2Error TOKEN_EXPIRED = new JSONRPC2ExtendedError(-32004, "Provided authentication token was expired and will be removed.");
|
||||||
|
|
||||||
|
/** Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000) */
|
||||||
|
public static final JSONRPC2Error UNSPECIFIED_API_VERSION = new JSONRPC2ExtendedError(-32005, "The version of the I2PControl API wasn't specified, but is required to be specified.");
|
||||||
|
|
||||||
|
/** Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000) */
|
||||||
|
public static final JSONRPC2Error UNSUPPORTED_API_VERSION = new JSONRPC2ExtendedError(-32006, "The version of the I2PControl API specified is not supported by I2PControl.");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new JSON-RPC 2.0 error with the specified code and
|
* Creates a new JSON-RPC 2.0 error with the specified code and
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.i2pcontrol.servlets.jsonrpc2handlers;
|
package net.i2p.i2pcontrol.servlets.jsonrpc2handlers;
|
||||||
|
|
||||||
|
import net.i2p.i2pcontrol.I2PControlVersion;
|
||||||
import net.i2p.i2pcontrol.security.*;
|
import net.i2p.i2pcontrol.security.*;
|
||||||
import net.i2p.i2pcontrol.security.SecurityManager;
|
import net.i2p.i2pcontrol.security.SecurityManager;
|
||||||
|
|
||||||
@ -54,7 +55,13 @@ public class JSONRPC2Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there exist any required arguments
|
// Validate I2PControl API version.
|
||||||
|
JSONRPC2Error err = validateAPIVersion(params);
|
||||||
|
if (err != null){
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there exist any required arguments.
|
||||||
if (requiredArgs != null && requiredArgs.length > 0){
|
if (requiredArgs != null && requiredArgs.length > 0){
|
||||||
String missingArgs = "";
|
String missingArgs = "";
|
||||||
for (int i = 0; i < requiredArgs.length; i++){
|
for (int i = 0; i < requiredArgs.length; i++){
|
||||||
@ -103,4 +110,29 @@ public class JSONRPC2Helper {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the provided I2PControl API version against the ones supported by I2PControl.
|
||||||
|
*/
|
||||||
|
private static JSONRPC2Error validateAPIVersion(HashMap params){
|
||||||
|
|
||||||
|
Integer apiVersion;
|
||||||
|
try {
|
||||||
|
Object input = params.get("API");
|
||||||
|
apiVersion = ((Long) input).intValue();
|
||||||
|
} catch (ClassCastException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return JSONRPC2ExtendedError.UNSPECIFIED_API_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!I2PControlVersion.SUPPORTED_API_VERSIONS.contains(apiVersion)){
|
||||||
|
String supportedAPIVersions = "";
|
||||||
|
for (Integer i : I2PControlVersion.SUPPORTED_API_VERSIONS){
|
||||||
|
supportedAPIVersions += ", "+ i;
|
||||||
|
}
|
||||||
|
return new JSONRPC2Error(JSONRPC2ExtendedError.UNSUPPORTED_API_VERSION.getCode(),
|
||||||
|
"The provided API version \'" + apiVersion + "\' is not supported. The supported versions are" + supportedAPIVersions+".");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,26 @@ public class RouterInfoHandler implements RequestHandler {
|
|||||||
if (inParams.containsKey("i2p.router.net.status")) {
|
if (inParams.containsKey("i2p.router.net.status")) {
|
||||||
outParams.put("i2p.router.net.status", getNetworkStatus());
|
outParams.put("i2p.router.net.status", getNetworkStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inParams.containsKey("i2p.router.net.bw.inbound.1s")) {
|
||||||
|
outParams.put("i2p.router.net.bw.inbound.1s", _context.bandwidthLimiter().getReceiveBps());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inParams.containsKey("i2p.router.net.bw.outbound.1s")) {
|
||||||
|
outParams.put("i2p.router.net.bw.outbound.1s", _context.bandwidthLimiter().getSendBps());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inParams.containsKey("i2p.router.net.bw.inbound.15s")) {
|
||||||
|
outParams.put("i2p.router.net.bw.inbound.15s", _context.bandwidthLimiter().getReceiveBps15s());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inParams.containsKey("i2p.router.net.bw.outbound.15s")) {
|
||||||
|
outParams.put("i2p.router.net.bw.outbound.15s", _context.bandwidthLimiter().getSendBps15s());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inParams.containsKey("i2p.router.net.tunnels.participating")) {
|
||||||
|
outParams.put("i2p.router.net.tunnels.participating", _context.tunnelManager().getParticipatingCount());
|
||||||
|
}
|
||||||
|
|
||||||
return new JSONRPC2Response(outParams, req.getID());
|
return new JSONRPC2Response(outParams, req.getID());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user