From b9b0a4a199020fc327fc4e7853c34e327a74ace0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 12 Nov 2020 17:36:56 +0800 Subject: [PATCH] 1 --- server/analyseapi/riskmgr.go | 53 ++++++++---------------------------- server/analyseapi/types.go | 34 +++++++++++++++++++++++ third_party/q5 | 2 +- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index 6b76af1..601af2c 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -36,12 +36,11 @@ type RiskMgr struct { func (this* RiskMgr) Init() *RiskMgr { this.fixedBlockProvinceCityHashMutex.Lock() defer this.fixedBlockProvinceCityHashMutex.Unlock() - this.fixedBlockProvinceCityHash = make(map[string]int32) - for _, val := range G.MetaMgr.GetFixedBlockProvinceCity().GetList() { this.fixedBlockProvinceCityHash[val] = 1 } + this.accessKeyId = G.MetaMgr.GetAliKey().GetAccessKeyid() this.accessSecret = G.MetaMgr.GetAliKey().GetAccessSecret() this.clusterConf = G.MetaMgr.GetCurrServer() @@ -68,14 +67,6 @@ func (this* RiskMgr) OutputLog() { f5.SysLog().Info("blockobj %s", this.GetBlockObj().ToJsonStr()) atomic.StoreInt64(&this.passTimes, 0) atomic.StoreInt64(&this.blockTimes, 0) - /*atomic.StoreInt64(&this.ipWhiteListPassTimes, 0) - atomic.StoreInt64(&this.launchWhiteListPassTimes, 0) - atomic.StoreInt64(&this.safeZonePassTimes, 0) - atomic.StoreInt64(&this.httpMethodBlockTimes, 0) - atomic.StoreInt64(&this.sessionErrBlockTimes, 0) - atomic.StoreInt64(&this.ipBlackListBlockTimes, 0) - atomic.StoreInt64(&this.launchBlackListBlockTimes, 0) - atomic.StoreInt64(&this.unSafeZoneBlockTimes, 0)*/ } func (this* RiskMgr) GetSdkInfo(accessKeyId* string, accessSecret* string) { @@ -119,6 +110,10 @@ func (this *RiskMgr) GetGameConf(gameId int32, channel int32) *GameConf { return nil } +func (this *RiskMgr) GetGameConfEx(gameId int32, channel int32) *GameConf { + return nil +} + func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { var gameConf *GameConf responseStr := "" @@ -182,38 +177,14 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { } func (this *RiskMgr) __opsDump(w* http.ResponseWriter, r *http.Request) { - /*this.ipWhiteListMutex.Lock() - this.ipBlackListMutex.Lock() - this.launchWhiteListMutex.Lock() - this.launchBlackListMutex.Lock() - this.blockProvinceCityHashMutex.Lock() - this.fixedBlockProvinceCityHashMutex.Lock() - defer this.ipWhiteListMutex.Unlock() - defer this.ipBlackListMutex.Unlock() - defer this.launchWhiteListMutex.Unlock() - defer this.launchBlackListMutex.Unlock() - defer this.blockProvinceCityHashMutex.Unlock() - defer this.fixedBlockProvinceCityHashMutex.Unlock() - - fillRespObj := func(respObj* q5.MutableXObject, attrName string, mapObj* map[string]int32) { - list := q5.NewMxoArray() - for key, _ := range *mapObj { - list.PushXValue(q5.NewXString(key)) - } - respObj.SetXObject(attrName, list.AsXObject()) + gameId := q5.Request(r, "gameid").GetInt32() + channel := q5.Request(r, "channel").GetInt32() + gameConf := this.GetGameConf(gameId, channel) + if gameConf == nil { + q5.ResponseErr(w, 1, "数据不存在") + return } - - respObj := q5.NewMxoObject() - respObj.SetXValue("errcode", q5.NewXInt32(0)) - respObj.SetXValue("errmsg", q5.NewXString("")) - fillRespObj(respObj, "ip_white_list", &this.ipWhiteList) - fillRespObj(respObj, "ip_black_list", &this.ipBlackList) - fillRespObj(respObj, "launch_white_list", &this.launchWhiteList) - fillRespObj(respObj, "launch_black_list", &this.launchBlackList) - fillRespObj(respObj, "block_province_city_list", &this.blockProvinceCityHash) - fillRespObj(respObj, "fixed_block_province_city_list", &this.fixedBlockProvinceCityHash) - q5.Response(w, respObj.ToJsonStr()) -*/ + q5.Response(w, gameConf.Dump().ToJsonStr()) } func (this *RiskMgr) __opsSyncConf(w* http.ResponseWriter, r *http.Request) { diff --git a/server/analyseapi/types.go b/server/analyseapi/types.go index 719a291..0f000bf 100644 --- a/server/analyseapi/types.go +++ b/server/analyseapi/types.go @@ -194,3 +194,37 @@ func (this* GameConf) IsSafeZone(ip string, response_str* string) bool { *response_str = q5.EncodeJson(response) return !this.IsBlockZone(response.Country, response.Province, response.City) } + +func (this* GameConf) Dump() *q5.MutableXObject { + this.ipWhiteListMutex.Lock() + this.ipBlackListMutex.Lock() + this.launchWhiteListMutex.Lock() + this.launchBlackListMutex.Lock() + this.blockProvinceCityHashMutex.Lock() + //this.fixedBlockProvinceCityHashMutex.Lock() + defer this.ipWhiteListMutex.Unlock() + defer this.ipBlackListMutex.Unlock() + defer this.launchWhiteListMutex.Unlock() + defer this.launchBlackListMutex.Unlock() + defer this.blockProvinceCityHashMutex.Unlock() + //defer this.fixedBlockProvinceCityHashMutex.Unlock() + + fillRespObj := func(respObj* q5.MutableXObject, attrName string, mapObj* map[string]int32) { + list := q5.NewMxoArray() + for key, _ := range *mapObj { + list.PushXValue(q5.NewXString(key)) + } + respObj.SetXObject(attrName, list.AsXObject()) + } + + respObj := q5.NewMxoObject() + respObj.SetXValue("errcode", q5.NewXInt32(0)) + respObj.SetXValue("errmsg", q5.NewXString("")) + fillRespObj(respObj, "ip_white_list", &this.ipWhiteList) + fillRespObj(respObj, "ip_black_list", &this.ipBlackList) + fillRespObj(respObj, "launch_white_list", &this.launchWhiteList) + fillRespObj(respObj, "launch_black_list", &this.launchBlackList) + fillRespObj(respObj, "block_province_city_list", &this.blockProvinceCityHash) + //fillRespObj(respObj, "fixed_block_province_city_list", &this.fixedBlockProvinceCityHash) + return respObj +} diff --git a/third_party/q5 b/third_party/q5 index 1e70d9f..56027b3 160000 --- a/third_party/q5 +++ b/third_party/q5 @@ -1 +1 @@ -Subproject commit 1e70d9f8938d42dfff11538792c4aa5bf9045ba1 +Subproject commit 56027b3c56267df69521b43612e2fab8650163a0