瀏覽代碼

add clean

zu1k 5 年之前
父節點
當前提交
db1a9f995e
共有 2 個文件被更改,包括 27 次插入4 次删除
  1. 10 4
      proxy/shadowsocksr.go
  2. 17 0
      tool/unicode.go

+ 10 - 4
proxy/shadowsocksr.go

@@ -112,8 +112,11 @@ func ParseSSRLink(link string) (*ShadowsocksR, error) {
 	if err != nil {
 		return nil, ErrorProtocolParamParseFail
 	}
-	if strings.HasSuffix(protocolParam, "_compatible") {
-		protocolParam = strings.ReplaceAll(protocolParam, "_compatible", "")
+	if tool.ContainChineseChar(protocolParam) {
+		protocolParam = ""
+	}
+	if strings.HasSuffix(protocol, "_compatible") {
+		protocol = strings.ReplaceAll(protocol, "_compatible", "")
 	}
 
 	// obfs param
@@ -121,8 +124,11 @@ func ParseSSRLink(link string) (*ShadowsocksR, error) {
 	if err != nil {
 		return nil, ErrorObfsParamParseFail
 	}
-	if strings.HasSuffix(obfsParam, "_compatible") {
-		obfsParam = strings.ReplaceAll(obfsParam, "_compatible", "")
+	if tool.ContainChineseChar(obfsParam) {
+		obfsParam = ""
+	}
+	if strings.HasSuffix(obfs, "_compatible") {
+		obfs = strings.ReplaceAll(obfs, "_compatible", "")
 	}
 
 	//group, err := tool.Base64DecodeString(moreInfo.Get("group"))

+ 17 - 0
tool/unicode.go

@@ -0,0 +1,17 @@
+package tool
+
+import (
+	"regexp"
+	"unicode"
+)
+
+var hanRe = regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]")
+
+func ContainChineseChar(str string) bool {
+	for _, r := range str {
+		if unicode.Is(unicode.Scripts["Han"], r) || (hanRe.MatchString(string(r))) {
+			return true
+		}
+	}
+	return false
+}