Tunnel control now lets you easily create client and server tunnels

pull/2/head
knaccc 5 years ago
parent b7039127e7
commit f68a86a498

@ -1,6 +1,6 @@
<img src="https://github.com/knaccc/i2p-zero/blob/master/i2p-zero.png" align="left" width="336" height="124">
# Zero dependency, small footprint, cross-platform I2P Java Router with SAM interface
# Zero dependency, small footprint, cross-platform I2P Java Router with simple tunnel controller and SAM interface
This project will run under Linux, and build native launchers for Linux, MacOS and Windows. The launchers will include the I2P router, a SAM listener and a minimal JVM.
@ -67,25 +67,33 @@ Press Ctrl-C to gracefully shut down the router (or send the SIGINT signal to th
## Tunnel control
Listen for i2p connections and forward them to the specified host and port. Returns a newly created destination public key.
### Listen for i2p connections and forward them to the specified host and port. Returns a newly created destination public key.
`dist/linux/router/bin/tunnel-control.sh server.create <host> <port>`
Close the tunnel listening for connections on the specified port. Returns "OK".
### Close the tunnel listening for connections on the specified port. Returns "OK".
`dist/linux/router/bin/tunnel-control.sh server.destroy <i2p destination public key>`
Create a tunnel that listens for connections on localhost and forwards connections over I2P to the specified destination public key. Returns a newly created localhost port number.
### Create a tunnel that listens for connections on localhost and forwards connections over I2P to the specified destination public key. Returns a newly created localhost port number.
`dist/linux/router/bin/tunnel-control.sh client.create <i2p destination public key>`
Close the tunnel listening for connections on the specified port. Returns "OK".
### Close the tunnel listening for connections on the specified port. Returns "OK".
`dist/linux/router/bin/tunnel-control.sh client.destroy <port>`
### Create a socks tunnel, listening on the specified port
`dist/linux/router/bin/tunnel-control.sh socks.create <port>`
### Destroy the socks tunnel listening on the specified port
`dist/linux/router/bin/tunnel-control.sh socks.destroy <port>`
## Watch the I2P log for messages

@ -17,6 +17,7 @@ public class TunnelControl implements Runnable {
private Map<Integer, I2PTunnel> clientTunnels = new HashMap<>();
private Map<String, I2PTunnel> serverTunnels = new HashMap<>();
private Map<Integer, I2PTunnel> socksTunnels = new HashMap<>();
private int clientPortSeq = 30000;
private int serverSeq = 0;
private String tunnelConfigDirPrefix;
@ -100,6 +101,31 @@ public class TunnelControl implements Runnable {
}.start();
out.println("OK");
}
if(args[0].equals("socks.create")) {
int port = Integer.parseInt(args[1]);
new Thread() {
@Override
public void run() {
// sockstunnel port
var t = new I2PTunnel(new String[]{"-die", "-nocli", "-e", "sockstunnel " + port});
socksTunnels.put(port, t);
}
}.start();
out.println("OK");
}
if(args[0].equals("socks.destroy")) {
int port = Integer.parseInt(args[1]);
new Thread() {
@Override
public void run() {
var t = socksTunnels.get(port);
socksTunnels.remove(port);
t.runClose(new String[]{"forced", "all"}, t);
}
}.start();
out.println("OK");
}
}
catch (Exception e) {
e.printStackTrace();

Loading…
Cancel
Save