forked from I2P_Developers/i2p.i2p
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:
@@ -46,11 +46,11 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase {
|
|||||||
try {
|
try {
|
||||||
SOCKSServer serv = SOCKSServerFactory.createSOCKSServer(s);
|
SOCKSServer serv = SOCKSServerFactory.createSOCKSServer(s);
|
||||||
Socket clientSock = serv.getClientSocket();
|
Socket clientSock = serv.getClientSocket();
|
||||||
I2PSocket destSock = serv.getDestinationI2PSocket();
|
I2PSocket destSock = serv.getDestinationI2PSocket(this);
|
||||||
new I2PTunnelRunner(clientSock, destSock, sockLock, null, mySockets);
|
new I2PTunnelRunner(clientSock, destSock, sockLock, null, mySockets);
|
||||||
} catch (SOCKSException e) {
|
} catch (SOCKSException e) {
|
||||||
_log.error("Error from SOCKS connection: " + e.getMessage());
|
_log.error("Error from SOCKS connection: " + e.getMessage());
|
||||||
closeSocket(s);
|
closeSocket(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,7 @@ public abstract class SOCKSServer {
|
|||||||
*
|
*
|
||||||
* @return an I2PSocket connected with the destination
|
* @return an I2PSocket connected with the destination
|
||||||
*/
|
*/
|
||||||
public I2PSocket getDestinationI2PSocket() throws SOCKSException {
|
public I2PSocket getDestinationI2PSocket(I2PSOCKSTunnel t) throws SOCKSException {
|
||||||
setupServer();
|
setupServer();
|
||||||
|
|
||||||
if (connHostName == null) {
|
if (connHostName == null) {
|
||||||
@@ -79,8 +79,11 @@ public abstract class SOCKSServer {
|
|||||||
try {
|
try {
|
||||||
if (connHostName.toLowerCase().endsWith(".i2p")) {
|
if (connHostName.toLowerCase().endsWith(".i2p")) {
|
||||||
_log.debug("connecting to " + connHostName + "...");
|
_log.debug("connecting to " + connHostName + "...");
|
||||||
I2PSocketManager sm = I2PSocketManagerFactory.createManager();
|
// Let's not due a new Dest for every request, huh?
|
||||||
destSock = sm.connect(I2PTunnel.destFromName(connHostName), null);
|
//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();
|
confirmConnection();
|
||||||
_log.debug("connection confirmed - exchanging data...");
|
_log.debug("connection confirmed - exchanging data...");
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user