屏蔽ai世界不同版本客户端ability消息转发

This commit is contained in:
flswld committed 2023-10-11 19:30:56 +08:00
1 parent cc2137c087
commit 3d8c2903be
18 files changed
+239 -215

No files matched your search

+33
View File
@@ -2,6 +2,8 @@ package region
import (
"os"
"regexp"
"strconv"
"hk4e/pkg/logger"
)
@@ -29,3 +31,34 @@ func LoadRegionRsaKey() (signRsaKey []byte, encRsaKeyMap map[string][]byte, pwdR
}
return signRsaKey, encRsaKeyMap, pwdRsaKey
}
// GetClientVersionByName 从客户端版本字符串中提取版本号
func GetClientVersionByName(versionName string) (int, string) {
reg, err := regexp.Compile("[0-9]+")
if err != nil {
logger.Error("compile regexp error: %v", err)
return 0, ""
}
versionSlice := reg.FindAllString(versionName, -1)
version := 0
for index, value := range versionSlice {
v, err := strconv.Atoi(value)
if err != nil {
logger.Error("parse client version error: %v", err)
return 0, ""
}
if v >= 10 {
// 测试版本
if index != 2 {
logger.Error("invalid client version")
return 0, ""
}
v /= 10
}
for i := 0; i < 2-index; i++ {
v *= 10
}
version += v
}
return version, strconv.Itoa(version)
}