Fix socks so it uses existing tunnels rather than building a new one for every request.

Now works with or without 'shared clients' enabled.
This commit is contained in:
zzz
2009-01-23 02:23:13 +00:00
parent 9885779cab
commit c02711ccad
2 changed files with 8 additions and 5 deletions

View File

@ -46,11 +46,11 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase {
try {
SOCKSServer serv = SOCKSServerFactory.createSOCKSServer(s);
Socket clientSock = serv.getClientSocket();
I2PSocket destSock = serv.getDestinationI2PSocket();
I2PSocket destSock = serv.getDestinationI2PSocket(this);
new I2PTunnelRunner(clientSock, destSock, sockLock, null, mySockets);
} catch (SOCKSException e) {
_log.error("Error from SOCKS connection: " + e.getMessage());
closeSocket(s);
}
}
}
}

View File

@ -59,7 +59,7 @@ public abstract class SOCKSServer {
*
* @return an I2PSocket connected with the destination
*/
public I2PSocket getDestinationI2PSocket() throws SOCKSException {
public I2PSocket getDestinationI2PSocket(I2PSOCKSTunnel t) throws SOCKSException {
setupServer();
if (connHostName == null) {
@ -79,8 +79,11 @@ public abstract class SOCKSServer {
try {
if (connHostName.toLowerCase().endsWith(".i2p")) {
_log.debug("connecting to " + connHostName + "...");
I2PSocketManager sm = I2PSocketManagerFactory.createManager();
destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
// Let's not due a new Dest for every request, huh?
//I2PSocketManager sm = I2PSocketManagerFactory.createManager();
//destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
// TODO get the streaming lib options in there
destSock = t.createI2PSocket(I2PTunnel.destFromName(connHostName));
confirmConnection();
_log.debug("connection confirmed - exchanging data...");
} else {