From d885b747fa692fefd9a32e74d77f75962272ceb2 Mon Sep 17 00:00:00 2001 From: zu1k Date: Fri, 14 Aug 2020 08:11:07 +0800 Subject: [PATCH] add ss another link support --- proxy/shadowsocks.go | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/proxy/shadowsocks.go b/proxy/shadowsocks.go index c04c913..c5c793c 100644 --- a/proxy/shadowsocks.go +++ b/proxy/shadowsocks.go @@ -59,20 +59,35 @@ func ParseSSLink(link string) (*Shadowsocks, error) { return nil, ErrorNotSSLink } + cipher := "" + password := "" + if uri.User.String() == "" { + // base64的情况 + infos, err := tool.Base64DecodeString(uri.Hostname()) + if err != nil { + return nil, err + } + uri, err = url.Parse("ss://" + infos) + if err != nil { + return nil, err + } + cipher = uri.User.Username() + password, _ = uri.User.Password() + } else { + cipherInfoString, err := tool.Base64DecodeString(uri.User.Username()) + if err != nil { + return nil, ErrorPasswordParseFail + } + cipherInfo := strings.SplitN(cipherInfoString, ":", 2) + if len(cipherInfo) < 2 { + return nil, ErrorPasswordParseFail + } + cipher = strings.ToLower(cipherInfo[0]) + password = cipherInfo[1] + } server := uri.Hostname() port, _ := strconv.Atoi(uri.Port()) - cipherInfoString, err := tool.Base64DecodeString(uri.User.Username()) - if err != nil { - return nil, ErrorPasswordParseFail - } - cipherInfo := strings.SplitN(cipherInfoString, ":", 2) - if len(cipherInfo) < 2 { - return nil, ErrorPasswordParseFail - } - cipher := strings.ToLower(cipherInfo[0]) - password := cipherInfo[1] - moreInfos := uri.Query() pluginString := moreInfos.Get("plugin") plugin := ""