mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-03 03:35:04 +03:00
fix(link): accept padded URL-safe base64 in vmess links (#6975)
parseVmess tried standard base64, then unpadded URL-safe base64, so a URL-safe body that kept its = padding failed both and the server silently dropped out of an imported outbound subscription. It now uses base64DecodeFlexible, the helper the shadowsocks parser already uses.
This commit is contained in:
@@ -208,17 +208,13 @@ func dropHostLocalKeys(v any) {
|
||||
|
||||
func parseVmess(link string) (*ParseResult, error) {
|
||||
b64 := strings.TrimPrefix(link, "vmess://")
|
||||
// vmess:// base64(json)
|
||||
raw, err := base64.StdEncoding.DecodeString(padBase64(b64))
|
||||
if err != nil {
|
||||
// Some providers use raw URL-safe
|
||||
raw, err = base64.RawURLEncoding.DecodeString(b64)
|
||||
}
|
||||
// vmess:// base64(json), standard or URL-safe, padded or not
|
||||
raw, err := base64DecodeFlexible(b64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("vmess decode: %w", err)
|
||||
}
|
||||
var j map[string]any
|
||||
if err := json.Unmarshal(raw, &j); err != nil {
|
||||
if err := json.Unmarshal([]byte(raw), &j); err != nil {
|
||||
return nil, fmt.Errorf("vmess json: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user