From c1189015ad1ea19ded24ca7c45530bbd80cc7627 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 27 Nov 2022 12:52:14 +0800 Subject: [PATCH] fix: ports of hysteria is optional --- adapter/outbound/hysteria.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapter/outbound/hysteria.go b/adapter/outbound/hysteria.go index fd441dc1..e6c2b25d 100644 --- a/adapter/outbound/hysteria.go +++ b/adapter/outbound/hysteria.go @@ -91,7 +91,7 @@ type HysteriaOption struct { Name string `proxy:"name"` Server string `proxy:"server"` Port int `proxy:"port"` - Ports string `proxy:"ports"` + Ports string `proxy:"ports,omitempty"` Protocol string `proxy:"protocol,omitempty"` ObfsProtocol string `proxy:"obfs-protocol,omitempty"` // compatible with Stash Up string `proxy:"up"` @@ -137,7 +137,7 @@ func NewHysteria(option HysteriaOption) (*Hysteria, error) { }, } var addr string - if option.Ports == "" { + if len(option.Ports) == 0 { addr = net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) } else { addr = net.JoinHostPort(option.Server, option.Ports)