From a03df5233f817a9885790d4899cd1273875b4cfe Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 7 Jun 2022 15:24:46 +0800 Subject: [PATCH] fix: hysteria parse auth --- adapter/outbound/hysteria.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/adapter/outbound/hysteria.go b/adapter/outbound/hysteria.go index ed580e1b..b8f69d2d 100644 --- a/adapter/outbound/hysteria.go +++ b/adapter/outbound/hysteria.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "encoding/base64" "errors" "fmt" "io/ioutil" @@ -71,7 +72,7 @@ type HysteriaOption struct { UpMbps int `proxy:"up_mbps,omitempty"` Down string `proxy:"down,omitempty"` DownMbps int `proxy:"down_mbps,omitempty"` - Auth []byte `proxy:"auth,omitempty"` + Auth string `proxy:"auth,omitempty"` AuthString string `proxy:"auth_str,omitempty"` Obfs string `proxy:"obfs,omitempty"` SNI string `proxy:"sni,omitempty"` @@ -163,8 +164,12 @@ func NewHysteria(option HysteriaOption) (*Hysteria, error) { log.Infoln("hysteria: Path MTU Discovery is not yet supported on this platform") } var auth []byte - if len(option.Auth) > 0 { - auth = option.Auth + if option.Auth != "" { + authBytes, err := base64.StdEncoding.DecodeString(option.Auth) + if err != nil { + return nil, fmt.Errorf("hysteria %s parse auth error: %w", addr, err) + } + auth = authBytes } else { auth = []byte(option.AuthString) }