add clean

This commit is contained in:
zu1k
2020-08-12 08:54:25 +08:00
parent 1b07538777
commit db1a9f995e
2 changed files with 27 additions and 4 deletions

View File

@@ -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
tool/unicode.go Normal file
View File

@@ -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
}