diff --git a/CHANGELOG b/CHANGELOG index 9f7f636..245b88c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ proxy更新日志 v4.9 1.修复了HTTP Basic代理返回不合适的头部,导致浏览器不会弹框,个别代理插件无法认证的问题. -2.mux内网穿透切换smux到yamux. +2.内网穿透切换smux到yamux. v4.8 diff --git a/services/tunnel_bridge.go b/services/tunnel_bridge.go index 333523d..8352d15 100644 --- a/services/tunnel_bridge.go +++ b/services/tunnel_bridge.go @@ -5,12 +5,14 @@ import ( "fmt" logger "log" "net" + "os" "strconv" "time" "github.com/snail007/goproxy/utils" - "github.com/xtaci/smux" + //"github.com/xtaci/smux" + smux "github.com/hashicorp/yamux" ) type ServerConn struct { @@ -89,10 +91,12 @@ func (s *TunnelBridge) callback(inConn net.Conn) { var err error //s.log.Printf("connection from %s ", inConn.RemoteAddr()) sess, err := smux.Server(inConn, &smux.Config{ - KeepAliveInterval: 10 * time.Second, - KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second, - MaxFrameSize: 4096, - MaxReceiveBuffer: 4194304, + AcceptBacklog: 256, + EnableKeepAlive: true, + KeepAliveInterval: 9 * time.Second, + ConnectionWriteTimeout: 3 * time.Second, + MaxStreamWindowSize: 512 * 1024, + LogOutput: os.Stderr, }) if err != nil { s.log.Printf("new mux server conn error,ERR:%s", err) diff --git a/services/tunnel_client.go b/services/tunnel_client.go index 29af4be..120d450 100644 --- a/services/tunnel_client.go +++ b/services/tunnel_client.go @@ -6,11 +6,13 @@ import ( "io" logger "log" "net" + "os" "time" "github.com/snail007/goproxy/utils" - "github.com/xtaci/smux" + //"github.com/xtaci/smux" + smux "github.com/hashicorp/yamux" ) type TunnelClient struct { @@ -139,10 +141,12 @@ func (s *TunnelClient) GetConn() (conn net.Conn, err error) { if err == nil { conn = net.Conn(&_conn) c, e := smux.Client(conn, &smux.Config{ - KeepAliveInterval: 10 * time.Second, - KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second, - MaxFrameSize: 4096, - MaxReceiveBuffer: 4194304, + AcceptBacklog: 256, + EnableKeepAlive: true, + KeepAliveInterval: 9 * time.Second, + ConnectionWriteTimeout: 3 * time.Second, + MaxStreamWindowSize: 512 * 1024, + LogOutput: os.Stderr, }) if e != nil { s.log.Printf("new mux client conn error,ERR:%s", e) diff --git a/services/tunnel_server.go b/services/tunnel_server.go index 6c4086e..91f7306 100644 --- a/services/tunnel_server.go +++ b/services/tunnel_server.go @@ -6,6 +6,7 @@ import ( "io" logger "log" "net" + "os" "runtime/debug" "strconv" "strings" @@ -13,7 +14,8 @@ import ( "github.com/snail007/goproxy/utils" - "github.com/xtaci/smux" + //"github.com/xtaci/smux" + smux "github.com/hashicorp/yamux" ) type TunnelServer struct { @@ -288,10 +290,12 @@ func (s *TunnelServer) GetConn() (conn net.Conn, err error) { if err == nil { conn = net.Conn(&_conn) c, e := smux.Client(conn, &smux.Config{ - KeepAliveInterval: 10 * time.Second, - KeepAliveTimeout: time.Duration(*s.cfg.Timeout) * time.Second, - MaxFrameSize: 4096, - MaxReceiveBuffer: 4194304, + AcceptBacklog: 256, + EnableKeepAlive: true, + KeepAliveInterval: 9 * time.Second, + ConnectionWriteTimeout: 3 * time.Second, + MaxStreamWindowSize: 512 * 1024, + LogOutput: os.Stderr, }) if e != nil { s.log.Printf("new mux client conn error,ERR:%s", e)