Compare commits

...

5 Commits

Author SHA1 Message Date
Shay Molcho
d77b00d53a
Merge 58ac53e39fb7253c7eddb466c663ec28fb3a69a3 into 1e8db667434f8f43cd60c16e9a6d694e9bd6e420 2025-02-12 13:32:37 +09:00
fatedier
1e8db66743
update Release.md (#4668) 2025-02-12 12:30:37 +08:00
fatedier
e0dd947e6a
frps: release resources in service.Close() (#4667) 2025-02-12 12:22:57 +08:00
ubergeek77
8b86e1473c
Fix ports not being released on Service.Close() (#4666) 2025-02-12 11:28:30 +08:00
Shay Molcho
58ac53e39f
Added missing colons for consistency and correctness
Inserted missing colons in specific parts of the text to maintain consistency with the existing format. This adjustment ensures a uniform writing style, improves readability, and aligns the text structure with the rest of the document.
2025-01-28 20:57:26 +02:00
8 changed files with 37 additions and 9 deletions

View File

@ -1235,7 +1235,7 @@ sshTunnelGateway.bindPort = 2200
When running `./frps -c frps.toml`, a private key file named `.autogen_ssh_key` will be automatically created in the current working directory. This generated private key file will be used by the SSH server in frps.
Executing the command
Executing the command:
```bash
ssh -R :80:127.0.0.1:8080 v0@{frp address} -p 2200 tcp --proxy_name "test-tcp" --remote_port 9090

View File

@ -1,3 +1,7 @@
### Features
* Support metadatas and annotations in frpc proxy commands.
### Fixes
* Properly release resources in service.Close() to prevent resource leaks when used as a library.

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.22.0
require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/coreos/go-oidc/v3 v3.10.0
github.com/fatedier/golib v0.5.0
github.com/fatedier/golib v0.5.1
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.0

4
go.sum
View File

@ -21,8 +21,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatedier/golib v0.5.0 h1:hNcH7hgfIFqVWbP+YojCCAj4eO94pPf4dEF8lmq2jWs=
github.com/fatedier/golib v0.5.0/go.mod h1:W6kIYkIFxHsTzbgqg5piCxIiDo4LzwgTY6R5W8l9NFQ=
github.com/fatedier/golib v0.5.1 h1:hcKAnaw5mdI/1KWRGejxR+i1Hn/NvbY5UsMKDr7o13M=
github.com/fatedier/golib v0.5.1/go.mod h1:W6kIYkIFxHsTzbgqg5piCxIiDo4LzwgTY6R5W8l9NFQ=
github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d h1:ynk1ra0RUqDWQfvFi5KtMiSobkVQ3cNc0ODb8CfIETo=
github.com/fatedier/yamux v0.0.0-20230628132301-7aca4898904d/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U=

View File

@ -112,6 +112,10 @@ func (g *Gateway) Run() {
}
}
func (g *Gateway) Close() error {
return g.ln.Close()
}
func (g *Gateway) handleConn(conn net.Conn) {
defer conn.Close()

View File

@ -100,6 +100,10 @@ func (v *Muxer) SetRewriteHostFunc(f hostRewriteFunc) *Muxer {
return v
}
func (v *Muxer) Close() error {
return v.listener.Close()
}
type ChooseEndpointFunc func() (string, error)
type CreateConnFunc func(remoteAddr string) (net.Conn, error)

View File

@ -59,3 +59,13 @@ type ResourceController struct {
// All server manager plugin
PluginManager *plugin.Manager
}
func (rc *ResourceController) Close() error {
if rc.VhostHTTPSMuxer != nil {
rc.VhostHTTPSMuxer.Close()
}
if rc.TCPMuxHTTPConnectMuxer != nil {
rc.TCPMuxHTTPConnectMuxer.Close()
}
return nil
}

View File

@ -386,24 +386,30 @@ func (svr *Service) Run(ctx context.Context) {
func (svr *Service) Close() error {
if svr.kcpListener != nil {
svr.kcpListener.Close()
svr.kcpListener = nil
}
if svr.quicListener != nil {
svr.quicListener.Close()
svr.quicListener = nil
}
if svr.websocketListener != nil {
svr.websocketListener.Close()
svr.websocketListener = nil
}
if svr.tlsListener != nil {
svr.tlsListener.Close()
svr.tlsConfig = nil
}
if svr.sshTunnelListener != nil {
svr.sshTunnelListener.Close()
}
if svr.listener != nil {
svr.listener.Close()
svr.listener = nil
}
if svr.webServer != nil {
svr.webServer.Close()
}
if svr.sshTunnelGateway != nil {
svr.sshTunnelGateway.Close()
}
svr.rc.Close()
svr.muxer.Close()
svr.ctlManager.Close()
if svr.cancel != nil {
svr.cancel()