Hysteria transport: Support range & random for interval in udphop as well (#5603)

https://github.com/XTLS/Xray-core/pull/5560#issuecomment-3794621260
This commit is contained in:
LjhAUMEM
2026-01-26 02:28:51 +08:00
committed by GitHub
parent 5173e5c15d
commit f1aee0b7c5
5 changed files with 75 additions and 51 deletions

View File

@@ -387,7 +387,7 @@ func (b Bandwidth) Bps() (uint64, error) {
type UdpHop struct {
PortList json.RawMessage `json:"port"`
Interval int64 `json:"interval"`
Interval *Int32Range `json:"interval"`
}
type HysteriaConfig struct {
@@ -431,13 +431,19 @@ func (c *HysteriaConfig) Build() (proto.Message, error) {
hop = &PortList{}
}
var inertvalMin, inertvalMax int64
if c.UdpHop.Interval != nil {
inertvalMin = int64(c.UdpHop.Interval.From)
inertvalMax = int64(c.UdpHop.Interval.To)
}
if up > 0 && up < 65536 {
return nil, errors.New("Up must be at least 65536 Bps")
}
if down > 0 && down < 65536 {
return nil, errors.New("Down must be at least 65536 Bps")
}
if c.UdpHop.Interval != 0 && c.UdpHop.Interval < 5 {
if (inertvalMin != 0 && inertvalMin < 5) || (inertvalMax != 0 && inertvalMax < 5) {
return nil, errors.New("Interval must be at least 5")
}
@@ -467,7 +473,8 @@ func (c *HysteriaConfig) Build() (proto.Message, error) {
config.Up = up
config.Down = down
config.Ports = hop.Build().Ports()
config.Interval = c.UdpHop.Interval
config.IntervalMin = inertvalMin
config.IntervalMax = inertvalMax
config.InitStreamReceiveWindow = c.InitStreamReceiveWindow
config.MaxStreamReceiveWindow = c.MaxStreamReceiveWindow
config.InitConnReceiveWindow = c.InitConnectionReceiveWindow