From 0a1960461a9b6957f917def28095a74b00692a60 Mon Sep 17 00:00:00 2001 From: sponge Date: Fri, 15 Jan 2010 03:32:35 +0000 Subject: [PATCH] Fully clean up I2PTunnel. No more lint issues, should compile 100% clean. Dropped unused class BufferLogger from I2PTunnel as it is not used anylonger. --- .../src/net/i2p/i2ptunnel/BufferLogger.java | 72 ------------------- .../i2p/i2ptunnel/I2PTunnelClientBase.java | 8 +-- .../i2ptunnel/I2PTunnelHTTPBidirProxy.java | 4 +- .../i2ptunnel/I2PTunnelHTTPBidirServer.java | 8 +-- .../i2p/i2ptunnel/I2PTunnelHTTPClient.java | 6 +- .../i2p/i2ptunnel/I2PTunnelHTTPServer.java | 8 +-- .../src/net/i2p/i2ptunnel/streamr/Pinger.java | 4 +- .../src/net/i2p/i2ptunnel/udp/I2PSink.java | 16 +---- .../i2p/i2ptunnel/udp/I2PSinkAnywhere.java | 16 +---- .../i2p/client/datagram/I2PDatagramMaker.java | 11 +++ history.txt | 6 ++ .../src/net/i2p/router/RouterVersion.java | 2 +- 12 files changed, 41 insertions(+), 120 deletions(-) delete mode 100644 apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java deleted file mode 100644 index 80d1fd054..000000000 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/BufferLogger.java +++ /dev/null @@ -1,72 +0,0 @@ -/* I2PTunnel is GPL'ed (with the exception mentioned in I2PTunnel.java) - * (c) 2003 - 2004 mihi - */ -package net.i2p.i2ptunnel; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import net.i2p.util.Log; - -/** - * Read what i2ptunnel logs, and expose it in a buffer - * - */ -class BufferLogger implements Logging { - private final static Log _log = new Log(BufferLogger.class); - private ByteArrayOutputStream _baos; // FIXME should be final and use a factory. FIXME - private boolean _ignore; - - /** - * Constructs a buffered logger. - */ - public BufferLogger() { - _baos = new ByteArrayOutputStream(512); - _ignore = false; - } - - private final static String EMPTY = ""; - - /** - * Retrieves the buffer - * @return the buffer - */ - public String getBuffer() { - if (_ignore) - return EMPTY; - - return new String(_baos.toByteArray()); - } - - /** - * We don't care about anything else the logger receives. This is useful - * for loggers passed in to servers and clients, since they will continue - * to add info to the logger, but if we're instantiated by the tunnel manager, - * its likely we only care about the first few messages it sends us. - * - */ - public void ignoreFurtherActions() { - _ignore = true; - synchronized (_baos) { - _baos.reset(); - } - _baos = null; - } - - /** - * Pass in some random data - * @param s String containing what we're logging. - */ - public void log(String s) { - if (_ignore) return; - if (s != null) { - _log.debug("logging [" + s + "]"); - try { - _baos.write(s.getBytes()); - _baos.write('\n'); - } catch (IOException ioe) { - _log.error("Error logging [" + s + "]"); - } - } - } -} \ No newline at end of file diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index cd3e9c1ce..b3ffcdb45 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -67,7 +67,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna // private Object conLock = new Object(); /** List of Socket for those accept()ed but not yet started up */ - private List _waitingSockets = new ArrayList(); // FIXME should be final and use a factory. FIXME + protected final List _waitingSockets = new ArrayList(4); // FIXME should be final and use a factory. FIXME /** How many connections will we allow to be in the process of being built at once? */ private int _numConnectionBuilders; /** How long will we allow sockets to sit in the _waitingSockets map before killing them? */ @@ -93,12 +93,12 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna // true if we are chained from a server. private boolean chained = false; - public I2PTunnelClientBase(int localPort, Logging l, I2PSocketManager SktMgr, + public I2PTunnelClientBase(int localPort, Logging l, I2PSocketManager sktMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId ) throws IllegalArgumentException { super(localPort + " (uninitialized)", notifyThis, tunnel); chained = true; - sockMgr = SktMgr; + sockMgr = sktMgr; _clientId = clientId; this.localPort = localPort; this.l = l; @@ -228,7 +228,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna * */ private void configurePool(I2PTunnel tunnel) { - _waitingSockets = new ArrayList(4); + //_waitingSockets = new ArrayList(4); Properties opts = tunnel.getClientOptions(); String maxWait = opts.getProperty(PROP_MAX_WAIT_TIME, DEFAULT_MAX_WAIT_TIME+""); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java index ecc52762e..8c188d115 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirProxy.java @@ -24,7 +24,7 @@ package net.i2p.i2ptunnel; -import java.util.ArrayList; +// import java.util.ArrayList; import net.i2p.client.streaming.I2PSocketManager; import net.i2p.util.EventDispatcher; @@ -44,7 +44,7 @@ public class I2PTunnelHTTPBidirProxy extends I2PTunnelHTTPClient implements Runn */ public I2PTunnelHTTPBidirProxy(int localPort, Logging l, I2PSocketManager sockMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId) { super(localPort, l, sockMgr, tunnel, notifyThis, clientId); - proxyList = new ArrayList(); + // proxyList = new ArrayList(); setName(getLocalPort() + " -> HTTPClient [NO PROXIES]"); startRunning(); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java index 616867bb2..54b2046cf 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPBidirServer.java @@ -15,20 +15,20 @@ public class I2PTunnelHTTPBidirServer extends I2PTunnelHTTPServer { public I2PTunnelHTTPBidirServer(InetAddress host, int port, int proxyport, String privData, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(host, port, privData, spoofHost, l, notifyThis, tunnel); - I2PTunnelHTTPBidirServerSet(tunnel, l, proxyport); + finishSetupI2PTunnelHTTPBidirServer(l, proxyport); } public I2PTunnelHTTPBidirServer(InetAddress host, int port, int proxyport, File privkey, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(host, port, privkey, privkeyname, spoofHost, l, notifyThis, tunnel); - I2PTunnelHTTPBidirServerSet(tunnel, l, proxyport); + finishSetupI2PTunnelHTTPBidirServer(l, proxyport); } public I2PTunnelHTTPBidirServer(InetAddress host, int port, int proxyport, InputStream privData, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(host, port, privData, privkeyname, spoofHost, l, notifyThis, tunnel); - I2PTunnelHTTPBidirServerSet(tunnel, l, proxyport); + finishSetupI2PTunnelHTTPBidirServer(l, proxyport); } - private void I2PTunnelHTTPBidirServerSet(I2PTunnel tunnel, Logging l, int proxyport) { + private void finishSetupI2PTunnelHTTPBidirServer(Logging l, int proxyport) { localPort = proxyport; bidir = true; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 3a24741c5..a86e01c65 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -57,7 +57,7 @@ import net.i2p.util.Translate; public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable { private static final Log _log = new Log(I2PTunnelHTTPClient.class); - protected List proxyList; + protected final List proxyList = new ArrayList(); private HashMap addressHelpers = new HashMap(); @@ -153,7 +153,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable public I2PTunnelHTTPClient(int localPort, Logging l, I2PSocketManager sockMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId) { super(localPort, l, sockMgr, tunnel, notifyThis, clientId); - proxyList = new ArrayList(); + // proxyList = new ArrayList(); setName(getLocalPort() + " -> HTTPClient [NO PROXIES]"); startRunning(); @@ -169,7 +169,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable I2PTunnel tunnel) throws IllegalArgumentException { super(localPort, ownDest, l, notifyThis, "HTTPHandler " + (++__clientId), tunnel); - proxyList = new ArrayList(); // We won't use outside of i2p + //proxyList = new ArrayList(); // We won't use outside of i2p if (waitEventValue("openBaseClientResult").equals("error")) { notifyEvent("openHTTPClientResult", "error"); return; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java index f0790ac38..d23185780 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java @@ -39,20 +39,20 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { public I2PTunnelHTTPServer(InetAddress host, int port, String privData, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(host, port, privData, l, notifyThis, tunnel); - I2PTunnelHTTPServerSet(spoofHost); + setupI2PTunnelHTTPServer(spoofHost); } public I2PTunnelHTTPServer(InetAddress host, int port, File privkey, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(host, port, privkey, privkeyname, l, notifyThis, tunnel); - I2PTunnelHTTPServerSet(spoofHost); + setupI2PTunnelHTTPServer(spoofHost); } public I2PTunnelHTTPServer(InetAddress host, int port, InputStream privData, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(host, port, privData, privkeyname, l, notifyThis, tunnel); - I2PTunnelHTTPServerSet(spoofHost); + setupI2PTunnelHTTPServer(spoofHost); } - private void I2PTunnelHTTPServerSet(String spoofHost) { + private void setupI2PTunnelHTTPServer(String spoofHost) { _spoofHost = spoofHost; getTunnel().getContext().statManager().createRateStat("i2ptunnel.httpserver.blockingHandleTime", "how long the blocking handle takes to complete", "I2PTunnel.HTTPServer", new long[] { 60*1000, 10*60*1000, 3*60*60*1000 }); getTunnel().getContext().statManager().createRateStat("i2ptunnel.httpNullWorkaround", "How often an http server works around a streaming lib or i2ptunnel bug", "I2PTunnel.HTTPServer", new long[] { 60*1000, 10*60*1000 }); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java index b1abd47e1..695e0e25a 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Pinger.java @@ -16,7 +16,7 @@ public class Pinger implements Source, Runnable { public void start() { this.running = true; - this.waitlock = new Object(); + //this.waitlock = new Object(); this.thread.start(); } @@ -54,6 +54,6 @@ public class Pinger implements Source, Runnable { protected Sink sink; protected Thread thread; - protected Object waitlock; // FIXME should be final and use a factory. FIXME + private final Object waitlock = new Object(); protected boolean running; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java index 6d8737f48..c0e4c6693 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSink.java @@ -29,7 +29,7 @@ public class I2PSink implements Sink { // create maker if (!raw) - this.maker = new I2PDatagramMaker(this.sess); + this.maker.setI2PDatagramMaker(this.sess); } /** @param src ignored */ @@ -54,20 +54,8 @@ public class I2PSink implements Sink { } } - - - - - - - - - - - - protected boolean raw; protected I2PSession sess; protected Destination dest; - protected I2PDatagramMaker maker; // FIXME should be final and use a factory. FIXME + protected final I2PDatagramMaker maker= new I2PDatagramMaker(); // FIXME should be final and use a factory. FIXME } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java index 143422ce4..a2793e7dd 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSinkAnywhere.java @@ -28,7 +28,7 @@ public class I2PSinkAnywhere implements Sink { // create maker if (!raw) - this.maker = new I2PDatagramMaker(this.sess); + this.maker.setI2PDatagramMaker(this.sess); } /** @param to - where it's going */ @@ -52,20 +52,8 @@ public class I2PSinkAnywhere implements Sink { } } - - - - - - - - - - - - protected boolean raw; protected I2PSession sess; protected Destination dest; - protected I2PDatagramMaker maker; // FIXME should be final and use a factory. FIXME + protected final I2PDatagramMaker maker = new I2PDatagramMaker(); } diff --git a/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java b/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java index 669818ac7..0b3baf5b4 100644 --- a/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java +++ b/core/java/src/net/i2p/client/datagram/I2PDatagramMaker.java @@ -48,7 +48,18 @@ public final class I2PDatagramMaker { sxPrivKey = session.getPrivateKey(); sxDestBytes = session.getMyDestination().toByteArray(); } + /** + * Construct a new I2PDatagramMaker that is null. + * Use setI2PDatagramMaker to set the parameters. + */ + public I2PDatagramMaker() { + // nop + } + public void setI2PDatagramMaker(I2PSession session) { + sxPrivKey = session.getPrivateKey(); + sxDestBytes = session.getMyDestination().toByteArray(); + } /** * Make a repliable I2P datagram containing the specified payload. * diff --git a/history.txt b/history.txt index cf5b26532..81633e434 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,9 @@ +2010-01-14 sponge + * Fully clean up I2PTunnel. No more lint issues, should compile 100% + clean. + * Dropped unused class BufferLogger from I2PTunnel as it is not used + anylonger. + 2010-01-14 sponge * Clean up reverse connection ability, remove some annoyingly redundent code. Place all settings in the console. It works! diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index b8546913b..f17951822 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 1; + public final static long BUILD = 2; /** for example "-test" */ public final static String EXTRA = "";