豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit cd53f7d

Browse files
Fanglidingyuhan6665
authored andcommitted
Close target when client closed
1 parent e4eec45 commit cd53f7d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tls.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,17 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
272272
if config.Show && hs.clientHello != nil {
273273
fmt.Printf("REALITY remoteAddr: %v\tforwarded SNI: %v\n", remoteAddr, hs.clientHello.serverName)
274274
}
275-
io.Copy(target, NewRatelimitedConn(underlying, &config.LimitFallbackUpload))
275+
_, err := io.Copy(target, NewRatelimitedConn(underlying, &config.LimitFallbackUpload))
276+
// close target writer when received FIN (err==nil)
277+
if err == nil {
278+
targetWriterCloser, ok := target.(CloseWriteConn)
279+
if ok {
280+
targetWriterCloser.CloseWrite()
281+
}
282+
} else {
283+
// Close target when encountering RST (or any other errors)
284+
target.Close()
285+
}
276286
}
277287
waitGroup.Done()
278288
}()

0 commit comments

Comments
 (0)