diff --git a/cmd/frps/root.go b/cmd/frps/root.go index fb19f532..b0c91b91 100644 --- a/cmd/frps/root.go +++ b/cmd/frps/root.go @@ -37,29 +37,30 @@ var ( cfgFile string showVersion bool - bindAddr string - bindPort int - bindUdpPort int - kcpBindPort int - proxyBindAddr string - vhostHttpPort int - vhostHttpsPort int - dashboardAddr string - dashboardPort int - dashboardUser string - dashboardPwd string - assetsDir string - logFile string - logWay string - logLevel string - logMaxDays int64 - token string - authTimeout int64 - subDomainHost string - tcpMux bool - allowPorts string - maxPoolCount int64 - maxPortsPerClient int64 + bindAddr string + bindPort int + bindUdpPort int + kcpBindPort int + proxyBindAddr string + vhostHttpPort int + vhostHttpsPort int + dashboardAddr string + dashboardPort int + dashboardUser string + dashboardPwd string + assetsDir string + logFile string + logWay string + logLevel string + logMaxDays int64 + token string + authTimeout int64 + subDomainHost string + tcpMux bool + allowPorts string + maxPoolCount int64 + maxPortsPerClient int64 + ResponseHeaderTimeout int64 ) func init() { @@ -85,6 +86,7 @@ func init() { rootCmd.PersistentFlags().Int64VarP(&authTimeout, "auth_timeout", "", 900, "auth timeout") rootCmd.PersistentFlags().StringVarP(&subDomainHost, "subdomain_host", "", "", "subdomain host") rootCmd.PersistentFlags().Int64VarP(&maxPortsPerClient, "max_ports_per_client", "", 0, "max ports per client") + rootCmd.PersistentFlags().Int64VarP(&ResponseHeaderTimeout, "Response_Header_Timeout", "", 30, "Response Header Timeout") } var rootCmd = &cobra.Command{ @@ -177,6 +179,7 @@ func parseServerCommonCfgFromCmd() (err error) { g.GlbServerCfg.AuthTimeout = authTimeout g.GlbServerCfg.SubDomainHost = subDomainHost g.GlbServerCfg.MaxPortsPerClient = maxPortsPerClient + g.GlbServerCfg.ResponseHeaderTimeout = ResponseHeaderTimeout return } diff --git a/conf/frps_full.ini b/conf/frps_full.ini index 586b9677..192bf1bc 100644 --- a/conf/frps_full.ini +++ b/conf/frps_full.ini @@ -66,3 +66,6 @@ subdomain_host = frps.com # if tcp stream multiplexing is used, default is true tcp_mux = true + +# if Response Header Timeout more the 30s ,fix the pars . +ResponseHeaderTimeout = 30 \ No newline at end of file diff --git a/models/config/server_common.go b/models/config/server_common.go index 19e1a1d2..b0179c3a 100644 --- a/models/config/server_common.go +++ b/models/config/server_common.go @@ -68,40 +68,42 @@ type ServerCommonConf struct { SubDomainHost string `json:"subdomain_host"` TcpMux bool `json:"tcp_mux"` - AllowPorts map[int]struct{} - MaxPoolCount int64 `json:"max_pool_count"` - MaxPortsPerClient int64 `json:"max_ports_per_client"` - HeartBeatTimeout int64 `json:"heart_beat_timeout"` - UserConnTimeout int64 `json:"user_conn_timeout"` + AllowPorts map[int]struct{} + MaxPoolCount int64 `json:"max_pool_count"` + MaxPortsPerClient int64 `json:"max_ports_per_client"` + HeartBeatTimeout int64 `json:"heart_beat_timeout"` + UserConnTimeout int64 `json:"user_conn_timeout"` + ResponseHeaderTimeout int64 `json:"Response_Header_Timeout"` } func GetDefaultServerConf() *ServerCommonConf { return &ServerCommonConf{ - BindAddr: "0.0.0.0", - BindPort: 7000, - BindUdpPort: 0, - KcpBindPort: 0, - ProxyBindAddr: "0.0.0.0", - VhostHttpPort: 0, - VhostHttpsPort: 0, - DashboardAddr: "0.0.0.0", - DashboardPort: 0, - DashboardUser: "admin", - DashboardPwd: "admin", - AssetsDir: "", - LogFile: "console", - LogWay: "console", - LogLevel: "info", - LogMaxDays: 3, - Token: "", - AuthTimeout: 900, - SubDomainHost: "", - TcpMux: true, - AllowPorts: make(map[int]struct{}), - MaxPoolCount: 5, - MaxPortsPerClient: 0, - HeartBeatTimeout: 90, - UserConnTimeout: 10, + BindAddr: "0.0.0.0", + BindPort: 7000, + BindUdpPort: 0, + KcpBindPort: 0, + ProxyBindAddr: "0.0.0.0", + VhostHttpPort: 0, + VhostHttpsPort: 0, + DashboardAddr: "0.0.0.0", + DashboardPort: 0, + DashboardUser: "admin", + DashboardPwd: "admin", + AssetsDir: "", + LogFile: "console", + LogWay: "console", + LogLevel: "info", + LogMaxDays: 3, + Token: "", + AuthTimeout: 900, + SubDomainHost: "", + TcpMux: true, + AllowPorts: make(map[int]struct{}), + MaxPoolCount: 5, + MaxPortsPerClient: 0, + HeartBeatTimeout: 90, + UserConnTimeout: 10, + ResponseHeaderTimeout: 30, } } @@ -300,6 +302,15 @@ func UnmarshalServerConfFromIni(defaultCfg *ServerCommonConf, content string) (c cfg.HeartBeatTimeout = v } } + if tmpStr, ok = conf.Get("common", "Response_Header_Timeout"); ok { + v, errRet := strconv.ParseInt(tmpStr, 10, 64) + if errRet != nil { + err = fmt.Errorf("Parse conf error: Response_Header_Timeout is incorrect") + return + } else { + cfg.ResponseHeaderTimeout = v + } + } return } diff --git a/utils/vhost/newhttp.go b/utils/vhost/newhttp.go index 1351b222..42b96a5f 100644 --- a/utils/vhost/newhttp.go +++ b/utils/vhost/newhttp.go @@ -25,13 +25,14 @@ import ( "sync" "time" + "github.com/fatedier/frp/g" frpLog "github.com/fatedier/frp/utils/log" "github.com/fatedier/golib/pool" ) var ( - responseHeaderTimeout = time.Duration(30) * time.Second + responseHeaderTimeout = time.Duration(g.GlbServerCfg.ResponseHeaderTimeout) * time.Second ErrRouterConfigConflict = errors.New("router config conflict") ErrNoDomain = errors.New("no such domain")