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