From 477f18502aff5dbfd5ec5e4bcadbe13c535cc367 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 13 Nov 2020 11:44:44 +0800 Subject: [PATCH] 1 --- server/analyseapi/riskmgr.go | 32 +++++++++++++++++++++++++++++--- server/analyseapi/types.go | 2 ++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index 65b4cf4..88b1091 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -66,9 +66,28 @@ func (this* RiskMgr) Init() *RiskMgr { func (this* RiskMgr) UnInit() { } +func (this* RiskMgr) fetchGameConfList() []*GameConf { + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + + gameConfList := []*GameConf{} + for _, val := range this.gameHash { + gameConfList = append(gameConfList, val) + } + return gameConfList +} + func (this* RiskMgr) OutputLog() { - //f5.SysLog().Info("passobj %s", this.GetPassObj().ToJsonStr()) - //f5.SysLog().Info("blockobj %s", this.GetBlockObj().ToJsonStr()) + for _, val := range this.fetchGameConfList() { + f5.SysLog().Info("gameid:%d channel:%d passobj %s", + val.gameId, + val.channel, + val.GetPassObj().ToJsonStr()) + f5.SysLog().Info("gameid:%d channel:%d blockobj %s", + val.gameId, + val.channel, + val.GetBlockObj().ToJsonStr()) + } f5.SysLog().Info("global passobj %s", this.GetGlobalPassObj().ToJsonStr()) f5.SysLog().Info("global blockobj %s", this.GetGlobalBlockObj().ToJsonStr()) atomic.StoreInt64(&this.passTimes, 0) @@ -80,12 +99,19 @@ func (this* RiskMgr) OutputLog() { func (this* RiskMgr) GetGlobalPassObj() *q5.XObject { passObj := q5.NewMxoObject() - /// passObj.SetXValue("curr_white_ip_times", q5.NewXInt64(this.ipWhiteListPassTimes)) + passObj.SetXValue("total", q5.NewXInt64(this.totalPassTimes)) + passObj.SetXValue("curr", q5.NewXInt64(this.passTimes)) return passObj.AsXObject() } func (this* RiskMgr) GetGlobalBlockObj() *q5.XObject { blockObj := q5.NewMxoObject() + blockObj.SetXValue("total", q5.NewXInt64(this.totalBlockTimes)) + blockObj.SetXValue("curr", q5.NewXInt64(this.blockTimes)) + blockObj.SetXValue("total_methoderr", q5.NewXInt64(this.totalHttpMethodBlockTimes)) + blockObj.SetXValue("curr_methoderr", q5.NewXInt64(this.httpMethodBlockTimes)) + blockObj.SetXValue("total_sessonerr", q5.NewXInt64(this.totalSessionErrBlockTimes)) + blockObj.SetXValue("curr_sessionerr", q5.NewXInt64(this.sessionErrBlockTimes)) return blockObj.AsXObject() } diff --git a/server/analyseapi/types.go b/server/analyseapi/types.go index ffd5a87..3de111e 100644 --- a/server/analyseapi/types.go +++ b/server/analyseapi/types.go @@ -8,6 +8,8 @@ import ( ) type GameConf struct { + gameId int32 + channel int32 ipWhiteList map[string]int32 ipWhiteListMutex sync.RWMutex