* I2PTunnel:
- Switch all I2PThreads to I2PAppThreads - Run an InternalSocket as well for the HTTP Proxy * EepGet: Use InternalSocket * Console: Change "depth" to "length"
This commit is contained in:
@ -20,7 +20,7 @@ import java.util.zip.GZIPInputStream;
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.ByteArray;
|
||||
import net.i2p.util.ByteCache;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@ class HTTPResponseOutputStream extends FilterOutputStream {
|
||||
//out.flush();
|
||||
PipedInputStream pi = new PipedInputStream();
|
||||
PipedOutputStream po = new PipedOutputStream(pi);
|
||||
new I2PThread(new Pusher(pi, out), "HTTP decompresser").start();
|
||||
new I2PAppThread(new Pusher(pi, out), "HTTP decompresser").start();
|
||||
out = po;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import net.i2p.client.streaming.I2PSocketManagerFactory;
|
||||
import net.i2p.client.streaming.I2PSocketOptions;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
@ -153,7 +153,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
|
||||
} // else delay creating session until createI2PSocket() is called
|
||||
|
||||
Thread t = new I2PThread(this);
|
||||
Thread t = new I2PAppThread(this);
|
||||
t.setName("Client " + _clientId);
|
||||
listenerReady = false;
|
||||
t.start();
|
||||
@ -207,7 +207,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
|
||||
for (int i = 0; i < _numConnectionBuilders; i++) {
|
||||
String name = "ClientBuilder" + _clientId + '.' + i;
|
||||
I2PThread b = new I2PThread(new TunnelConnectionBuilder(), name);
|
||||
I2PAppThread b = new I2PAppThread(new TunnelConnectionBuilder(), name);
|
||||
b.setDaemon(true);
|
||||
b.start();
|
||||
}
|
||||
@ -350,7 +350,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
* called by derived classes after initialization.
|
||||
*
|
||||
*/
|
||||
public final void startRunning() {
|
||||
public void startRunning() {
|
||||
synchronized (startLock) {
|
||||
startRunning = true;
|
||||
startLock.notify();
|
||||
@ -490,7 +490,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
protected void manageConnection(Socket s) {
|
||||
if (s == null) return;
|
||||
if (_numConnectionBuilders <= 0) {
|
||||
new I2PThread(new BlockingRunner(s), "Clinet run").start();
|
||||
new I2PAppThread(new BlockingRunner(s), "Clinet run").start();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -233,6 +233,29 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
return opts;
|
||||
}
|
||||
|
||||
private InternalSocketRunner isr;
|
||||
|
||||
/**
|
||||
* Actually start working on incoming connections.
|
||||
* Overridden to start an internal socket too.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void startRunning() {
|
||||
super.startRunning();
|
||||
this.isr = new InternalSocketRunner(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to close internal socket too.
|
||||
*/
|
||||
public boolean close(boolean forced) {
|
||||
boolean rv = super.close(forced);
|
||||
if (this.isr != null)
|
||||
this.isr.stopRunning();
|
||||
return rv;
|
||||
}
|
||||
|
||||
private static final boolean DEFAULT_GZIP = true;
|
||||
// all default to false
|
||||
public static final String PROP_REFERER = "i2ptunnel.httpclient.sendReferer";
|
||||
|
@ -17,7 +17,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.data.Base32;
|
||||
|
||||
@ -118,7 +118,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
useGZIP = true;
|
||||
|
||||
if (allowGZIP && useGZIP) {
|
||||
I2PThread req = new I2PThread(new CompressedRequestor(s, socket, modifiedHeader), Thread.currentThread().getName()+".hc");
|
||||
I2PAppThread req = new I2PAppThread(new CompressedRequestor(s, socket, modifiedHeader), Thread.currentThread().getName()+".hc");
|
||||
req.start();
|
||||
} else {
|
||||
new I2PTunnelRunner(s, socket, slock, null, modifiedHeader.getBytes(), null);
|
||||
@ -174,7 +174,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
_log.info("request headers: " + _headers);
|
||||
serverout.write(_headers.getBytes());
|
||||
browserin = _browser.getInputStream();
|
||||
I2PThread sender = new I2PThread(new Sender(serverout, browserin, "server: browser to server"), Thread.currentThread().getName() + "hcs");
|
||||
I2PAppThread sender = new I2PAppThread(new Sender(serverout, browserin, "server: browser to server"), Thread.currentThread().getName() + "hcs");
|
||||
sender.start();
|
||||
|
||||
browserout = _browser.getOutputStream();
|
||||
|
@ -14,7 +14,7 @@ import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable {
|
||||
@ -83,9 +83,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
|
||||
i2ps = createI2PSocket(clientDest);
|
||||
i2ps.setReadTimeout(readTimeout);
|
||||
StringBuilder expectedPong = new StringBuilder();
|
||||
Thread in = new I2PThread(new IrcInboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " in");
|
||||
Thread in = new I2PAppThread(new IrcInboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " in");
|
||||
in.start();
|
||||
Thread out = new I2PThread(new IrcOutboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " out");
|
||||
Thread out = new I2PAppThread(new IrcOutboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " out");
|
||||
out.start();
|
||||
} catch (Exception ex) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
|
@ -16,10 +16,10 @@ import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.data.ByteArray;
|
||||
import net.i2p.util.ByteCache;
|
||||
import net.i2p.util.Clock;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorListener {
|
||||
public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErrorListener {
|
||||
private final static Log _log = new Log(I2PTunnelRunner.class);
|
||||
|
||||
private static volatile long __runnerId;
|
||||
@ -222,7 +222,7 @@ public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorL
|
||||
}
|
||||
}
|
||||
|
||||
private class StreamForwarder extends I2PThread {
|
||||
private class StreamForwarder extends I2PAppThread {
|
||||
|
||||
InputStream in;
|
||||
OutputStream out;
|
||||
|
@ -24,7 +24,7 @@ import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.client.streaming.I2PSocketManagerFactory;
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
@ -132,7 +132,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
*
|
||||
*/
|
||||
public void startRunning() {
|
||||
Thread t = new I2PThread(this);
|
||||
Thread t = new I2PAppThread(this);
|
||||
t.setName("Server " + (++__serverId));
|
||||
t.start();
|
||||
}
|
||||
@ -204,7 +204,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
I2PServerSocket i2pS_S = sockMgr.getServerSocket();
|
||||
int handlers = getHandlerCount();
|
||||
for (int i = 0; i < handlers; i++) {
|
||||
I2PThread handler = new I2PThread(new Handler(i2pS_S), "Handle Server " + i);
|
||||
I2PAppThread handler = new I2PAppThread(new Handler(i2pS_S), "Handle Server " + i);
|
||||
handler.start();
|
||||
}
|
||||
} else {
|
||||
@ -213,7 +213,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
try {
|
||||
final I2PSocket i2ps = i2pS_S.accept();
|
||||
if (i2ps == null) throw new I2PException("I2PServerSocket closed");
|
||||
new I2PThread(new Runnable() { public void run() { blockingHandle(i2ps); } }).start();
|
||||
new I2PAppThread(new Runnable() { public void run() { blockingHandle(i2ps); } }).start();
|
||||
} catch (I2PException ipe) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error accepting - KILLING THE TUNNEL SERVER", ipe);
|
||||
|
@ -14,7 +14,7 @@ import net.i2p.I2PException;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.EventDispatcher;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public class I2Ping extends I2PTunnelTask implements Runnable {
|
||||
@ -59,7 +59,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable {
|
||||
sockMgr = I2PTunnelClient.getSocketManager(tunnel);
|
||||
}
|
||||
}
|
||||
Thread t = new I2PThread(this);
|
||||
Thread t = new I2PAppThread(this);
|
||||
t.setName("Client");
|
||||
t.start();
|
||||
open = true;
|
||||
@ -188,7 +188,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public class PingHandler extends I2PThread {
|
||||
public class PingHandler extends I2PAppThread {
|
||||
private String destination;
|
||||
|
||||
public PingHandler(String dest) {
|
||||
|
@ -0,0 +1,55 @@
|
||||
package net.i2p.i2ptunnel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.InternalServerSocket;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
* Listen for in-JVM connections on the internal "socket"
|
||||
*
|
||||
* @author zzz
|
||||
*/
|
||||
class InternalSocketRunner implements Runnable {
|
||||
private I2PTunnelClientBase client;
|
||||
private int port;
|
||||
private ServerSocket ss;
|
||||
private boolean open;
|
||||
private static final Log _log = new Log(InternalSocketRunner.class);
|
||||
|
||||
/** starts the runner */
|
||||
InternalSocketRunner(I2PTunnelClientBase client) {
|
||||
this.client = client;
|
||||
this.port = client.getLocalPort();
|
||||
Thread t = new I2PAppThread(this, "Internal socket port " + this.port, true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
public final void run() {
|
||||
try {
|
||||
this.ss = new InternalServerSocket(this.port);
|
||||
this.open = true;
|
||||
while (true) {
|
||||
Socket s = this.ss.accept();
|
||||
this.client.manageConnection(s);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
if (this.open) {
|
||||
_log.error("Error listening for internal connections on " + this.port, ex);
|
||||
}
|
||||
this.open = false;
|
||||
}
|
||||
}
|
||||
|
||||
void stopRunning() {
|
||||
if (this.open) {
|
||||
try {
|
||||
this.ss.close();
|
||||
} catch (IOException ex) {}
|
||||
this.open = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ import net.i2p.client.I2PClientFactory;
|
||||
import net.i2p.client.I2PSession;
|
||||
import net.i2p.data.Base32;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
@ -106,7 +106,7 @@ public class TunnelController implements Logging {
|
||||
public void startTunnelBackground() {
|
||||
if (_running) return;
|
||||
_starting = true;
|
||||
new I2PThread(new Runnable() { public void run() { startTunnel(); } }).start();
|
||||
new I2PAppThread(new Runnable() { public void run() { startTunnel(); } }).start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ import net.i2p.I2PAppContext;
|
||||
import net.i2p.client.I2PSession;
|
||||
import net.i2p.client.I2PSessionException;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
@ -94,7 +94,7 @@ public class TunnelControllerGroup {
|
||||
_controllers.add(controller);
|
||||
i++;
|
||||
}
|
||||
I2PThread startupThread = new I2PThread(new StartControllers(), "Startup tunnels");
|
||||
I2PAppThread startupThread = new I2PAppThread(new StartControllers(), "Startup tunnels");
|
||||
startupThread.start();
|
||||
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
|
@ -205,9 +205,9 @@
|
||||
</div>
|
||||
<div id="depthField" class="rowItem">
|
||||
<label for="tunnelDepth" accesskey="t">
|
||||
Dep<span class="accessKey">t</span>h:
|
||||
Leng<span class="accessKey">t</span>h:
|
||||
</label>
|
||||
<select id="tunnelDepth" name="tunnelDepth" title="Depth of each Tunnel" class="selectbox">
|
||||
<select id="tunnelDepth" name="tunnelDepth" title="Length of each Tunnel" class="selectbox">
|
||||
<% int tunnelDepth = editBean.getTunnelDepth(curTunnel, 2);
|
||||
%><option value="0"<%=(tunnelDepth == 0 ? " selected=\"selected\"" : "") %>>0 hop tunnel (low anonymity, low latency)</option>
|
||||
<option value="1"<%=(tunnelDepth == 1 ? " selected=\"selected\"" : "") %>>1 hop tunnel (medium anonymity, medium latency)</option>
|
||||
@ -222,7 +222,7 @@
|
||||
<label for="tunnelVariance" accesskey="v">
|
||||
<span class="accessKey">V</span>ariance:
|
||||
</label>
|
||||
<select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Depth" class="selectbox">
|
||||
<select id="tunnelVariance" name="tunnelVariance" title="Level of Randomization for Tunnel Length" class="selectbox">
|
||||
<% int tunnelVariance = editBean.getTunnelVariance(curTunnel, 0);
|
||||
%><option value="0"<%=(tunnelVariance == 0 ? " selected=\"selected\"" : "") %>>0 hop variance (no randomisation, consistant performance)</option>
|
||||
<option value="1"<%=(tunnelVariance == 1 ? " selected=\"selected\"" : "") %>>+ 0-1 hop variance (medium additive randomisation, subtractive performance)</option>
|
||||
|
@ -172,9 +172,9 @@
|
||||
</div>
|
||||
<div id="depthField" class="rowItem">
|
||||
<label for="tunnelDepth" accesskey="t">
|
||||
Dep<span class="accessKey">t</span>h:
|
||||
Leng<span class="accessKey">t</span>h:
|
||||
</label>
|
||||
<select id="tunnelDepth" name="tunnelDepth" title="Depth of each Tunnel" class="selectbox">
|
||||
<select id="tunnelDepth" name="tunnelDepth" title="Length of each Tunnel" class="selectbox">
|
||||
<% int tunnelDepth = editBean.getTunnelDepth(curTunnel, 2);
|
||||
%><option value="0"<%=(tunnelDepth == 0 ? " selected=\"selected\"" : "") %>>0 hop tunnel (low anonymity, low latency)</option>
|
||||
<option value="1"<%=(tunnelDepth == 1 ? " selected=\"selected\"" : "") %>>1 hop tunnel (medium anonymity, medium latency)</option>
|
||||
|
@ -84,7 +84,7 @@ public class ConfigTunnelsHelper extends HelperBase {
|
||||
// buf.append("<tr><th></th><th>Inbound</th><th>Outbound</th></tr>\n");
|
||||
|
||||
// tunnel depth
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Depth") + ":</td>\n");
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Length") + ":</td>\n");
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".depthInbound\">\n");
|
||||
int now = in.getLength();
|
||||
renderOptions(buf, 0, MAX_LENGTH, now, "", HOP);
|
||||
|
@ -16,6 +16,7 @@ import java.util.StringTokenizer;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.InternalSocket;
|
||||
|
||||
/**
|
||||
* EepGet [-p 127.0.0.1:4444]
|
||||
@ -869,7 +870,7 @@ public class EepGet {
|
||||
if (_proxy != null) try { _proxy.close(); } catch (IOException ioe) {}
|
||||
|
||||
if (_shouldProxy) {
|
||||
_proxy = new Socket(_proxyHost, _proxyPort);
|
||||
_proxy = InternalSocket.getSocket(_proxyHost, _proxyPort);
|
||||
} else {
|
||||
try {
|
||||
URL url = new URL(_actualURL);
|
||||
|
@ -63,13 +63,24 @@ public class InternalSocket extends Socket {
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
if (_is != null) _is.close();
|
||||
if (_is != null) {
|
||||
_is.close();
|
||||
_is = null;
|
||||
}
|
||||
} catch (IOException ie) {}
|
||||
try {
|
||||
if (_os != null) _os.close();
|
||||
if (_os != null) {
|
||||
_os.close();
|
||||
_os = null;
|
||||
}
|
||||
} catch (IOException ie) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return _is == null || _os == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("Internal socket");
|
||||
@ -183,11 +194,6 @@ public class InternalSocket extends Socket {
|
||||
}
|
||||
/** @deprecated unsupported */
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
throw new IllegalArgumentException("unsupported");
|
||||
}
|
||||
/** @deprecated unsupported */
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
throw new IllegalArgumentException("unsupported");
|
||||
}
|
||||
|
Reference in New Issue
Block a user