feat(rpc): 设置默认RPC地址为本地回环

修复RPC客户端连接问题,将默认服务器地址设置为127.0.0.1以确保本地连接正常

refactor(qqwry): 优化IP地址查询功能

移除不必要的正则表达式依赖,重构IP地址查询逻辑,提高代码性能和可维护性

fix(server): 保存确定的端口到配置中

确保服务器端口在确定后正确保存到配置中,避免端口配置丢失
This commit is contained in:
2026-01-08 05:15:10 +08:00
parent 56fe334045
commit 4d0464c76b
8 changed files with 116 additions and 164 deletions

View File

@@ -2,6 +2,7 @@ package service
import (
"blazing/cool"
"fmt"
"sync"
"blazing/modules/base/model"
@@ -33,22 +34,38 @@ func NewBaseSysLogService() *BaseSysLogService {
},
},
ModifyResult: func(ctx g.Ctx, data interface{}) interface{} {
// baseSysLog.IPAddr = fmt.Sprintf("国家:%s省份%s城市%s区县%s运营商%s\n",
// location.Country,
// location.Province,
// location.City,
// location.District,
// location.ISP,
// )
var rr []g.MapStrAny
r, _ := gconv.Map(data)["list"].(gdb.Result)
for _, v := range r {
ipaddr, err := qqwry.QueryIP(v.Map()["ip"].(string))
for i := 0; i < len(r); i++ {
subm := r[i].GMap()
ipaddr, err := qqwry.QueryIP(r[i].Map()["ip"].(string))
if err == nil {
v.GMap().Set("ipAddr", ipaddr)
// baseSysLog.IPAddr = fmt.Sprintf("国家:%s省份%s城市%s区县%s运营商%s\n",
// location.Country,
// location.Province,
// location.City,
// location.District,
// location.ISP,
// )
subm.Set("ipAddr", fmt.Sprintf("国家:%s省份%s城市%s区县%s运营商%s\n",
ipaddr.Country,
ipaddr.Province,
ipaddr.City,
ipaddr.District,
ipaddr.ISP,
))
}
rr = append(rr, subm.MapStrAny())
}
data.(map[string]interface{})["list"] = rr
return data
},
},
},

View File

@@ -38,7 +38,7 @@ func (s *ItemService) UPDATE(id uint32, count int) {
"item_id": id,
"item_cnt": count,
}
data = cool.SetTest(data)
//data = cool.SetTest(data)
m.Data(data).Insert()
}

View File

@@ -12,6 +12,8 @@ const TableNameServerList = "server_list"
type ServerList struct {
*cool.Model
coolconfig.ServerList
//isonline
IsOnline uint8 `gorm:"column:isonline;default:0;comment:'是否在线'" json:"isonline"`
}
// TableName ServerList's table name

View File

@@ -29,24 +29,29 @@ func NewServerService() *ServerService {
Model: model.NewServerList(),
PageQueryOp: &cool.QueryOp{
ModifyResult: func(ctx g.Ctx, data interface{}) interface{} {
var rr []g.MapStrAny
r, _ := gconv.Map(data)["list"].(gdb.Result)
for _, v := range r {
t, ok := cool.GetClient(gconv.Uint16(v.Map()["port"]))
for i := 0; i < len(r); i++ {
t, ok := cool.GetClient(gconv.Uint16(r[i].Map()["port"]))
// tt.Friends = v.Friends
subm := r[i].GMap()
if ok {
cool.Logger.Info(context.TODO(), "服务器假踢人")
err := t.KickPerson(0) //实现指定服务器踢人
if err == nil {
// tt.Friends = v.Friends
v.GMap().Set("isonline", 1)
subm.Set("isonline", 1)
}
}
rr = append(rr, subm.MapStrAny())
}
data.(map[string]interface{})["list"] = rr
return data
},
},