Fully clean up I2PTunnel. No more lint issues, should compile 100% clean.
Dropped unused class BufferLogger from I2PTunnel as it is not used anylonger.
This commit is contained in:
@ -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 + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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+"");
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 });
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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!
|
||||
|
@ -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 = "";
|
||||
|
Reference in New Issue
Block a user