diff --git a/src/net/i2p/itoopie/i2pcontrol/JSONRPC2Interface.java b/src/net/i2p/itoopie/i2pcontrol/JSONRPC2Interface.java index 05d513d3c..a2a7d725a 100644 --- a/src/net/i2p/itoopie/i2pcontrol/JSONRPC2Interface.java +++ b/src/net/i2p/itoopie/i2pcontrol/JSONRPC2Interface.java @@ -7,6 +7,7 @@ import java.util.Random; import javax.net.ssl.HttpsURLConnection; +import net.i2p.itoopie.ItoopieVersion; import net.i2p.itoopie.configuration.ConfigurationManager; import net.i2p.itoopie.i2pcontrol.methods.Authenticate; import net.i2p.itoopie.security.CertificateHelper; @@ -77,11 +78,14 @@ public class JSONRPC2Interface { } HashMap outParams = (HashMap) req.getParams(); outParams.put("Token", token); // Add authentication token + outParams.put("API", ItoopieVersion.I2PCONTROL_API_VERSION); req.setParams(outParams); JSONRPC2Response resp = null; try { resp = session.send(req); + System.out.println("Request: " + req.toString()); + System.out.println("Response: " + resp.toString()); JSONRPC2Error err = resp.getError(); if (err != null) { switch (err.getCode()) { @@ -128,11 +132,20 @@ public class JSONRPC2Interface { token = Authenticate.execute(); throw new FailedRequestException(); // break; + case -32005: + // I2PControl API version not provided + throw new InvalidI2PControlAPI(err.getMessage()); + case -32006: + // I2PControl API version not supported + throw new InvalidI2PControlAPI(err.getMessage()); } } return resp; } catch (FailedRequestException e) { return sendReq(req, ++tryNbr); + } catch (InvalidI2PControlAPI e) { + _log.error(e); + return null; } } } diff --git a/src/net/i2p/itoopie/i2pcontrol/methods/RouterInfo.java b/src/net/i2p/itoopie/i2pcontrol/methods/RouterInfo.java index 8d03c8c56..dd8ff7be1 100644 --- a/src/net/i2p/itoopie/i2pcontrol/methods/RouterInfo.java +++ b/src/net/i2p/itoopie/i2pcontrol/methods/RouterInfo.java @@ -16,21 +16,42 @@ public class RouterInfo{ * @author hottuna */ public enum ROUTER_INFO implements Remote{ - VERSION { public boolean isReadable(){ return true;} - public boolean isWritable(){ return false;} - public String toString() { return "i2p.router.version"; }}, + VERSION { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.version"; }}, - UPTIME { public boolean isReadable(){ return true;} - public boolean isWritable(){ return false;} - public String toString() { return "i2p.router.uptime"; }}, + UPTIME { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.uptime"; }}, - STATUS { public boolean isReadable(){ return true;} - public boolean isWritable(){ return false;} - public String toString() { return "i2p.router.status"; }}, + STATUS { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.status"; }}, - NETWORK_STATUS { public boolean isReadable(){ return true;} - public boolean isWritable(){ return false;} - public String toString() { return "i2p.router.net.status"; }} + NETWORK_STATUS { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.net.status"; }}, + + BW_INBOUND_1S { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.net.bw.inbound.1s"; }}, + + BW_INBOUND_15S { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.net.bw.inbound.15s"; }}, + + BW_OUTBOUND_1S { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.net.bw.outbound.1s"; }}, + + BW_OUTBOUND_15S { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.net.bw.outbound.15s"; }}, + + TUNNELS_PARTICIPATING { public boolean isReadable(){ return true;} + public boolean isWritable(){ return false;} + public String toString() { return "i2p.router.net.tunnels.participating"; }} + }; static {