From f205140b04330cf9c7533dd7b105a26ffd181c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 8 Nov 2022 16:45:19 +0800 Subject: [PATCH] Fix smux keep alive --- common/mux/protocol.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/mux/protocol.go b/common/mux/protocol.go index 706512a2..26abebb1 100644 --- a/common/mux/protocol.go +++ b/common/mux/protocol.go @@ -43,7 +43,7 @@ func ParseProtocol(name string) (Protocol, error) { func (p Protocol) newServer(conn net.Conn) (abstractSession, error) { switch p { case ProtocolSMux: - session, err := smux.Server(conn, nil) + session, err := smux.Server(conn, smuxConfig()) if err != nil { return nil, err } @@ -58,7 +58,7 @@ func (p Protocol) newServer(conn net.Conn) (abstractSession, error) { func (p Protocol) newClient(conn net.Conn) (abstractSession, error) { switch p { case ProtocolSMux: - session, err := smux.Client(conn, nil) + session, err := smux.Client(conn, smuxConfig()) if err != nil { return nil, err } @@ -70,6 +70,12 @@ func (p Protocol) newClient(conn net.Conn) (abstractSession, error) { } } +func smuxConfig() *smux.Config { + config := smux.DefaultConfig() + config.KeepAliveDisabled = true + return config +} + func yaMuxConfig() *yamux.Config { config := yamux.DefaultConfig() config.LogOutput = io.Discard