diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index d1516f80..c6caff6c 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -2,7 +2,7 @@ name: Build Image and Publish to Dockerhub & GPR on: release: - types: [ created ] + types: [ published ] workflow_dispatch: inputs: tag: @@ -61,7 +61,7 @@ jobs: echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV - name: Build and push frpc - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: ./dockerfiles/Dockerfile-for-frpc diff --git a/Release.md b/Release.md index 9f3577bb..a1fa993a 100644 --- a/Release.md +++ b/Release.md @@ -1,14 +1,9 @@ -### Notable Changes - -We have optimized the heartbeat mechanism when tcpmux is enabled (enabled by default). The default value of `heartbeatInterval` has been adjusted to -1. This update ensures that when tcpmux is active, the client does not send additional heartbeats to the server. Since tcpmux incorporates its own heartbeat system, this change effectively reduces unnecessary data consumption, streamlining communication efficiency between client and server. - -When connecting to frps versions older than v0.39.0 might encounter compatibility issues due to changes in the heartbeat mechanism. As a temporary workaround, setting the `heartbeatInterval` to 30 can help maintain stable connectivity with these older versions. We recommend updating to the latest frps version to leverage full functionality and improvements. - -### Features - -* Show tcpmux proxies on the frps dashboard. -* `http` proxy can modify the response header. For example, `responseHeaders.set.foo = "bar"` will add a new header `foo: bar` to the response. - ### Fixes -* When an HTTP proxy request times out, it returns 504 instead of 404 now. +* Fixed an issue where HTTP/2 was not enabled for https2http and https2https plugins. +* Fixed the issue where the default values of INI configuration parameters are inconsistent with other configuration formats. + +### Changes + +* Updated the default value of `transport.tcpMuxKeepaliveInterval` from 60 to 30. +* On the Android platform, the Google DNS server is used only when the default DNS server cannot be obtained. diff --git a/conf/frpc_full_example.toml b/conf/frpc_full_example.toml index 3d4d0347..c88087a1 100644 --- a/conf/frpc_full_example.toml +++ b/conf/frpc_full_example.toml @@ -76,7 +76,7 @@ transport.poolCount = 5 # Specify keep alive interval for tcp mux. # only valid if tcpMux is enabled. -# transport.tcpMuxKeepaliveInterval = 60 +# transport.tcpMuxKeepaliveInterval = 30 # Communication protocol used to connect to server # supports tcp, kcp, quic, websocket and wss now, default is tcp diff --git a/conf/frps_full_example.toml b/conf/frps_full_example.toml index 35c1a57b..a4fc2736 100644 --- a/conf/frps_full_example.toml +++ b/conf/frps_full_example.toml @@ -34,7 +34,7 @@ transport.maxPoolCount = 5 # Specify keep alive interval for tcp mux. # only valid if tcpMux is true. -# transport.tcpMuxKeepaliveInterval = 60 +# transport.tcpMuxKeepaliveInterval = 30 # tcpKeepalive specifies the interval between keep-alive probes for an active network connection between frpc and frps. # If negative, keep-alive probes are disabled. diff --git a/pkg/config/legacy/client.go b/pkg/config/legacy/client.go index b45ed069..7c16c73d 100644 --- a/pkg/config/legacy/client.go +++ b/pkg/config/legacy/client.go @@ -345,35 +345,19 @@ func copySection(source, target *ini.Section) { } // GetDefaultClientConf returns a client configuration with default values. +// Note: Some default values here will be set to empty and will be converted to them +// new configuration through the 'Complete' function to set them as the default +// values of the new configuration. func GetDefaultClientConf() ClientCommonConf { return ClientCommonConf{ ClientConfig: legacyauth.GetDefaultClientConf(), - ServerAddr: "0.0.0.0", - ServerPort: 7000, - NatHoleSTUNServer: "stun.easyvoip.com:3478", - DialServerTimeout: 10, - DialServerKeepAlive: 7200, - HTTPProxy: os.Getenv("http_proxy"), - LogFile: "console", - LogWay: "console", - LogLevel: "info", - LogMaxDays: 3, - AdminAddr: "127.0.0.1", - PoolCount: 1, TCPMux: true, - TCPMuxKeepaliveInterval: 60, LoginFailExit: true, - Start: make([]string, 0), Protocol: "tcp", - QUICKeepalivePeriod: 10, - QUICMaxIdleTimeout: 30, - QUICMaxIncomingStreams: 100000, + Start: make([]string, 0), TLSEnable: true, DisableCustomTLSFirstByte: true, - HeartbeatInterval: 30, - HeartbeatTimeout: 90, Metas: make(map[string]string), - UDPPacketSize: 1500, IncludeConfigFiles: make([]string, 0), } } diff --git a/pkg/config/legacy/server.go b/pkg/config/legacy/server.go index 1279a499..c58f76ad 100644 --- a/pkg/config/legacy/server.go +++ b/pkg/config/legacy/server.go @@ -200,34 +200,20 @@ type ServerCommonConf struct { NatHoleAnalysisDataReserveHours int64 `ini:"nat_hole_analysis_data_reserve_hours" json:"nat_hole_analysis_data_reserve_hours"` } -// GetDefaultServerConf returns a server configuration with reasonable -// defaults. +// GetDefaultServerConf returns a server configuration with reasonable defaults. +// Note: Some default values here will be set to empty and will be converted to them +// new configuration through the 'Complete' function to set them as the default +// values of the new configuration. func GetDefaultServerConf() ServerCommonConf { return ServerCommonConf{ - ServerConfig: legacyauth.GetDefaultServerConf(), - BindAddr: "0.0.0.0", - BindPort: 7000, - QUICKeepalivePeriod: 10, - QUICMaxIdleTimeout: 30, - QUICMaxIncomingStreams: 100000, - VhostHTTPTimeout: 60, - DashboardAddr: "0.0.0.0", - LogFile: "console", - LogWay: "console", - LogLevel: "info", - LogMaxDays: 3, - DetailedErrorsToClient: true, - TCPMux: true, - TCPMuxKeepaliveInterval: 60, - TCPKeepAlive: 7200, - AllowPorts: make(map[int]struct{}), - MaxPoolCount: 5, - MaxPortsPerClient: 0, - HeartbeatTimeout: 90, - UserConnTimeout: 10, - HTTPPlugins: make(map[string]HTTPPluginOptions), - UDPPacketSize: 1500, - NatHoleAnalysisDataReserveHours: 7 * 24, + ServerConfig: legacyauth.GetDefaultServerConf(), + DashboardAddr: "0.0.0.0", + LogFile: "console", + LogWay: "console", + DetailedErrorsToClient: true, + TCPMux: true, + AllowPorts: make(map[int]struct{}), + HTTPPlugins: make(map[string]HTTPPluginOptions), } } diff --git a/pkg/config/v1/client.go b/pkg/config/v1/client.go index 35d8071c..d43ec1bc 100644 --- a/pkg/config/v1/client.go +++ b/pkg/config/v1/client.go @@ -135,7 +135,7 @@ func (c *ClientTransportConfig) Complete() { c.ProxyURL = util.EmptyOr(c.ProxyURL, os.Getenv("http_proxy")) c.PoolCount = util.EmptyOr(c.PoolCount, 1) c.TCPMux = util.EmptyOr(c.TCPMux, lo.ToPtr(true)) - c.TCPMuxKeepaliveInterval = util.EmptyOr(c.TCPMuxKeepaliveInterval, 60) + c.TCPMuxKeepaliveInterval = util.EmptyOr(c.TCPMuxKeepaliveInterval, 30) if lo.FromPtr(c.TCPMux) { // If TCPMux is enabled, heartbeat of application layer is unnecessary because we can rely on heartbeat in tcpmux. c.HeartbeatInterval = util.EmptyOr(c.HeartbeatInterval, -1) diff --git a/pkg/config/v1/plugin.go b/pkg/config/v1/plugin.go index 5602a813..3a7c8344 100644 --- a/pkg/config/v1/plugin.go +++ b/pkg/config/v1/plugin.go @@ -17,6 +17,7 @@ package v1 import ( "bytes" "encoding/json" + "errors" "fmt" "reflect" ) @@ -42,7 +43,7 @@ func (c *TypedClientPluginOptions) UnmarshalJSON(b []byte) error { c.Type = typeStruct.Type if c.Type == "" { - return nil + return errors.New("plugin type is empty") } v, ok := clientPluginOptionsTypeMap[typeStruct.Type] @@ -63,6 +64,10 @@ func (c *TypedClientPluginOptions) UnmarshalJSON(b []byte) error { return nil } +func (c *TypedClientPluginOptions) MarshalJSON() ([]byte, error) { + return json.Marshal(c.ClientPluginOptions) +} + const ( PluginHTTP2HTTPS = "http2https" PluginHTTPProxy = "http_proxy" diff --git a/pkg/config/v1/proxy.go b/pkg/config/v1/proxy.go index 8530e216..45c489f6 100644 --- a/pkg/config/v1/proxy.go +++ b/pkg/config/v1/proxy.go @@ -195,6 +195,10 @@ func (c *TypedProxyConfig) UnmarshalJSON(b []byte) error { return nil } +func (c *TypedProxyConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(c.ProxyConfigurer) +} + type ProxyConfigurer interface { Complete(namePrefix string) GetBaseConfig() *ProxyBaseConfig diff --git a/pkg/config/v1/server.go b/pkg/config/v1/server.go index c4ef59de..3108cd34 100644 --- a/pkg/config/v1/server.go +++ b/pkg/config/v1/server.go @@ -176,7 +176,7 @@ type ServerTransportConfig struct { func (c *ServerTransportConfig) Complete() { c.TCPMux = util.EmptyOr(c.TCPMux, lo.ToPtr(true)) - c.TCPMuxKeepaliveInterval = util.EmptyOr(c.TCPMuxKeepaliveInterval, 60) + c.TCPMuxKeepaliveInterval = util.EmptyOr(c.TCPMuxKeepaliveInterval, 30) c.TCPKeepAlive = util.EmptyOr(c.TCPKeepAlive, 7200) c.MaxPoolCount = util.EmptyOr(c.MaxPoolCount, 5) if lo.FromPtr(c.TCPMux) { diff --git a/pkg/config/v1/visitor.go b/pkg/config/v1/visitor.go index e9fa166e..51fe88a6 100644 --- a/pkg/config/v1/visitor.go +++ b/pkg/config/v1/visitor.go @@ -120,6 +120,10 @@ func (c *TypedVisitorConfig) UnmarshalJSON(b []byte) error { return nil } +func (c *TypedVisitorConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(c.VisitorConfigurer) +} + func NewVisitorConfigurerByType(t VisitorType) VisitorConfigurer { v, ok := visitorConfigTypeMap[t] if !ok { diff --git a/pkg/plugin/client/https2http.go b/pkg/plugin/client/https2http.go index d7bddcb3..6d686361 100644 --- a/pkg/plugin/client/https2http.go +++ b/pkg/plugin/client/https2http.go @@ -72,11 +72,6 @@ func NewHTTPS2HTTPPlugin(options v1.ClientPluginOptions) (Plugin, error) { ErrorLog: stdlog.New(log.NewWriteLogger(log.WarnLevel, 2), "", 0), } - p.s = &http.Server{ - Handler: rp, - ReadHeaderTimeout: 60 * time.Second, - } - var ( tlsConfig *tls.Config err error @@ -90,10 +85,15 @@ func NewHTTPS2HTTPPlugin(options v1.ClientPluginOptions) (Plugin, error) { if err != nil { return nil, fmt.Errorf("gen TLS config error: %v", err) } - ln := tls.NewListener(listener, tlsConfig) + + p.s = &http.Server{ + Handler: rp, + ReadHeaderTimeout: 60 * time.Second, + TLSConfig: tlsConfig, + } go func() { - _ = p.s.Serve(ln) + _ = p.s.ServeTLS(listener, "", "") }() return p, nil } diff --git a/pkg/plugin/client/https2https.go b/pkg/plugin/client/https2https.go index 047d4ff2..5ddd4dd6 100644 --- a/pkg/plugin/client/https2https.go +++ b/pkg/plugin/client/https2https.go @@ -78,11 +78,6 @@ func NewHTTPS2HTTPSPlugin(options v1.ClientPluginOptions) (Plugin, error) { ErrorLog: stdlog.New(log.NewWriteLogger(log.WarnLevel, 2), "", 0), } - p.s = &http.Server{ - Handler: rp, - ReadHeaderTimeout: 60 * time.Second, - } - var ( tlsConfig *tls.Config err error @@ -96,10 +91,15 @@ func NewHTTPS2HTTPSPlugin(options v1.ClientPluginOptions) (Plugin, error) { if err != nil { return nil, fmt.Errorf("gen TLS config error: %v", err) } - ln := tls.NewListener(listener, tlsConfig) + + p.s = &http.Server{ + Handler: rp, + ReadHeaderTimeout: 60 * time.Second, + TLSConfig: tlsConfig, + } go func() { - _ = p.s.Serve(ln) + _ = p.s.ServeTLS(listener, "", "") }() return p, nil } diff --git a/pkg/util/system/system_android.go b/pkg/util/system/system_android.go index bfcf401d..6fcfdbc1 100644 --- a/pkg/util/system/system_android.go +++ b/pkg/util/system/system_android.go @@ -59,8 +59,12 @@ func fixDNSResolver() { // Note: If there are other methods to obtain the default DNS servers, the default DNS servers should be used preferentially. net.DefaultResolver = &net.Resolver{ PreferGo: true, - Dial: func(ctx context.Context, network, _ string) (net.Conn, error) { - return net.Dial(network, "8.8.8.8:53") + Dial: func(ctx context.Context, network, addr string) (net.Conn, error) { + if addr == "127.0.0.1:53" || addr == "[::1]:53" { + addr = "8.8.8.8:53" + } + var d net.Dialer + return d.DialContext(ctx, network, addr) }, } } diff --git a/pkg/util/version/version.go b/pkg/util/version/version.go index c6f3f04b..11d140eb 100644 --- a/pkg/util/version/version.go +++ b/pkg/util/version/version.go @@ -14,7 +14,7 @@ package version -var version = "0.58.0" +var version = "0.58.1" func Full() string { return version