File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package convert
2
2
3
3
import (
4
4
"encoding/base64"
5
+ "fmt"
5
6
"strings"
6
7
)
7
8
@@ -43,3 +44,22 @@ func decodeUrlSafe(data string) string {
43
44
}
44
45
return string (dcBuf )
45
46
}
47
+
48
+ func TryDecodeBase64 (s string ) (decoded []byte , err error ) {
49
+ if len (s )% 4 == 0 {
50
+ if decoded , err = base64 .StdEncoding .DecodeString (s ); err == nil {
51
+ return
52
+ }
53
+ if decoded , err = base64 .URLEncoding .DecodeString (s ); err == nil {
54
+ return
55
+ }
56
+ } else {
57
+ if decoded , err = base64 .RawStdEncoding .DecodeString (s ); err == nil {
58
+ return
59
+ }
60
+ if decoded , err = base64 .RawURLEncoding .DecodeString (s ); err == nil {
61
+ return
62
+ }
63
+ }
64
+ return nil , fmt .Errorf ("invalid base64-encoded string" )
65
+ }
Original file line number Diff line number Diff line change @@ -456,12 +456,12 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
456
456
proxies = append (proxies , ss )
457
457
458
458
case "ssr" :
459
- dcBuf , err := encRaw . DecodeString (body )
459
+ dcBuf , err := TryDecodeBase64 (body )
460
460
if err != nil {
461
461
continue
462
462
}
463
463
464
- // ssr://host:port:protocol:method:obfs:urlsafebase64pass/?obfsparam=urlsafebase64 &protoparam=&remarks=urlsafebase64 &group=urlsafebase64 &udpport=0&uot=1
464
+ // ssr://host:port:protocol:method:obfs:urlsafebase64pass/?obfsparam=urlsafebase64param &protoparam=urlsafebase64param &remarks=urlsafebase64remarks &group=urlsafebase64group &udpport=0&uot=1
465
465
466
466
before , after , ok := strings .Cut (string (dcBuf ), "/?" )
467
467
if ! ok {
@@ -490,7 +490,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
490
490
name := uniqueName (names , remarks )
491
491
492
492
obfsParam := decodeUrlSafe (query .Get ("obfsparam" ))
493
- protocolParam := query .Get ("protoparam" )
493
+ protocolParam := decodeUrlSafe ( query .Get ("protoparam" ) )
494
494
495
495
ssr := make (map [string ]any , 20 )
496
496
You can’t perform that action at this time.
0 commit comments