diff --git a/Release.md b/Release.md index cff4dbc12b..c5d16402f9 100644 --- a/Release.md +++ b/Release.md @@ -1 +1,4 @@ -### Features +### Fixes + +* Fix the issue of not disabling tcp keepalive when configuring `tcp_keepalive` = -1 in frps. +* Fix a race condition error. diff --git a/client/proxy/proxy.go b/client/proxy/proxy.go index 82d5d9f2ef..62d02fcfc2 100644 --- a/client/proxy/proxy.go +++ b/client/proxy/proxy.go @@ -143,7 +143,9 @@ func (pxy *BaseProxy) HandleTCPWorkConnection(workConn net.Conn, m *msg.StartWor } } if baseConfig.UseCompression { - remote = libio.WithCompression(remote) + var releaseFn func() + remote, releaseFn = libio.WithCompressionFromPool(remote) + defer releaseFn() } // check if we need to send proxy protocol info diff --git a/client/proxy/sudp.go b/client/proxy/sudp.go index 9d61e22855..0981c6568d 100644 --- a/client/proxy/sudp.go +++ b/client/proxy/sudp.go @@ -97,7 +97,9 @@ func (pxy *SUDPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) { } } if pxy.cfg.UseCompression { - rwc = libio.WithCompression(rwc) + var releaseFn func() + rwc, releaseFn = libio.WithCompressionFromPool(rwc) + defer releaseFn() } conn = utilnet.WrapReadWriteCloserToConn(rwc, conn) diff --git a/client/proxy/udp.go b/client/proxy/udp.go index adf92766d4..cc187000f5 100644 --- a/client/proxy/udp.go +++ b/client/proxy/udp.go @@ -108,7 +108,9 @@ func (pxy *UDPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) { } } if pxy.cfg.UseCompression { - rwc = libio.WithCompression(rwc) + var releaseFn func() + rwc, releaseFn = libio.WithCompressionFromPool(rwc) + defer releaseFn() } conn = utilnet.WrapReadWriteCloserToConn(rwc, conn) diff --git a/client/visitor/stcp.go b/client/visitor/stcp.go index 2ea27f38f7..86e09ac0b7 100644 --- a/client/visitor/stcp.go +++ b/client/visitor/stcp.go @@ -126,7 +126,9 @@ func (sv *STCPVisitor) handleConn(userConn net.Conn) { } if sv.cfg.UseCompression { - remote = libio.WithCompression(remote) + var releaseFn func() + remote, releaseFn = libio.WithCompressionFromPool(remote) + defer releaseFn() } libio.Join(userConn, remote) diff --git a/client/visitor/xtcp.go b/client/visitor/xtcp.go index 9f83b3945f..713ed341ad 100644 --- a/client/visitor/xtcp.go +++ b/client/visitor/xtcp.go @@ -200,7 +200,9 @@ func (sv *XTCPVisitor) handleConn(userConn net.Conn) { } } if sv.cfg.UseCompression { - muxConnRWCloser = libio.WithCompression(muxConnRWCloser) + var releaseFn func() + muxConnRWCloser, releaseFn = libio.WithCompressionFromPool(muxConnRWCloser) + defer releaseFn() } _, _, errs := libio.Join(userConn, muxConnRWCloser) diff --git a/go.mod b/go.mod index 9572d9523d..65374ab6ba 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 github.com/coreos/go-oidc/v3 v3.4.0 github.com/fatedier/beego v0.0.0-20171024143340-6c6a4f5bd5eb - github.com/fatedier/golib v0.1.1-0.20230717092310-8d13bff6d373 + github.com/fatedier/golib v0.1.1-0.20230720124328-204db2e322f8 github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible github.com/go-playground/validator/v10 v10.11.0 github.com/google/uuid v1.3.0 @@ -43,7 +43,7 @@ require ( github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/golang/snappy v0.0.3 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index c1e754d174..68f4520ce0 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatedier/beego v0.0.0-20171024143340-6c6a4f5bd5eb h1:wCrNShQidLmvVWn/0PikGmpdP0vtQmnvyRg3ZBEhczw= github.com/fatedier/beego v0.0.0-20171024143340-6c6a4f5bd5eb/go.mod h1:wx3gB6dbIfBRcucp94PI9Bt3I0F2c/MyNEWuhzpWiwk= -github.com/fatedier/golib v0.1.1-0.20230717092310-8d13bff6d373 h1:lprMgD5nOD9k2Af0T/al8nU31YvFkTyCtRapi4z2jbQ= -github.com/fatedier/golib v0.1.1-0.20230717092310-8d13bff6d373/go.mod h1:Wdn1pJ0dHB1lah6FPYwt4AO9NEmWI0OzW13dpzC9g4E= +github.com/fatedier/golib v0.1.1-0.20230720124328-204db2e322f8 h1:8JYzwZ26k1zEsjgits6GHsQxm2tl3K3FYgMMLcIKBKU= +github.com/fatedier/golib v0.1.1-0.20230720124328-204db2e322f8/go.mod h1:Lmi9U4VfvdRvonSMh1FgXVy1hCXycVyJk4E9ktokknE= github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible h1:ssXat9YXFvigNge/IkkZvFMn8yeYKFX+uI6wn2mLJ74= github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible/go.mod h1:YpCOaxj7vvMThhIQ9AfTOPW2sfztQR5WDfs7AflSy4s= github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d h1:ynk1ra0RUqDWQfvFi5KtMiSobkVQ3cNc0ODb8CfIETo= @@ -189,8 +189,9 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= diff --git a/pkg/util/version/version.go b/pkg/util/version/version.go index 1778fd8e4d..670e07fcec 100644 --- a/pkg/util/version/version.go +++ b/pkg/util/version/version.go @@ -19,7 +19,7 @@ import ( "strings" ) -var version = "0.51.0" +var version = "0.51.1" func Full() string { return version diff --git a/server/proxy/http.go b/server/proxy/http.go index 432dbc101b..81139167ee 100644 --- a/server/proxy/http.go +++ b/server/proxy/http.go @@ -175,7 +175,9 @@ func (pxy *HTTPProxy) GetRealConn(remoteAddr string) (workConn net.Conn, err err } } if pxy.cfg.UseCompression { - rwc = libio.WithCompression(rwc) + var releaseFn func() + rwc, releaseFn = libio.WithCompressionFromPool(rwc) + defer releaseFn() } if pxy.GetLimiter() != nil { diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index aeb2ef050b..9d6ee99355 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -241,7 +241,9 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) { } } if cfg.UseCompression { - local = libio.WithCompression(local) + var releaseFn func() + local, releaseFn = libio.WithCompressionFromPool(local) + defer releaseFn() } if pxy.GetLimiter() != nil { diff --git a/test/e2e/basic/basic.go b/test/e2e/basic/basic.go index d032a0d9a4..805b46010b 100644 --- a/test/e2e/basic/basic.go +++ b/test/e2e/basic/basic.go @@ -298,6 +298,7 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() { case "xtcp": localPortName = framework.TCPEchoServerPort protocol = "tcp" + ginkgo.Skip("stun server is not stable") } correctSK := "abc" @@ -363,6 +364,7 @@ var _ = ginkgo.Describe("[Feature: Basic]", func() { use_encryption = true use_compression = true `, + skipXTCP: true, }, { proxyName: "with-error-sk",