From ce9eb6e0ac23f0c3828712bd03419b545658e04e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Jan 2021 11:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4ip=E9=BB=91=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/analyseapi/metamgr.go | 64 ------------------------------------ server/analyseapi/riskmgr.go | 28 ---------------- third_party/f5 | 2 +- 3 files changed, 1 insertion(+), 93 deletions(-) diff --git a/server/analyseapi/metamgr.go b/server/analyseapi/metamgr.go index 28b9adb..f297aa0 100644 --- a/server/analyseapi/metamgr.go +++ b/server/analyseapi/metamgr.go @@ -9,8 +9,6 @@ import ( const ( MT_SERVER_INFO = 0 MT_ALI_KEY = iota - MT_IP_WHITE_LIST - MT_IP_BLACK_LIST MT_LAUNCH_WHITE_LIST MT_LAUNCH_BLACK_LIST MT_BLOCK_PROVINCE_CITY @@ -24,12 +22,6 @@ type MetaMgr struct { accessSecret string sdkInfoMutex sync.RWMutex - ipWhiteList map[string]int32 - ipWhiteListMutex sync.RWMutex - - ipBlackList map[string]int32 - ipBlackListMutex sync.RWMutex - fixedBlockRegionHash map[string]int32 fixedBlockRegionHashMutex sync.RWMutex } @@ -52,16 +44,6 @@ func (this *MetaMgr) Init() *MetaMgr { Idx: MT_ALI_KEY, RawMeta: (*mt.AliKeyInfoMetas)(nil), WrapMeta: (*MtwAliKeyConf)(nil)}, - f5.MetaClass{ - FileName: configDir + "ip_whitelist.json", - Idx: MT_IP_WHITE_LIST, - RawMeta: (*mt.IpWhiteListMetas)(nil), - WrapMeta: (*MtwIpWhiteList)(nil)}, - f5.MetaClass{ - FileName: configDir + "ip_blacklist.json", - Idx: MT_IP_BLACK_LIST, - RawMeta: (*mt.IpBlackListMetas)(nil), - WrapMeta: (*MtwIpBlackList)(nil)}, f5.MetaClass{ FileName: configDir + "launch_whitelist.json", Idx: MT_LAUNCH_WHITE_LIST, @@ -90,28 +72,15 @@ func (this *MetaMgr) UnInit() { func (this *MetaMgr) secondInit() { this.sdkInfoMutex.Lock() - this.ipWhiteListMutex.Lock() - this.ipBlackListMutex.Lock() this.fixedBlockRegionHashMutex.Lock() defer this.sdkInfoMutex.Unlock() - defer this.ipWhiteListMutex.Unlock() - defer this.ipBlackListMutex.Unlock() defer this.fixedBlockRegionHashMutex.Unlock() this.accessKeyId = this.GetAliKey().GetAccessKeyid() this.accessSecret = this.GetAliKey().GetAccessSecret() - this.ipWhiteList = make(map[string]int32) - this.ipBlackList = make(map[string]int32) this.fixedBlockRegionHash = make(map[string]int32) - for _, val := range this.GetIpWhiteList().GetList() { - this.ipWhiteList[val] = 1 - } - for _, val := range this.GetIpBlackList().GetList() { - this.ipBlackList[val] = 1 - } - for _, val := range this.GetFixedBlockRegion().GetList() { this.fixedBlockRegionHash[val] = 1 } @@ -139,24 +108,6 @@ func (this *MetaMgr) GetAliKey() *MtwAliKeyConf { } } -func (this *MetaMgr) GetIpWhiteList() *MtwIpWhiteList { - v, ok := this.MetaMgr.GetMetaById(MT_IP_WHITE_LIST, 1).(*MtwIpWhiteList) - if ok { - return v - } else { - return nil - } -} - -func (this *MetaMgr) GetIpBlackList() *MtwIpBlackList { - v, ok := this.MetaMgr.GetMetaById(MT_IP_BLACK_LIST, 1).(*MtwIpBlackList) - if ok { - return v - } else { - return nil - } -} - func (this *MetaMgr) GetLaunchWhiteList() *MtwLaunchWhiteList { v, ok := this.MetaMgr.GetMetaById(MT_LAUNCH_WHITE_LIST, 1).(*MtwLaunchWhiteList) if ok { @@ -184,21 +135,6 @@ func (this *MetaMgr) GetFixedBlockRegion() *MtwBlockProvinceCity { } } -func (this *MetaMgr) InIpWhiteList(ip string) bool { - this.ipWhiteListMutex.Lock() - defer this.ipWhiteListMutex.Unlock() - _, ok := this.ipWhiteList[ip] - return ok -} - - -func (this* MetaMgr) InIpBlackList(ip string) bool { - this.ipBlackListMutex.Lock() - defer this.ipBlackListMutex.Unlock() - _, ok := this.ipBlackList[ip] - return ok -} - func (this* MetaMgr) GetSdkInfo(accessKeyId* string, accessSecret* string) { this.sdkInfoMutex.Lock() defer this.sdkInfoMutex.Unlock() diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index 8461974..b321a24 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -15,12 +15,6 @@ type RiskMgr struct { passTimes int64 blockTimes int64 - totalIpWhiteListPassTimes int64 - ipWhiteListPassTimes int64 - - totalIpBlackListBlockTimes int64 - ipBlackListBlockTimes int64 - totalHttpMethodBlockTimes int64 httpMethodBlockTimes int64 totalSessionErrBlockTimes int64 @@ -87,16 +81,12 @@ func (this* RiskMgr) OutputLog() { atomic.StoreInt64(&this.blockTimes, 0) atomic.StoreInt64(&this.httpMethodBlockTimes, 0) atomic.StoreInt64(&this.sessionErrBlockTimes, 0) - atomic.StoreInt64(&this.ipWhiteListPassTimes, 0) - atomic.StoreInt64(&this.ipBlackListBlockTimes, 0) } func (this* RiskMgr) GetGlobalPassObj() *q5.XObject { passObj := q5.NewMxoObject() passObj.SetXValue("total", q5.NewXInt64(this.totalPassTimes)) passObj.SetXValue("curr", q5.NewXInt64(this.passTimes)) - passObj.SetXValue("total_ip_whitelist", q5.NewXInt64(this.totalIpWhiteListPassTimes)) - passObj.SetXValue("curr_ip_whitelist", q5.NewXInt64(this.ipWhiteListPassTimes)) return passObj.AsXObject() } @@ -104,8 +94,6 @@ 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_ip_blacklist", q5.NewXInt64(this.totalIpBlackListBlockTimes)) - blockObj.SetXValue("curr_ip_blacklist", q5.NewXInt64(this.ipBlackListBlockTimes)) blockObj.SetXValue("total_methoderr", q5.NewXInt64(this.totalHttpMethodBlockTimes)) blockObj.SetXValue("curr_methoderr", q5.NewXInt64(this.httpMethodBlockTimes)) blockObj.SetXValue("total_sessonerr", q5.NewXInt64(this.totalSessionErrBlockTimes)) @@ -167,22 +155,6 @@ func (this *RiskMgr) _analyseIsOpen(c *f5.Context) { remoteAddr = c.Request("ip").GetString() } - if G.MetaMgr.InIpWhiteList(remoteAddr) { - atomic.AddInt64(&this.totalIpWhiteListPassTimes, 1) - atomic.AddInt64(&this.ipWhiteListPassTimes, 1) - atomic.AddInt64(&gameConf.passTimes, 1) - atomic.AddInt64(&gameConf.totalPassTimes, 1) - return true - } - - if G.MetaMgr.InIpBlackList(remoteAddr) { - atomic.AddInt64(&this.totalIpBlackListBlockTimes, 1) - atomic.AddInt64(&this.ipBlackListBlockTimes, 1) - atomic.AddInt64(&gameConf.blockTimes, 1) - atomic.AddInt64(&gameConf.totalBlockTimes, 1) - return false - } - launchInfo := c.GetBody().GetString() if gameConf.IsPass(remoteAddr, launchInfo, &responseStr) { atomic.AddInt64(&gameConf.passTimes, 1) diff --git a/third_party/f5 b/third_party/f5 index 32919e7..9790bfd 160000 --- a/third_party/f5 +++ b/third_party/f5 @@ -1 +1 @@ -Subproject commit 32919e76e14935e089dfae84aa346f6b9031c3ea +Subproject commit 9790bfdd6e252d2bf15079572a6ead034626a3d5