From e77a44fa8a454e58f2157d96a433e9ca45968091 Mon Sep 17 00:00:00 2001 From: nange Date: Sun, 28 Apr 2024 19:32:02 +0800 Subject: [PATCH] fix: goroutine leak in httptunnel --- remote.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/remote.go b/remote.go index 0c30f023..e6b112a9 100644 --- a/remote.go +++ b/remote.go @@ -7,6 +7,7 @@ import ( "io" "net" "os" + "time" "github.com/caddyserver/certmagic" "github.com/nange/easyss/v2/cipherstream" @@ -198,6 +199,8 @@ func (es *EasyServer) handShakeWithClient(conn net.Conn) (hsRes, error) { cs := csStream.(*cipherstream.CipherStream) defer cs.Release() + _ = csStream.SetDeadline(time.Now().Add(5 * es.Timeout())) + var frame *cipherstream.Frame for { frame, err = cs.ReadFrame() @@ -205,6 +208,8 @@ func (es *EasyServer) handShakeWithClient(conn net.Conn) (hsRes, error) { return res, err } + _ = csStream.SetDeadline(time.Now().Add(5 * es.Timeout())) + if frame.IsPingFrame() { log.Debug("[REMOTE] got ping message", "payload", string(frame.RawDataPayload()), "is_need_ack", frame.IsNeedACK())