Merge pull request #151 from H1JK/update-converter2

fix: Converter error when VMess `aid` field not exists
This commit is contained in:
MetaCubeX 2022-08-07 20:47:32 +08:00 committed by GitHub
commit 50cc274b2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,10 @@ import (
"strings" "strings"
) )
var encRaw = base64.RawStdEncoding var (
var enc = base64.StdEncoding encRaw = base64.RawStdEncoding
enc = base64.StdEncoding
)
func DecodeBase64(buf []byte) []byte { func DecodeBase64(buf []byte) []byte {
dBuf := make([]byte, encRaw.DecodedLen(len(buf))) dBuf := make([]byte, encRaw.DecodedLen(len(buf)))
@ -149,7 +151,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
vless["skip-cert-verify"] = false vless["skip-cert-verify"] = false
vless["tls"] = false vless["tls"] = false
tls := strings.ToLower(query.Get("security")) tls := strings.ToLower(query.Get("security"))
if strings.Contains(tls, "tls") { if strings.HasSuffix(tls, "tls") {
vless["tls"] = true vless["tls"] = true
} }
sni := query.Get("sni") sni := query.Get("sni")
@ -244,7 +246,11 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
vmess["server"] = values["add"] vmess["server"] = values["add"]
vmess["port"] = values["port"] vmess["port"] = values["port"]
vmess["uuid"] = values["id"] vmess["uuid"] = values["id"]
vmess["alterId"] = values["aid"] if alterId, ok := values["aid"]; ok {
vmess["alterId"] = alterId
} else {
vmess["alterId"] = 0
}
vmess["cipher"] = "auto" vmess["cipher"] = "auto"
vmess["udp"] = true vmess["udp"] = true
vmess["tls"] = false vmess["tls"] = false