1
This commit is contained in:
parent
762c589b75
commit
8a3572ccc2
@ -12,7 +12,8 @@ const (
|
||||
MT_IP_BLACK_LIST
|
||||
MT_LAUNCH_WHITE_LIST
|
||||
MT_LAUNCH_BLACK_LIST
|
||||
MT_MAX = iota
|
||||
MT_BLOCK_PROVINCE_CITY
|
||||
MT_MAX
|
||||
)
|
||||
|
||||
type MetaMgr struct {
|
||||
@ -57,6 +58,11 @@ func (this *MetaMgr) Init() *MetaMgr {
|
||||
Idx: MT_LAUNCH_BLACK_LIST,
|
||||
RawMeta: (*mt.LaunchBlackListMetas)(nil),
|
||||
WrapMeta: (*MtwLaunchBlackList)(nil)},
|
||||
f5.MetaClass{
|
||||
FileName: configDir + "block_province_city.json",
|
||||
Idx: MT_BLOCK_PROVINCE_CITY,
|
||||
RawMeta: (*mt.BlockProvinceCityMetas)(nil),
|
||||
WrapMeta: (*MtwBlockProvinceCity)(nil)},
|
||||
}
|
||||
this.MetaMgr.RegisterMetaClasses(metaClasses)
|
||||
this.Load()
|
||||
@ -120,3 +126,12 @@ func (this *MetaMgr) GetLaunchBlackList() *MtwLaunchBlackList {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *MetaMgr) GetFixedBlockProvinceCity() *MtwBlockProvinceCity {
|
||||
v, ok := this.MetaMgr.GetMetaById(MT_BLOCK_PROVINCE_CITY, 1).(*MtwBlockProvinceCity)
|
||||
if ok {
|
||||
return v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -25,3 +25,7 @@ type MtwLaunchWhiteList struct {
|
||||
type MtwLaunchBlackList struct {
|
||||
*mt.LaunchBlackList
|
||||
}
|
||||
|
||||
type MtwBlockProvinceCity struct {
|
||||
*mt.BlockProvinceCity
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ type RiskMgr struct {
|
||||
blockProvinceCityHash map[string]int32
|
||||
blockProvinceCityHashMutex sync.RWMutex
|
||||
|
||||
fixedBlockProvinceCityHash map[string]int32
|
||||
fixedBlockProvinceCityHashMutex sync.RWMutex
|
||||
|
||||
accessKeyId string
|
||||
accessSecret string
|
||||
sdkInfoMutex sync.RWMutex
|
||||
@ -35,11 +38,13 @@ func (this* RiskMgr) Init() *RiskMgr {
|
||||
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()
|
||||
|
||||
this.ipWhiteList = make(map[string]int32)
|
||||
this.ipBlackList = make(map[string]int32)
|
||||
@ -59,6 +64,10 @@ func (this* RiskMgr) Init() *RiskMgr {
|
||||
for _, val := range G.MetaMgr.GetLaunchBlackList().GetList() {
|
||||
this.launchBlackList[val] = 1
|
||||
}
|
||||
for _, val := range G.MetaMgr.GetFixedBlockProvinceCity().GetList() {
|
||||
this.fixedBlockProvinceCityHash[val] = 1
|
||||
this.blockProvinceCityHash[val] = 1
|
||||
}
|
||||
this.accessKeyId = G.MetaMgr.GetAliKey().GetAccessKeyid()
|
||||
this.accessSecret = G.MetaMgr.GetAliKey().GetAccessSecret()
|
||||
|
||||
@ -197,11 +206,13 @@ func (this *RiskMgr) __opsDump(w* http.ResponseWriter, r *http.Request) {
|
||||
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()
|
||||
@ -219,5 +230,6 @@ func (this *RiskMgr) __opsDump(w* http.ResponseWriter, r *http.Request) {
|
||||
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())
|
||||
}
|
||||
|
@ -64,3 +64,13 @@ message LaunchBlackListMetas
|
||||
{
|
||||
repeated LaunchBlackList values = 1;
|
||||
}
|
||||
|
||||
message BlockProvinceCity
|
||||
{
|
||||
repeated string list = 1;
|
||||
}
|
||||
|
||||
message BlockProvinceCityMetas
|
||||
{
|
||||
repeated BlockProvinceCity values = 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user