This commit is contained in:
aozhiwei 2020-10-30 17:29:39 +08:00
parent 6e48eaf266
commit ab94a70edd

View File

@ -98,12 +98,34 @@ func (this* RiskMgr) Init() *RiskMgr {
G.HttpServer.RegisterHandle("Analyse", "isOpen", this.__analyseIsOpen)
G.HttpServer.RegisterHandle("Ops", "dump", this.__opsDump)
G.HttpServer.RegisterHandle("Ops", "syncConf", this.__opsSyncConf)
G.HttpServer.RegisterHandle("Ops", "info", this.__opsInfo)
f5.Timer().AddRepeatTimer(1000 * 60,
func (params* q5.XParams) {
},
func (params* q5.XParams) {
this.OutputLog()
})
return this
}
func (this* RiskMgr) UnInit() {
}
func (this* RiskMgr) OutputLog() {
f5.SysLog().Info("passobj %s", this.GetPassObj().ToJsonStr())
f5.SysLog().Info("blockobj %s", this.GetBlockObj().ToJsonStr())
this.passTimes = 0
this.blockTimes = 0
this.ipWhiteListPassTimes = 0
this.launchWhiteListPassTimes = 0
this.safeZonePassTimes = 0
this.httpMethodBlockTimes = 0
this.sessionErrBlockTimes = 0
this.ipBlackListBlockTimes = 0
this.launchBlackListBlockTimes = 0
this.unSafeZoneBlockTimes = 0
}
func (this* RiskMgr) InIpWhiteList(ip string) bool {
this.ipWhiteListMutex.Lock()
defer this.ipWhiteListMutex.Unlock()
@ -162,6 +184,36 @@ func (this* RiskMgr) GetSdkInfo(accessKeyId* string, accessSecret* string) {
*accessSecret = "" + this.accessSecret
}
func (this* RiskMgr) GetPassObj() *q5.XObject {
passObj := q5.NewMxoObject()
passObj.SetXValue("total_times", q5.NewXInt64(this.totalPassTimes))
passObj.SetXValue("curr_times", q5.NewXInt64(this.passTimes))
passObj.SetXValue("total_white_ip_times", q5.NewXInt64(this.totalIpWhiteListPassTimes))
passObj.SetXValue("curr_white_ip_times", q5.NewXInt64(this.ipWhiteListPassTimes))
passObj.SetXValue("total_white_launch_times", q5.NewXInt64(this.totalLaunchWhiteListPassTimes))
passObj.SetXValue("curr_white_launch_times", q5.NewXInt64(this.launchWhiteListPassTimes))
passObj.SetXValue("total_safezone_times", q5.NewXInt64(this.totalSafeZonePassTimes))
passObj.SetXValue("curr_safezone_times", q5.NewXInt64(this.safeZonePassTimes))
return passObj.AsXObject()
}
func (this* RiskMgr) GetBlockObj() *q5.XObject {
blockObj := q5.NewMxoObject()
blockObj.SetXValue("total_times", q5.NewXInt64(this.totalBlockTimes))
blockObj.SetXValue("curr_times", q5.NewXInt64(this.blockTimes))
blockObj.SetXValue("total_method_err_times", q5.NewXInt64(this.totalHttpMethodBlockTimes))
blockObj.SetXValue("curr_method_err_times", q5.NewXInt64(this.httpMethodBlockTimes))
blockObj.SetXValue("total_session_err_times", q5.NewXInt64(this.totalSessionErrBlockTimes))
blockObj.SetXValue("curr_session_err_times", q5.NewXInt64(this.sessionErrBlockTimes))
blockObj.SetXValue("total_black_ip_times", q5.NewXInt64(this.totalIpBlackListBlockTimes))
blockObj.SetXValue("curr_black_ip_times", q5.NewXInt64(this.ipBlackListBlockTimes))
blockObj.SetXValue("total_black_launch_times", q5.NewXInt64(this.totalLaunchBlackListBlockTimes))
blockObj.SetXValue("curr_black_launch_times", q5.NewXInt64(this.launchBlackListBlockTimes))
blockObj.SetXValue("total_unsafezone_times", q5.NewXInt64(this.totalUnSafeZoneBlockTimes))
blockObj.SetXValue("curr_unsafezone_times", q5.NewXInt64(this.unSafeZoneBlockTimes))
return blockObj.AsXObject()
}
func (this* RiskMgr) IsSafeZone(gameId int32, channel int32, ip string) bool {
accessKeyId := ""
accessSecret := ""
@ -281,3 +333,12 @@ func (this *RiskMgr) __opsDump(w* http.ResponseWriter, r *http.Request) {
func (this *RiskMgr) __opsSyncConf(w* http.ResponseWriter, r *http.Request) {
q5.ResponseOk(w)
}
func (this *RiskMgr) __opsInfo(w* http.ResponseWriter, r *http.Request) {
respObj := q5.NewMxoObject()
respObj.SetXValue("errcode", q5.NewXInt32(0))
respObj.SetXValue("errcode", q5.NewXString(""))
respObj.SetXObject("pass", this.GetPassObj())
respObj.SetXObject("block", this.GetBlockObj())
q5.Response(w, respObj.ToJsonStr())
}