移除ip黑白名单配置
This commit is contained in:
parent
dc0560f3a8
commit
ce9eb6e0ac
@ -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()
|
||||
|
@ -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)
|
||||
|
2
third_party/f5
vendored
2
third_party/f5
vendored
@ -1 +1 @@
|
||||
Subproject commit 32919e76e14935e089dfae84aa346f6b9031c3ea
|
||||
Subproject commit 9790bfdd6e252d2bf15079572a6ead034626a3d5
|
Loading…
x
Reference in New Issue
Block a user