diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelManager.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelManager.java
deleted file mode 100644
index 3b76c5e32c..0000000000
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelManager.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/* I2PTunnel is GPL'ed (with the exception mentioned in I2PTunnel.java)
- * (c) 2003 - 2004 mihi
- */
-
-package net.i2p.i2ptunnel;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-import net.i2p.data.DataFormatException;
-import net.i2p.data.Destination;
-import net.i2p.util.Clock;
-import net.i2p.util.I2PThread;
-import net.i2p.util.Log;
-
-/**
- * Quick and dirty socket listener to control an I2PTunnel.
- * Basically run this class as TunnelManager [listenHost] [listenPort] and
- * then send it commands on that port. Commands are one shot deals -
- * Send a command + newline, get a response plus newline, then get disconnected.
- *
- * Implemented commands:
- *
- * -------------------------------------------------
- * lookup <name>\n
- * --
- * <base64 of the destination>\n
- * or
- * <error message, usually 'Unknown host'>\n
- *
- * Lookup the public key of a named destination (i.e. listed in hosts.txt)
- * -------------------------------------------------
- * genkey\n
- * --
- * <base64 of the destination>\t<base64 of private data>\n
- *
- * Generates a new public and private key pair
- * -------------------------------------------------
- * convertprivate <base64 of privkey>
- * --
- * <base64 of destination>\n
- * or
- * <error message>\n
- *
- * Returns the destination (pubkey) of a given private key.
- * -------------------------------------------------
- * listen_on <ip>\n
- * --
- * ok\n
- * or
- * error\n
- *
- * Sets the ip address clients will listen on. By default this is the
- * localhost (127.0.0.1)
- * -------------------------------------------------
- * openclient <listenPort> <peer>[ <sharedClient>]\n
- * --
- * ok [<jobId>]\n
- * or
- * ok <listenPort> [<jobId>]\n
- * or
- * error\n
- *
- * Open a tunnel on the given <listenport> to the destination specified
- * by <peer>. If <listenPort> is 0 a free port is picked and returned in
- * the reply message. Otherwise the short reply message is used.
- * Peer can be the base64 of the destination, a file with the public key
- * specified as 'file:<filename>' or the name of a destination listed in
- * hosts.txt. The <jobId> returned together with "ok" and <listenport> can
- * later be used as argument for the "close" command.
- * <sharedClient> indicates if this httpclient shares tunnels with other
- * clients or not (just use 'true' and 'false'
- * -------------------------------------------------
- * openhttpclient <listenPort> [<sharedClient>] [<proxy>]\n
- * --
- * ok [<jobId>]\n
- * or
- * ok <listenPort> [<jobId>]\n
- * or
- * error\n
- *
- * Open an HTTP proxy through the I2P on the given
- * <listenport>. <proxy> (optional) specifies a
- * destination to be used as an outbound proxy, to access normal WWW
- * sites out of the .i2p domain. If <listenPort> is 0 a free
- * port is picked and returned in the reply message. Otherwise the
- * short reply message is used. <proxy> can be the base64 of the
- * destination, a file with the public key specified as
- * 'file:<filename>' or the name of a destination listed in
- * hosts.txt. The <jobId> returned together with "ok" and
- * <listenport> can later be used as argument for the "close"
- * command.
- * <sharedClient> indicates if this httpclient shares tunnels with other
- * clients or not (just use 'true' and 'false'
- * -------------------------------------------------
- * opensockstunnel <listenPort>\n
- * --
- * ok [<jobId>]\n
- * or
- * ok <listenPort> [<jobId>]\n
- * or
- * error\n
- *
- * Open an SOCKS tunnel through the I2P on the given
- * <listenport>. If <listenPort> is 0 a free port is
- * picked and returned in the reply message. Otherwise the short
- * reply message is used. The <jobId> returned together with
- * "ok" and <listenport> can later be used as argument for the
- * "close" command.
- * -------------------------------------------------
- * openserver <serverHost> <serverPort> <serverKeys>\n
- * --
- * ok [<jobId>]\n
- * or
- * error\n
- *
- * Starts receiving traffic for the destination specified by <serverKeys>
- * and forwards it to the <serverPort> of <serverHost>.
- * <serverKeys> is the base 64 encoded private key set of the local
- * destination. The <joId> returned together with "ok" can later be used
- * as argument for the "close" command.
- * -------------------------------------------------
- * close [forced] <jobId>\n
- * or
- * close [forced] all\n
- * --
- * ok\n
- * or
- * error\n
- *
- * Closes the job specified by <jobId> or all jobs. Use the list command
- * for a list of running jobs.
- * Normally a connection job is not closed when it still has an active
- * connection. Use the optional 'forced' keyword to close connections
- * regardless of their use.
- * -------------------------------------------------
- * list\n
- * --
- * Example output:
- *
- * [0] i2p.dnsalias.net/69.55.226.145:5555 <- C:\i2pKeys\squidPriv
- * [1] 8767 -> HTTPClient
- * [2] 7575 -> file:C:\i2pKeys\squidPub
- * [3] 5252 -> sCcSANIO~f4AQtCNI1BvDp3ZBS~9Ag5O0k0Msm7XBWWz5eOnZWL3MQ-2rxlesucb9XnpASGhWzyYNBpWAfaIB3pux1J1xujQLOwscMIhm7T8BP76Ly5jx6BLZCYrrPj0BI0uV90XJyT~4UyQgUlC1jzFQdZ9HDgBPJDf1UI4-YjIwEHuJgdZynYlQ1oUFhgno~HhcDByXO~PDaO~1JDMDbBEfIh~v6MgmHp-Xchod1OfKFrxFrzHgcJbn7E8edTFjZA6JCi~DtFxFelQz1lSBd-QB1qJnA0g-pVL5qngNUojXJCXs4qWcQ7ICLpvIc-Fpfj-0F1gkVlGDSGkb1yLH3~8p4czYgR3W5D7OpwXzezz6clpV8kmbd~x2SotdWsXBPRhqpewO38coU4dJG3OEUbuYmdN~nJMfWbmlcM1lXzz2vBsys4sZzW6dV3hZnbvbfxNTqbdqOh-KXi1iAzXv7CVTun0ubw~CfeGpcAqutC5loRUq7Mq62ngOukyv8Z9AAAA
- *
- * Lists descriptions of all running jobs. The exact format of the
- * description depends on the type of job.
- * -------------------------------------------------
- *
- *
- *
- * @deprecated this isn't run by default, and no one seems to use it, and has
- * lots of things to maintain. so, at some point this may dissapear
- * unless someone pipes up ;)
- */
-public class TunnelManager implements Runnable {
- private final static Log _log = new Log(TunnelManager.class);
- private I2PTunnel _tunnel;
- private ServerSocket _socket;
- private boolean _keepAccepting;
-
- public TunnelManager(int listenPort) {
- this(null, listenPort);
- }
-
- public TunnelManager(String listenHost, int listenPort) {
- _tunnel = new I2PTunnel();
- _keepAccepting = true;
- try {
- if (listenHost != null) {
- _socket = new ServerSocket(listenPort, 0, InetAddress.getByName(listenHost));
- _log.info("Listening for tunnel management clients on " + listenHost + ":" + listenPort);
- } else {
- _socket = new ServerSocket(listenPort);
- _log.info("Listening for tunnel management clients on localhost:" + listenPort);
- }
- } catch (Exception e) {
- _log.error("Error starting up tunnel management listener on " + listenPort, e);
- }
- }
-
- public static void main(String args[]) {
- int port = 7676;
- String host = null;
- if (args.length == 1) {
- try {
- port = Integer.parseInt(args[0]);
- } catch (NumberFormatException nfe) {
- _log.error("Usage: TunnelManager [host] [port]");
- return;
- }
- } else if (args.length == 2) {
- host = args[0];
- try {
- port = Integer.parseInt(args[1]);
- } catch (NumberFormatException nfe) {
- _log.error("Usage: TunnelManager [host] [port]");
- return;
- }
- }
-
- TunnelManager mgr = new TunnelManager(host, port);
- Thread t = new I2PThread(mgr, "Listener");
- t.start();
- }
-
- public void run() {
- if (_socket == null) {
- _log.error("Unable to start listening, since the socket was not bound. Already running?");
- return;
- }
- _log.debug("Running");
- try {
- while (_keepAccepting) {
- Socket socket = _socket.accept();
- _log.debug("Client accepted");
- if (socket != null) {
- Thread t = new I2PThread(new TunnelManagerClientRunner(this, socket));
- t.setName("TunnelManager Client");
- t.setPriority(I2PThread.MIN_PRIORITY);
- t.start();
- }
- }
- } catch (IOException ioe) {
- _log.error("Error accepting connections", ioe);
- } catch (Exception e) {
- _log.error("Other error?!", e);
- } finally {
- if (_socket != null) try {
- _socket.close();
- } catch (IOException ioe) {
- }
- }
- try {
- Thread.sleep(5000);
- } catch (InterruptedException ie) {
- }
- }
-
- public void error(String msg, OutputStream out) throws IOException {
- out.write(msg.getBytes());
- out.write('\n');
- }
-
- public void processQuit(OutputStream out) throws IOException {
- out.write("Nice try".getBytes());
- out.write('\n');
- }
-
- public void processList(OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- long startCommand = Clock.getInstance().now();
- _tunnel.runCommand("list", buf);
- Object obj = _tunnel.waitEventValue("listDone");
- long endCommand = Clock.getInstance().now();
- String str = buf.getBuffer();
- _log.debug("ListDone complete after " + (endCommand - startCommand) + "ms: [" + str + "]");
- out.write(str.getBytes());
- out.write('\n');
- buf.ignoreFurtherActions();
- }
-
- public void processListenOn(String ip, OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("listen_on " + ip, buf);
- String status = (String) _tunnel.waitEventValue("listen_onResult");
- out.write((status + "\n").getBytes());
- buf.ignoreFurtherActions();
- }
-
- /**
- * "lookup " returns with the result in base64, else "Unknown host" [or something like that],
- * then a newline.
- *
- */
- public void processLookup(String name, OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("lookup " + name, buf);
- String rv = (String) _tunnel.waitEventValue("lookupResult");
- out.write(rv.getBytes());
- out.write('\n');
- buf.ignoreFurtherActions();
- }
-
- public void processTestDestination(String destKey, OutputStream out) throws IOException {
- try {
- Destination d = new Destination();
- d.fromBase64(destKey);
- out.write("valid\n".getBytes());
- } catch (DataFormatException dfe) {
- out.write("invalid\n".getBytes());
- }
- out.flush();
- }
-
- public void processConvertPrivate(String priv, OutputStream out) throws IOException {
- try {
- Destination dest = new Destination();
- dest.fromBase64(priv);
- String str = dest.toBase64();
- out.write(str.getBytes());
- out.write('\n');
- } catch (DataFormatException dfe) {
- _log.error("Error converting private data", dfe);
- out.write("Error converting private key\n".getBytes());
- }
- }
-
- public void processClose(String which, boolean forced, OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand((forced ? "close forced " : "close ") + which, buf);
- String str = (String) _tunnel.waitEventValue("closeResult");
- out.write((str + "\n").getBytes());
- buf.ignoreFurtherActions();
- }
-
- /**
- * "genkey" returns with the base64 of the destination, followed by a tab, then the base64 of that
- * destination's private keys, then a newline.
- *
- */
- public void processGenKey(OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("gentextkeys", buf);
- String priv = (String) _tunnel.waitEventValue("privateKey");
- String pub = (String) _tunnel.waitEventValue("publicDestination");
- out.write((pub + "\t" + priv).getBytes());
- out.write('\n');
- buf.ignoreFurtherActions();
- }
-
- public void processOpenClient(int listenPort, String peer, String sharedClient, OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("client " + listenPort + " " + peer + " " + sharedClient, buf);
- Integer taskId = (Integer) _tunnel.waitEventValue("clientTaskId");
- if (taskId.intValue() < 0) {
- out.write("error\n".getBytes());
- buf.ignoreFurtherActions();
- return;
- }
- String rv = (String) _tunnel.waitEventValue("openClientResult");
- if (rv.equals("error")) {
- out.write((rv + "\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
-
- if (listenPort != 0) {
- out.write((rv + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
- Integer port = (Integer) _tunnel.waitEventValue("clientLocalPort");
- out.write((rv + " " + port.intValue() + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- }
-
- public void processOpenHTTPClient(int listenPort, String sharedClient, String proxy, OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("httpclient " + listenPort + " " + sharedClient + " " + proxy, buf);
- Integer taskId = (Integer) _tunnel.waitEventValue("httpclientTaskId");
- if (taskId.intValue() < 0) {
- out.write("error\n".getBytes());
- buf.ignoreFurtherActions();
- return;
- }
- String rv = (String) _tunnel.waitEventValue("openHTTPClientResult");
- if (rv.equals("error")) {
- out.write((rv + "\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
-
- if (listenPort != 0) {
- out.write((rv + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
- Integer port = (Integer) _tunnel.waitEventValue("clientLocalPort");
- out.write((rv + " " + port.intValue() + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- }
-
- public void processOpenSOCKSTunnel(int listenPort, OutputStream out) throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("sockstunnel " + listenPort, buf);
- Integer taskId = (Integer) _tunnel.waitEventValue("sockstunnelTaskId");
- if (taskId.intValue() < 0) {
- out.write("error\n".getBytes());
- buf.ignoreFurtherActions();
- return;
- }
- String rv = (String) _tunnel.waitEventValue("openSOCKSTunnelResult");
- if (rv.equals("error")) {
- out.write((rv + "\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
-
- if (listenPort != 0) {
- out.write((rv + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
- Integer port = (Integer) _tunnel.waitEventValue("clientLocalPort");
- out.write((rv + " " + port.intValue() + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- }
-
- public void processOpenServer(String serverHost, int serverPort, String privateKeys, OutputStream out)
- throws IOException {
- BufferLogger buf = new BufferLogger();
- _tunnel.runCommand("textserver " + serverHost + " " + serverPort + " " + privateKeys, buf);
- Integer taskId = (Integer) _tunnel.waitEventValue("serverTaskId");
- if (taskId.intValue() < 0) {
- out.write("error\n".getBytes());
- buf.ignoreFurtherActions();
- return;
- }
-
- String rv = (String) _tunnel.waitEventValue("openServerResult");
-
- if (rv.equals("error")) {
- out.write((rv + "\n").getBytes());
- buf.ignoreFurtherActions();
- return;
- }
-
- out.write((rv + " [" + taskId.intValue() + "]\n").getBytes());
- buf.ignoreFurtherActions();
- }
-
- /**
- * Frisbee.
- *
- */
- public void unknownCommand(String command, OutputStream out) throws IOException {
- out.write("Unknown command: ".getBytes());
- out.write(command.getBytes());
- out.write("\n".getBytes());
- }
-}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelManagerClientRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelManagerClientRunner.java
deleted file mode 100644
index 6bd9bb730d..0000000000
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelManagerClientRunner.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/* I2PTunnel is GPL'ed (with the exception mentioned in I2PTunnel.java)
- * (c) 2003 - 2004 mihi
- */
-
-package net.i2p.i2ptunnel;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.util.StringTokenizer;
-
-import net.i2p.util.Log;
-
-/**
- * Runner thread that reads commands from the socket and fires off commands to
- * the TunnelManager
- *
- */
-class TunnelManagerClientRunner implements Runnable {
- private final static Log _log = new Log(TunnelManagerClientRunner.class);
- private TunnelManager _mgr;
- private Socket _clientSocket;
-
- public TunnelManagerClientRunner(TunnelManager mgr, Socket socket) {
- _clientSocket = socket;
- _mgr = mgr;
- }
-
- public void run() {
- _log.debug("Client running");
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(_clientSocket.getInputStream()));
- OutputStream out = _clientSocket.getOutputStream();
-
- String cmd = reader.readLine();
- if (cmd != null) processCommand(cmd, out);
- } catch (IOException ioe) {
- _log.error("Error processing client commands", ioe);
- } finally {
- if (_clientSocket != null) try {
- _clientSocket.close();
- } catch (IOException ioe) {
- }
- }
- _log.debug("Client closed");
- }
-
- /**
- * Parse the command string and fire off the appropriate tunnelManager method,
- * sending the results to the output stream
- */
- private void processCommand(String command, OutputStream out) throws IOException {
- _log.debug("Processing [" + command + "]");
- StringTokenizer tok = new StringTokenizer(command);
- if (!tok.hasMoreTokens()) {
- _mgr.unknownCommand(command, out);
- } else {
- String cmd = tok.nextToken();
- if ("quit".equalsIgnoreCase(cmd)) {
- _mgr.processQuit(out);
- } else if ("lookup".equalsIgnoreCase(cmd)) {
- if (tok.hasMoreTokens())
- _mgr.processLookup(tok.nextToken(), out);
- else
- _mgr.error("Usage: lookup ", out);
- } else if ("testdestination".equalsIgnoreCase(cmd)) {
- if (tok.hasMoreTokens())
- _mgr.processTestDestination(tok.nextToken(), out);
- else
- _mgr.error("Usage: testdestination ", out);
- } else if ("convertprivate".equalsIgnoreCase(cmd)) {
- if (tok.hasMoreTokens())
- _mgr.processConvertPrivate(tok.nextToken(), out);
- else
- _mgr.error("Usage: convertprivate ", out);
- } else if ("close".equalsIgnoreCase(cmd)) {
- if (tok.hasMoreTokens()) {
- String closeArg;
- if ((closeArg = tok.nextToken()).equals("forced")) {
- if (tok.hasMoreTokens()) {
- _mgr.processClose(tok.nextToken(), true, out);
- } else {
- _mgr.error("Usage: close [forced] |all", out);
- }
- } else {
- _mgr.processClose(closeArg, false, out);
- }
- } else {
- _mgr.error("Usage: close [forced] |all", out);
- }
- } else if ("genkey".equalsIgnoreCase(cmd)) {
- _mgr.processGenKey(out);
- } else if ("list".equalsIgnoreCase(cmd)) {
- _mgr.processList(out);
- } else if ("listen_on".equalsIgnoreCase(cmd)) {
- if (tok.hasMoreTokens()) {
- _mgr.processListenOn(tok.nextToken(), out);
- } else {
- _mgr.error("Usage: listen_on ", out);
- }
- } else if ("openclient".equalsIgnoreCase(cmd)) {
- int listenPort = 0;
- String peer = null;
- String sharedClient = null;
- int numTokens = tok.countTokens();
- if (numTokens < 2 || numTokens > 3) {
- _mgr.error("Usage: openclient ", out);
- return;
- }
- try {
- listenPort = Integer.parseInt(tok.nextToken());
- peer = tok.nextToken();
- if (tok.hasMoreTokens())
- sharedClient = tok.nextToken();
- else
- sharedClient = "true";
- _mgr.processOpenClient(listenPort, peer, sharedClient, out);
- } catch (NumberFormatException nfe) {
- _mgr.error("Bad listen port", out);
- return;
- }
- } else if ("openhttpclient".equalsIgnoreCase(cmd)) {
- int listenPort = 0;
- String proxy = "squid.i2p";
- String sharedClient = "true";
- int numTokens = tok.countTokens();
- if (numTokens < 1 || numTokens > 3) {
- _mgr.error("Usage: openhttpclient [] []", out);
- return;
- }
- try {
- listenPort = Integer.parseInt(tok.nextToken());
- if (tok.hasMoreTokens()) {
- String val = tok.nextToken();
- if (tok.hasMoreTokens()) {
- sharedClient = val;
- proxy = tok.nextToken();
- } else {
- if ( ("true".equals(val)) || ("false".equals(val)) ) {
- sharedClient = val;
- } else {
- proxy = val;
- }
- }
- }
- _mgr.processOpenHTTPClient(listenPort, sharedClient, proxy, out);
- } catch (NumberFormatException nfe) {
- _mgr.error("Bad listen port", out);
- return;
- }
- } else if ("opensockstunnel".equalsIgnoreCase(cmd)) {
- int listenPort = 0;
- if (!tok.hasMoreTokens()) {
- _mgr.error("Usage: opensockstunnel ", out);
- return;
- }
- try {
- String portStr = tok.nextToken();
- listenPort = Integer.parseInt(portStr);
- } catch (NumberFormatException nfe) {
- _mgr.error("Bad listen port", out);
- return;
- }
- if (tok.hasMoreTokens()) {
- _mgr.error("Usage: opensockstunnel ", out);
- return;
- }
- _mgr.processOpenSOCKSTunnel(listenPort, out);
- } else if ("openserver".equalsIgnoreCase(cmd)) {
- int listenPort = 0;
- String serverHost = null;
- String serverKeys = null;
- if (!tok.hasMoreTokens()) {
- _mgr.error("Usage: openserver ", out);
- return;
- }
- serverHost = tok.nextToken();
-
- if (!tok.hasMoreTokens()) {
- _mgr.error("Usage: openserver ", out);
- return;
- }
- try {
- String portStr = tok.nextToken();
- listenPort = Integer.parseInt(portStr);
- } catch (NumberFormatException nfe) {
- _mgr.error("Bad listen port", out);
- return;
- }
- if (!tok.hasMoreTokens()) {
- _mgr.error("Usage: openserver ", out);
- return;
- }
- serverKeys = tok.nextToken();
- _mgr.processOpenServer(serverHost, listenPort, serverKeys, out);
- } else {
- _mgr.unknownCommand(command, out);
- }
- }
- }
-}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
index 8cf396102e..8b039732e7 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java
@@ -28,7 +28,8 @@ public class ConfigNetHandler extends FormHandler {
private boolean _reseedRequested;
private boolean _saveRequested;
private boolean _timeSyncEnabled;
- private String _port;
+ private String _tcpPort;
+ private String _udpPort;
private String _inboundRate;
private String _inboundBurst;
private String _outboundRate;
@@ -56,8 +57,11 @@ public class ConfigNetHandler extends FormHandler {
public void setHostname(String hostname) {
_hostname = (hostname != null ? hostname.trim() : null);
}
- public void setPort(String port) {
- _port = (port != null ? port.trim() : null);
+ public void setTcpPort(String port) {
+ _tcpPort = (port != null ? port.trim() : null);
+ }
+ public void setUdpPort(String port) {
+ _udpPort = (port != null ? port.trim() : null);
}
public void setInboundrate(String rate) {
_inboundRate = (rate != null ? rate.trim() : null);
@@ -207,14 +211,25 @@ public class ConfigNetHandler extends FormHandler {
restartRequired = true;
}
}
- if ( (_port != null) && (_port.length() > 0) ) {
+ if ( (_tcpPort != null) && (_tcpPort.length() > 0) ) {
String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT);
- if ( (oldPort == null) && (_port.equals("8887")) ) {
+ if ( (oldPort == null) && (_tcpPort.equals("8887")) ) {
// still on default.. noop
- } else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_port)) ) {
+ } else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_tcpPort)) ) {
// its not the default OR it has changed
- _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _port);
- addFormNotice("Updating TCP port from " + oldPort + " to " + _port);
+ _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _tcpPort);
+ addFormNotice("Updating TCP port from " + oldPort + " to " + _tcpPort);
+ restartRequired = true;
+ }
+ }
+ if ( (_udpPort != null) && (_udpPort.length() > 0) ) {
+ String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_UDP_PORT);
+ if ( (oldPort == null) && (_udpPort.equals("8887")) ) {
+ // still on default.. noop
+ } else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_udpPort)) ) {
+ // its not the default OR it has changed
+ _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _udpPort);
+ addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
restartRequired = true;
}
}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
index fa66bac35e..12e01852a5 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java
@@ -24,11 +24,13 @@ public class ConfigNetHelper {
/** copied from various private TCP components */
public final static String PROP_I2NP_TCP_HOSTNAME = "i2np.tcp.hostname";
public final static String PROP_I2NP_TCP_PORT = "i2np.tcp.port";
+ public final static String PROP_I2NP_UDP_PORT = "i2np.udp.port";
+ public final static String PROP_I2NP_INTERNAL_UDP_PORT = "i2np.udp.internalPort";
public String getHostname() {
return _context.getProperty(PROP_I2NP_TCP_HOSTNAME);
}
- public String getPort() {
+ public String getTcpPort() {
int port = 8887;
String val = _context.getProperty(PROP_I2NP_TCP_PORT);
if (val != null) {
@@ -41,6 +43,21 @@ public class ConfigNetHelper {
return "" + port;
}
+ public String getUdpPort() {
+ int port = 8887;
+ String val = _context.getProperty(PROP_I2NP_UDP_PORT);
+ if (val == null)
+ val = _context.getProperty(PROP_I2NP_INTERNAL_UDP_PORT);
+ if (val != null) {
+ try {
+ port = Integer.parseInt(val);
+ } catch (NumberFormatException nfe) {
+ // ignore, use default from above
+ }
+ }
+ return "" + port;
+ }
+
public String getEnableTimeSyncChecked() {
String disabled = _context.getProperty(Timestamper.PROP_DISABLED, "false");
if ( (disabled != null) && ("true".equalsIgnoreCase(disabled)) )
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java
index 3aa0dd90e4..bcb2af1d58 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java
@@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import net.i2p.util.Log;
import net.i2p.stat.StatManager;
/**
@@ -22,6 +23,7 @@ public class ConfigStatsHandler extends FormHandler {
public ConfigStatsHandler() {
super();
_stats = new ArrayList();
+ _explicitFilter = false;
}
protected void processForm() {
@@ -36,29 +38,16 @@ public class ConfigStatsHandler extends FormHandler {
if (stats != null) {
for (int i = 0; i < stats.length; i++) {
String cur = stats[i].trim();
+ if (_log.shouldLog(Log.DEBUG))
+ _log.debug("Stat: [" + cur + "]");
if ( (cur.length() > 0) && (!_stats.contains(cur)) )
_stats.add(cur);
}
}
+ if (_log.shouldLog(Log.DEBUG))
+ _log.debug("Updated stats: " + _stats);
}
- public void setStatList(String stat) {
- if (stat != null) {
- if (stat.indexOf(',') != -1) {
- StringTokenizer tok = new StringTokenizer(stat, ",");
- while (tok.hasMoreTokens()) {
- String cur = tok.nextToken().trim();
- if ( (cur.length() > 0) && (!_stats.contains(cur)) )
- _stats.add(cur);
- }
- } else {
- stat = stat.trim();
- if ( (stat.length() > 0) && (!_stats.contains(stat)) )
- _stats.add(stat);
- }
- }
- }
-
public void setExplicitFilter(String foo) { _explicitFilter = true; }
public void setExplicitFilterValue(String filter) { _explicitFilterValue = filter; }
@@ -74,7 +63,19 @@ public class ConfigStatsHandler extends FormHandler {
if (_explicitFilter) {
_stats.clear();
- setStatList(_explicitFilterValue);
+
+ if (_explicitFilterValue.indexOf(',') != -1) {
+ StringTokenizer tok = new StringTokenizer(_explicitFilterValue, ",");
+ while (tok.hasMoreTokens()) {
+ String cur = tok.nextToken().trim();
+ if ( (cur.length() > 0) && (!_stats.contains(cur)) )
+ _stats.add(cur);
+ }
+ } else {
+ String stat = _explicitFilterValue.trim();
+ if ( (stat.length() > 0) && (!_stats.contains(stat)) )
+ _stats.add(stat);
+ }
}
StringBuffer stats = new StringBuffer();
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java
index 9f14c8b16b..1d66037afe 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java
@@ -4,6 +4,7 @@ import java.util.List;
import java.util.ArrayList;
import net.i2p.router.RouterContext;
+import net.i2p.util.Log;
/**
* Simple form handler base class - does not depend on servlets or jsp,
@@ -16,6 +17,7 @@ import net.i2p.router.RouterContext;
*/
public class FormHandler {
protected RouterContext _context;
+ protected Log _log;
private String _nonce;
protected String _action;
private List _errors;
@@ -41,6 +43,7 @@ public class FormHandler {
public void setContextId(String contextId) {
try {
_context = ContextHelper.getContext(contextId);
+ _log = _context.logManager().getLog(getClass());
} catch (Throwable t) {
t.printStackTrace();
}
diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp
index 3209ce3f98..99735f68b7 100644
--- a/apps/routerconsole/jsp/config.jsp
+++ b/apps/routerconsole/jsp/config.jsp
@@ -28,13 +28,13 @@
" />
- TCP port:
- " />
+ UDP port:
+
+You must poke a hole in your firewall or NAT (if applicable) to receive new inbound UDP packets on
+this port from arbitrary peers (this requirement will be removed in i2p 0.6.1, but is necessary now)
+ TCP port: " /> You must poke a hole in your firewall or NAT (if applicable) so that you can receive inbound TCP
- connections on it. Nothing will work if you don't. Sorry. We know how to make it so
- this restriction won't be necessary, but its later on in the
- roadmap and we only have so many coder-hours (but if you want
- to help, please get involved!)
+ connections on it (this requirement will be removed in i2p 0.6.1, but is necessary now)
Bandwidth limiter
@@ -57,7 +57,7 @@
packets on port 123 to one of the pool.ntp.org machines (or some other SNTP server).
- Changing the TCP port will force a 'soft restart' - dropping your connections and clients as
+ Changing the TCP or UDP port will force a 'soft restart' - dropping your connections and clients as
if the router was stopped and restarted. Please be patient - it may take
a few seconds to complete.
@@ -73,6 +73,13 @@
"i2p.reseedURL=someURL" (e.g. java -Di2p.reseedURL=http://dev.i2p.net/i2pdb/ ...). You can
also do it manually by getting routerInfo-*.dat files from someone (a friend, someone on IRC,
whatever) and saving them to your netDb/ directory.
+
+ With the SSU transport, the internal UDP port may be different from the external
+ UDP port (in case of a firewall/NAT) - the UDP port field above specifies the
+ external one and assumes they are the same, but if you want to set the internal
+ port to something else, you can add "i2np.udp.internalPort=1234" to the
+ advanced config and restart the router.
+