mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
fix: up/down of hysteria must be a valid value
This commit is contained in:
parent
c968104a19
commit
ff4a5bef9b
|
@ -88,7 +88,15 @@ type HysteriaOption struct {
|
||||||
func (c *HysteriaOption) Speed() (uint64, uint64, error) {
|
func (c *HysteriaOption) Speed() (uint64, uint64, error) {
|
||||||
var up, down uint64
|
var up, down uint64
|
||||||
up = stringToBps(c.Up)
|
up = stringToBps(c.Up)
|
||||||
|
if up == 0 {
|
||||||
|
return 0, 0, fmt.Errorf("invaild upload speed: %s", c.Up)
|
||||||
|
}
|
||||||
|
|
||||||
down = stringToBps(c.Down)
|
down = stringToBps(c.Down)
|
||||||
|
if up == 0 {
|
||||||
|
return 0, 0, fmt.Errorf("invaild download speed: %s", c.Down)
|
||||||
|
}
|
||||||
|
|
||||||
return up, down, nil
|
return up, down, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +168,12 @@ func NewHysteria(option HysteriaOption) (*Hysteria, error) {
|
||||||
if len(option.Obfs) > 0 {
|
if len(option.Obfs) > 0 {
|
||||||
obfuscator = obfs.NewXPlusObfuscator([]byte(option.Obfs))
|
obfuscator = obfs.NewXPlusObfuscator([]byte(option.Obfs))
|
||||||
}
|
}
|
||||||
up, down, _ := option.Speed()
|
|
||||||
|
up, down, err := option.Speed()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
client, err := core.NewClient(
|
client, err := core.NewClient(
|
||||||
addr, option.Protocol, auth, tlsConfig, quicConfig, clientTransport, up, down, func(refBPS uint64) congestion.CongestionControl {
|
addr, option.Protocol, auth, tlsConfig, quicConfig, clientTransport, up, down, func(refBPS uint64) congestion.CongestionControl {
|
||||||
return hyCongestion.NewBrutalSender(congestion.ByteCount(refBPS))
|
return hyCongestion.NewBrutalSender(congestion.ByteCount(refBPS))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user