diff --git a/README.md b/README.md index a268b8d..55137f0 100755 --- a/README.md +++ b/README.md @@ -123,6 +123,10 @@ specified host and port. Note that the base 32 I2P destination address determini `tunnel-control.sh all.destroy` +#### List all tunnels. Returns JSON string containing information about all tunnels currently in existence + +`tunnel-control.sh all.list` + #### Start a SAM listener on port 7656. Returns "OK" `tunnel-control.sh sam.create` diff --git a/org.getmonero.i2p.zero/src/org/getmonero/i2p/zero/TunnelControl.java b/org.getmonero.i2p.zero/src/org/getmonero/i2p/zero/TunnelControl.java index 3d612b5..2246764 100644 --- a/org.getmonero.i2p.zero/src/org/getmonero/i2p/zero/TunnelControl.java +++ b/org.getmonero.i2p.zero/src/org/getmonero/i2p/zero/TunnelControl.java @@ -98,7 +98,7 @@ public class TunnelControl implements Runnable { throw new RuntimeException(e); } } - public void save() { + public String getJSON(boolean includeKeyPairs) { try { JSONObject root = new JSONObject(); JSONArray tunnelsArray = new JSONArray(); @@ -112,7 +112,7 @@ public class TunnelControl implements Runnable { entry.put("host", t.getHost()); entry.put("port", t.getPort()); entry.put("dest", t.getI2P()); - entry.put("keypair", ((ServerTunnel) t).keyPair.toString()); + if(includeKeyPairs) entry.put("keypair", ((ServerTunnel) t).keyPair.toString()); break; case "client": @@ -125,7 +125,15 @@ public class TunnelControl implements Runnable { break; } } - Files.writeString(new File(tunnelControlConfigDir, "tunnels.json").toPath(), root.toJSONString()); + return root.toJSONString(); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + public void save() { + try { + Files.writeString(new File(tunnelControlConfigDir, "tunnels.json").toPath(), getJSON(true)); } catch (Exception e) { throw new RuntimeException(e); @@ -389,6 +397,11 @@ public class TunnelControl implements Runnable { break; } + case "all.list": { + out.println(tunnelList.getJSON(false)); + break; + } + case "sam.create": { String[] samArgs = new String[]{"sam.keys", "127.0.0.1", "7656", "i2cp.tcp.host=127.0.0.1", "i2cp.tcp.port=7654"}; I2PAppContext context = router.getContext();