Skip to content

Commit 1015624

Browse files
committed
fix: tcp反向代理时目标不可达则断开源头连接
1 parent c77c716 commit 1015624

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>top.meethigher</groupId>
88
<artifactId>tcp-reverse-proxy</artifactId>
9-
<version>1.0.4</version>
9+
<version>1.0.5</version>
1010

1111
<properties>
1212
<maven.compiler.source>8</maven.compiler.source>

src/main/java/top/meethigher/proxy/tcp/ReverseTcpProxy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ protected ReverseTcpProxy(NetServer netServer, NetClient netClient,
4747
// 暂停流读取
4848
sourceSocket.pause();
4949
netClient.connect(targetPort, targetHost)
50-
.onFailure(e -> log.error("failed to connect to {}:{}", targetHost, targetPort, e))
50+
.onFailure(e -> {
51+
log.error("failed to connect to {}:{}", targetHost, targetPort, e);
52+
sourceSocket.close();
53+
})
5154
.onSuccess(targetSocket -> {
5255
SocketAddress sourceRemoteAddress = sourceSocket.remoteAddress();
5356
SocketAddress sourceLocalAddress = sourceSocket.localAddress();

0 commit comments

Comments
 (0)