mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user