diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java index b346039db..93785e326 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java @@ -32,6 +32,9 @@ public class I2PTunnelClient extends I2PTunnelClientBase { protected long readTimeout = DEFAULT_READ_TIMEOUT; /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @param destinations peers we target, comma- or space-separated. Since 0.9.9, each dest may be appended with :port * @throws IllegalArgumentException if the I2PTunnel does not contain * valid config to contact the router @@ -63,9 +66,6 @@ public class I2PTunnelClient extends I2PTunnelClientBase { } setName(getLocalPort() + " -> " + destinations); - - startRunning(); - notifyEvent("openClientResult", "ok"); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index abac27504..972818cdd 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -398,7 +398,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna if (log != null) log.log("Error opening key file " + ioe); _log.error("Error opening key file", ioe); - throw new IllegalArgumentException("Error opening key file " + ioe); + throw new IllegalArgumentException("Error opening key file", ioe); } finally { if (fis != null) try { fis.close(); } catch (IOException ioe) {} @@ -500,6 +500,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna } private void startup() { + if (_log.shouldLog(Log.DEBUG)) + _log.debug("startup " + _clientId, new Exception("I did it")); // prevent JVM exit when running outside the router boolean isDaemon = getTunnel().getContext().isRouterContext(); Thread t = new I2PAppThread(this, "Client " + _clientId, isDaemon); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java index ffe669f91..876321866 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java @@ -77,6 +77,9 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R "Your browser is misconfigured. Do not use the proxy to access the router console or other localhost destinations.
"; /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @throws IllegalArgumentException if the I2PTunnel does not contain * valid config to contact the router */ @@ -92,8 +95,6 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R } setName("HTTPS Proxy on " + tunnel.listenHost + ':' + localPort); - - startRunning(); } /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java index 56c2e7550..4dbd5e654 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java @@ -30,6 +30,9 @@ public class I2PTunnelHTTPBidirProxy extends I2PTunnelHTTPClient implements Runn /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @throws IllegalArgumentException if the I2PTunnel does not contain * valid config to contact the router */ @@ -38,8 +41,6 @@ public class I2PTunnelHTTPBidirProxy extends I2PTunnelHTTPClient implements Runn // proxyList = new ArrayList(); setName(getLocalPort() + " -> HTTPClient [NO PROXIES]"); - startRunning(); - notifyEvent("openHTTPClientResult", "ok"); } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java index d97482e04..2a3118567 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java @@ -32,7 +32,9 @@ public class I2PTunnelHTTPBidirServer extends I2PTunnelHTTPServer { bidir = true; /* start the httpclient */ - task = new I2PTunnelHTTPBidirProxy(localPort, l, sockMgr, getTunnel(), getEventDispatcher(), __serverId); + I2PTunnelClientBase client = new I2PTunnelHTTPBidirProxy(localPort, l, sockMgr, getTunnel(), getEventDispatcher(), __serverId); + client.startRunning(); + task = client; sockMgr.setName("Server"); // TO-DO: Need to change this to "Bidir"! getTunnel().addSession(sockMgr.getSession()); l.log("Ready!"); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 1426fd398..6dcfd32b7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -192,6 +192,9 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn * This constructor always starts the tunnel (ignoring the i2cp.delayOpen option). * It is used to add a client to an existing socket manager. * + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @param sockMgr the existing socket manager */ public I2PTunnelHTTPClient(int localPort, Logging l, I2PSocketManager sockMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId) { @@ -200,12 +203,13 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn // proxyList = new ArrayList(); setName("HTTP Proxy on " + getTunnel().listenHost + ':' + localPort); - startRunning(); - notifyEvent("openHTTPClientResult", "ok"); } /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @throws IllegalArgumentException if the I2PTunnel does not contain * valid config to contact the router */ @@ -225,9 +229,6 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn } setName("HTTP Proxy on " + tunnel.listenHost + ':' + localPort); - - startRunning(); - notifyEvent("openHTTPClientResult", "ok"); } @@ -607,6 +608,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn _("i2paddresshelper cannot help you with a destination like that!") + "

").getBytes("UTF-8")); writeFooter(out); + reader.drain(); // XXX: should closeSocket(s) be in a finally block? } catch (IOException ioe) { // ignore @@ -721,7 +723,6 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn out.write(getErrorPage("localhost", ERR_LOCALHOST).getBytes("UTF-8")); writeFooter(out); reader.drain(); - s.close(); } catch (IOException ioe) { // ignore } finally { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java index 344c72197..e8fac6812 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java @@ -41,6 +41,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase { public static final String PROP_DCC = "i2ptunnel.ircclient.enableDCC"; /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @param destinations peers we target, comma- or space-separated. Since 0.9.9, each dest may be appended with :port * @throws IllegalArgumentException if the I2PTunnel does not contain * valid config to contact the router @@ -81,8 +84,6 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase { _dccEnabled = Boolean.parseBoolean(tunnel.getClientOptions().getProperty(PROP_DCC)); // TODO add some prudent tunnel options (or is it too late?) - startRunning(); - notifyEvent("openIRCClientResult", "ok"); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java index 42af9abf2..753da65ec 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java @@ -109,6 +109,7 @@ public class DCCClientManager extends EventReceiver { I2PTunnelDCCClient cTunnel = new I2PTunnelDCCClient(b32, localPort, port, l, sockMgr, _dispatch, _tunnel, ++_id); cTunnel.attachEventDispatcher(this); + cTunnel.startRunning(); int lport = cTunnel.getLocalPort(); if (_log.shouldLog(Log.WARN)) _log.warn("Opened client tunnel at port " + lport + diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java index fcca71cb9..f5b434e3b 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCClient.java @@ -37,6 +37,9 @@ public class I2PTunnelDCCClient extends I2PTunnelClientBase { public static final String CONNECT_STOP_EVENT = "connectionStopped"; /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * * @param dest the target, presumably b32 * @param localPort if 0, use any port, get actual port selected with getLocalPort() * @throws IllegalArgumentException if the I2PTunnel does not contain @@ -51,8 +54,6 @@ public class I2PTunnelDCCClient extends I2PTunnelClientBase { _expires = tunnel.getContext().clock().now() + INBOUND_EXPIRE; setName("DCC send -> " + dest + ':' + remotePort); - - startRunning(); } /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java index 498d75a18..6f8f6b3d3 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java @@ -33,7 +33,12 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase { // I2PSOCKSTunnel(localPort, l, ownDest, (EventDispatcher)null); //} - /** @param pkf private key file name or null for transient key */ + /** + * As of 0.9.20 this is fast, and does NOT connect the manager to the router, + * or open the local socket. You MUST call startRunning() for that. + * + * @param pkf private key file name or null for transient key + */ public I2PSOCKSTunnel(int localPort, Logging l, boolean ownDest, EventDispatcher notifyThis, I2PTunnel tunnel, String pkf) { super(localPort, ownDest, l, notifyThis, "SOCKS Proxy on " + tunnel.listenHost + ':' + localPort, tunnel, pkf); @@ -44,8 +49,6 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase { setName("SOCKS Proxy on " + tunnel.listenHost + ':' + localPort); parseOptions(); - startRunning(); - notifyEvent("openSOCKSTunnelResult", "ok"); }