屏蔽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

+2 -34
View File
@@ -11,11 +11,10 @@ import (
"net/http"
"net/url"
"os"
"regexp"
"strconv"
"hk4e/common/config"
"hk4e/common/mq"
"hk4e/common/region"
httpapi "hk4e/dispatch/api"
"hk4e/node/api"
"hk4e/pkg/endec"
@@ -187,7 +186,7 @@ func (c *Controller) queryCurRegion(ctx *gin.Context) {
c.dispatchReqErrorRsp(ctx, 2)
return
}
version, versionStr := c.getClientVersionByName(versionName)
version, versionStr := region.GetClientVersionByName(versionName)
if version == 0 {
c.dispatchReqErrorRsp(ctx, 2)
return
@@ -307,37 +306,6 @@ func (c *Controller) queryCurRegion(ctx *gin.Context) {
ctx.JSON(http.StatusOK, rsp)
}
// 从客户端版本字符串中提取版本号
func (c *Controller) 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)
}
func (c *Controller) querySecurityFile(ctx *gin.Context) {
// 很早以前2.6.0版本的时候抓包为了完美还原写的 不清楚有没有副作用暂时不要了
return