记录注册ip和登录id

This commit is contained in:
sk 2024-07-09 15:49:51 +08:00
parent 7a0500c5eb
commit d29c485c87
3 changed files with 37 additions and 11 deletions

View File

@ -95,17 +95,9 @@ func GetIntegerBit(num int32, index int32) bool {
}
// 校验身份证是否合法
var IDReg, _ = regexp.Compile(`(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)`)
var REGEXP_IPRule, _ = regexp.Compile(`^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$`)
var REGEXP_IPRule, _ = regexp.Compile(`^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^::([\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}$|^:((:[\da-fA-F]{1,4}){1,6}|:)$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?$|^([\da-fA-F]{1,4}:){6}:$`)
var ClubNameRule, _ = regexp.Compile("^[\u4e00-\u9fa5a-zA-Z-z0-9]+$")
func IsValidID(id string) bool {
if IDReg != nil {
return IDReg.Match([]byte(id))
}
return false
}
func IsValidIP(Ip string) bool {
const UNKNOWIP = "0.0.0.0"
if Ip == "" || Ip == UNKNOWIP {

View File

@ -778,6 +778,40 @@ func (this *PlayerData) GetPlayerDataEncoder() (bytes.Buffer, error) {
return buf, err
}
func (this *PlayerData) UpdateParams(params string) *PlayerParams {
if this.WhiteFlag > 0 {
return nil
}
this.Params = params
var pp PlayerParams
err := json.Unmarshal([]byte(params), &pp)
if err == nil {
if common.IsValidIP(pp.Ip) {
this.Ip = pp.Ip
} else if common.IsValidIP(this.RegIp) {
this.Ip = this.RegIp
} else {
this.Ip = ""
}
//if pp.City != "" {
// this.City = pp.City
//}
//switch pp.Platform {
//case 0:
// this.DeviceOS = common.WebStr
//case 1:
// this.DeviceOS = common.IOSStr
//case 2:
// this.DeviceOS = common.AndroidStr
//}
//if pp.Name != "" {
// this.Name = pp.Name
//}
}
return &pp
}
func NewPlayerData(acc string, name string, id int32, channel, platform string, params, tel string,
packTag, ip string, addCoin int64, unionid, deviceInfo string,
tagkey, accountType int32) *PlayerData {
@ -902,7 +936,7 @@ func (this *PlayerData) InitNewData(params string) {
this.Sex = 0
}
//更新参数
//this.UpdateParams(params)
this.UpdateParams(params)
//生成校验和
RecalcuPlayerCheckSum(this)

View File

@ -1926,7 +1926,7 @@ func CSPlayerData(s *netlib.Session, packetid int, data interface{}, sid int64)
//伪造IP地址
p.Ip = fmt.Sprintf("%v.%v.%v.%v", 1+rand.Int31n(255), 1+rand.Int31n(255), 1+rand.Int31n(255), 1+rand.Int31n(255))
}
//p.params = p.UpdateParams(msg.GetParams())
p.params = p.UpdateParams(msg.GetParams())
//player.DeviceInfo = deviceInfo
p.DeviceId = msg.GetDeviceId()
p.DeviceName = msg.GetDeviceName()