mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-07-05 10:49:51 +00:00
feat: disable keep alive on server (should be client's responsibility only) & use a default idle timeout of 60 seconds
This commit is contained in:
parent
c018eb11a9
commit
7126425499
@ -80,8 +80,8 @@ func client(config *clientConfig) {
|
||||
EnableDatagrams: true,
|
||||
}
|
||||
if config.IdleTimeout == 0 {
|
||||
quicConfig.MaxIdleTimeout = DefaultMaxIdleTimeout
|
||||
quicConfig.KeepAlivePeriod = DefaultKeepAlivePeriod
|
||||
quicConfig.MaxIdleTimeout = DefaultClientMaxIdleTimeout
|
||||
quicConfig.KeepAlivePeriod = DefaultClientKeepAlivePeriod
|
||||
} else {
|
||||
quicConfig.MaxIdleTimeout = time.Duration(config.IdleTimeout) * time.Second
|
||||
quicConfig.KeepAlivePeriod = quicConfig.MaxIdleTimeout * 2 / 5
|
||||
|
@ -23,8 +23,9 @@ const (
|
||||
|
||||
DefaultMMDBFilename = "GeoLite2-Country.mmdb"
|
||||
|
||||
DefaultMaxIdleTimeout = 20 * time.Second
|
||||
DefaultKeepAlivePeriod = 8 * time.Second
|
||||
ServerMaxIdleTimeout = 60 * time.Second
|
||||
DefaultClientMaxIdleTimeout = 20 * time.Second
|
||||
DefaultClientKeepAlivePeriod = 8 * time.Second
|
||||
)
|
||||
|
||||
var rateStringRegexp = regexp.MustCompile(`^(\d+)\s*([KMGT]?)([Bb])ps$`)
|
||||
@ -43,16 +44,15 @@ type serverConfig struct {
|
||||
CertFile string `json:"cert"`
|
||||
KeyFile string `json:"key"`
|
||||
// Optional below
|
||||
Up string `json:"up"`
|
||||
UpMbps int `json:"up_mbps"`
|
||||
Down string `json:"down"`
|
||||
DownMbps int `json:"down_mbps"`
|
||||
IdleTimeout int `json:"idle_timeout"`
|
||||
DisableUDP bool `json:"disable_udp"`
|
||||
ACL string `json:"acl"`
|
||||
MMDB string `json:"mmdb"`
|
||||
Obfs string `json:"obfs"`
|
||||
Auth struct {
|
||||
Up string `json:"up"`
|
||||
UpMbps int `json:"up_mbps"`
|
||||
Down string `json:"down"`
|
||||
DownMbps int `json:"down_mbps"`
|
||||
DisableUDP bool `json:"disable_udp"`
|
||||
ACL string `json:"acl"`
|
||||
MMDB string `json:"mmdb"`
|
||||
Obfs string `json:"obfs"`
|
||||
Auth struct {
|
||||
Mode string `json:"mode"`
|
||||
Config json5.RawMessage `json:"config"`
|
||||
} `json:"auth"`
|
||||
@ -106,9 +106,6 @@ func (c *serverConfig) Check() error {
|
||||
if up, down, err := c.Speed(); err != nil || (up != 0 && up < minSpeedBPS) || (down != 0 && down < minSpeedBPS) {
|
||||
return errors.New("invalid speed")
|
||||
}
|
||||
if c.IdleTimeout != 0 && c.IdleTimeout < 4 {
|
||||
return errors.New("invalid idle timeout")
|
||||
}
|
||||
if (c.ReceiveWindowConn != 0 && c.ReceiveWindowConn < 65536) ||
|
||||
(c.ReceiveWindowClient != 0 && c.ReceiveWindowClient < 65536) {
|
||||
return errors.New("invalid receive window size")
|
||||
|
@ -77,16 +77,11 @@ func server(config *serverConfig) {
|
||||
InitialConnectionReceiveWindow: config.ReceiveWindowClient,
|
||||
MaxConnectionReceiveWindow: config.ReceiveWindowClient,
|
||||
MaxIncomingStreams: int64(config.MaxConnClient),
|
||||
MaxIdleTimeout: ServerMaxIdleTimeout,
|
||||
KeepAlivePeriod: 0, // Keep alive should solely be client's responsibility
|
||||
DisablePathMTUDiscovery: config.DisableMTUDiscovery,
|
||||
EnableDatagrams: true,
|
||||
}
|
||||
if config.IdleTimeout == 0 {
|
||||
quicConfig.MaxIdleTimeout = DefaultMaxIdleTimeout
|
||||
quicConfig.KeepAlivePeriod = DefaultKeepAlivePeriod
|
||||
} else {
|
||||
quicConfig.MaxIdleTimeout = time.Duration(config.IdleTimeout) * time.Second
|
||||
quicConfig.KeepAlivePeriod = quicConfig.MaxIdleTimeout * 2 / 5
|
||||
}
|
||||
if config.ReceiveWindowConn == 0 {
|
||||
quicConfig.InitialStreamReceiveWindow = DefaultStreamReceiveWindow
|
||||
quicConfig.MaxStreamReceiveWindow = DefaultStreamReceiveWindow
|
||||
|
Loading…
x
Reference in New Issue
Block a user