This commit is contained in:
Administrator
2025-08-08 17:13:27 +08:00
parent 7267aec1fd
commit 306bfd36f7
39 changed files with 2515 additions and 355 deletions
@@ -20,6 +20,15 @@ public class SocketToSocketProxy extends Proxy {
private SocketBridgeFactory defaultFactory;
private SocketChannelBridgeFactory defaultChannelFactory;
private Map<String, SocketBridgeFactory> detectedFactory;
private int defaultSoTimeout=120*60*1000;
public int getDefaultSoTimeout() {
return defaultSoTimeout;
}
public void setDefaultSoTimeout(int defaultSoTimeout) {
this.defaultSoTimeout = defaultSoTimeout;
}
public SocketToSocketProxy(MultipurposeSocketAddress listen, MultipurposeSocketAddress connect) throws IOException {
this(listen, new MultipurposeSocketAddress(new InetSocketAddress(0)), connect);
@@ -152,6 +161,8 @@ public class SocketToSocketProxy extends Proxy {
protected void runBridge(SocketBridgeFactory sbf,Socket sk, Socket sox) throws IOException {
sk.setSoTimeout(defaultSoTimeout);
sox.setSoTimeout(defaultSoTimeout);
sk.setTcpNoDelay(true);
sox.setTcpNoDelay(true);
SocketBridge sb = sbf.createBridge(sk, sox);
@@ -159,6 +170,8 @@ public class SocketToSocketProxy extends Proxy {
}
protected void runChannelBridge(SocketChannelBridgeFactory sbf,SocketChannel sk, SocketChannel sox) throws IOException {
//sk.setSoTimeout(defaultSoTimeout);
//sox.setSoTimeout(defaultSoTimeout);
sk.setOption(StandardSocketOptions.TCP_NODELAY, true);
sox.setOption(StandardSocketOptions.TCP_NODELAY, true);
SocketChannelBridge sb = sbf.createBridge(sk, sox);