From 4a4e11896c23a6b61b7ad596e06cf1d4042ea027 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 7 Jan 2021 15:28:31 +0800 Subject: [PATCH] 1 --- server/analyseapi/riskmgr.go | 47 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index fa7c540..a446341 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -248,20 +248,45 @@ func (this *RiskMgr) _opsSyncConf(c *f5.Context) { } func (this *RiskMgr) _opsInfo(c *f5.Context) { - gameId := c.Request("gameid").GetInt32() - channel := c.Request("channel").GetInt32() - gameConf := this.GetGameConf(gameId, channel) - if gameConf == nil { - c.ResponseErr(1, "数据不存在") - return - } - gameConf.Active() + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + respObj := q5.NewMxoObject() respObj.SetXValue("errcode", q5.NewXInt32(0)) respObj.SetXValue("errmsg", q5.NewXString("")) - respObj.SetXObject("conf", gameConf.GetConfObj()) - respObj.SetXObject("pass", gameConf.GetPassObj()) - respObj.SetXObject("block", gameConf.GetBlockObj()) + { + passObj := q5.NewMxoObject() + passObj.SetXValue("total", q5.NewXInt64(this.totalPassTimes)) + respObj.SetXValue("curr", q5.NewXInt64(this.passTimes)) + respObj.SetXValue("total_ip_whitelist", q5.NewXInt64(this.totalIpWhiteListPassTimes)) + respObj.SetXValue("curr_ip_whitelist", q5.NewXInt64(this.ipWhiteListPassTimes)) + respObj.SetXObject("pass", passObj.AsXObject()) + } + { + blockObj := q5.NewMxoObject() + respObj.SetXValue("total", q5.NewXInt64(this.totalBlockTimes)) + respObj.SetXValue("curr", q5.NewXInt64(this.blockTimes)) + respObj.SetXValue("total_ip_blacklist", q5.NewXInt64(this.totalIpBlackListBlockTimes)) + respObj.SetXValue("curr_ip_blacklist", q5.NewXInt64(this.ipBlackListBlockTimes)) + respObj.SetXValue("total_http_method", q5.NewXInt64(this.totalHttpMethodBlockTimes)) + respObj.SetXValue("http_method", q5.NewXInt64(this.httpMethodBlockTimes)) + + respObj.SetXObject("block", blockObj.AsXObject()) + } + respObj.SetXValue("errcode", q5.NewXInt64(this.totalSessionErrBlockTimes)) + respObj.SetXValue("errcode", q5.NewXInt64(this.totalSessionErrBlockTimes)) + gameList := q5.NewMxoArray() + for _, gameConf := range this.fetchGameConfList() { + gameConf.Active() + gameObj := q5.NewMxoObject() + gameObj.SetXValue("gameid", q5.NewXInt32(gameConf.gameId)) + gameObj.SetXValue("channel", q5.NewXInt32(gameConf.channel)) + gameObj.SetXObject("conf", gameConf.GetConfObj()) + gameObj.SetXObject("pass", gameConf.GetPassObj()) + gameObj.SetXObject("block", gameConf.GetBlockObj()) + gameList.PushXObject(gameObj.AsXObject()) + } + respObj.SetXObject("games", gameList.AsXObject()) c.Response(respObj.ToJsonStr()) }