fix: Converter Shadowsocks password parse

This commit is contained in:
gVisor bot 2023-02-01 08:50:26 +08:00
parent ebadcef8a5
commit d9d2ea41c0

View file

@ -2,6 +2,7 @@ package convert
import ( import (
"bytes" "bytes"
"encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/log"
@ -283,14 +284,17 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
) )
cipher = cipherRaw cipher = cipherRaw
if password, found = urlSS.User.Password(); !found { if password, found = urlSS.User.Password(); !found {
dcBuf, _ := enc.DecodeString(cipherRaw) dcBuf, err := base64.RawURLEncoding.DecodeString(cipherRaw)
if err != nil {
dcBuf, _ = enc.DecodeString(cipherRaw)
}
cipher, password, found = strings.Cut(string(dcBuf), ":") cipher, password, found = strings.Cut(string(dcBuf), ":")
if !found { if !found {
continue continue
} }
err := VerifyMethod(cipher, password) err = VerifyMethod(cipher, password)
if err != nil { if err != nil {
dcBuf, _ := encRaw.DecodeString(cipherRaw) dcBuf, _ = encRaw.DecodeString(cipherRaw)
cipher, password, found = strings.Cut(string(dcBuf), ":") cipher, password, found = strings.Cut(string(dcBuf), ":")
} }
} }