1
This commit is contained in:
parent
7ee3df2b24
commit
2e2562c7cd
@ -19,7 +19,7 @@ func (this *App_) Init() {
|
|||||||
G.HttpServer = new(f5.HttpServer).Init("httpserver", 1000 * 60)
|
G.HttpServer = new(f5.HttpServer).Init("httpserver", 1000 * 60)
|
||||||
G.RiskMgr = new(RiskMgr).Init()
|
G.RiskMgr = new(RiskMgr).Init()
|
||||||
|
|
||||||
G.HttpServer.Start(G.MetaMgr.GetServer(1).GetListenPort());
|
G.HttpServer.Start(G.MetaMgr.GetCurrServer().GetListenPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *App_) UnInit() {
|
func (this *App_) UnInit() {
|
||||||
|
@ -82,6 +82,10 @@ func (this *MetaMgr) GetServer(instance_id int32) *MtwServerInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *MetaMgr) GetCurrServer() *MtwServerInfo {
|
||||||
|
return this.GetServer(int32(f5.App.GetInstanceId()))
|
||||||
|
}
|
||||||
|
|
||||||
func (this *MetaMgr) GetAliKey() *MtwAliKeyConf {
|
func (this *MetaMgr) GetAliKey() *MtwAliKeyConf {
|
||||||
v, ok := this.MetaMgr.GetMetaById(MT_ALI_KEY, 1).(*MtwAliKeyConf)
|
v, ok := this.MetaMgr.GetMetaById(MT_ALI_KEY, 1).(*MtwAliKeyConf)
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -54,6 +54,8 @@ type RiskMgr struct {
|
|||||||
launchBlackListBlockTimes int64
|
launchBlackListBlockTimes int64
|
||||||
totalUnSafeZoneBlockTimes int64
|
totalUnSafeZoneBlockTimes int64
|
||||||
unSafeZoneBlockTimes int64
|
unSafeZoneBlockTimes int64
|
||||||
|
|
||||||
|
clusterConf *MtwServerInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* RiskMgr) Init() *RiskMgr {
|
func (this* RiskMgr) Init() *RiskMgr {
|
||||||
@ -94,6 +96,7 @@ func (this* RiskMgr) Init() *RiskMgr {
|
|||||||
}
|
}
|
||||||
this.accessKeyId = G.MetaMgr.GetAliKey().GetAccessKeyid()
|
this.accessKeyId = G.MetaMgr.GetAliKey().GetAccessKeyid()
|
||||||
this.accessSecret = G.MetaMgr.GetAliKey().GetAccessSecret()
|
this.accessSecret = G.MetaMgr.GetAliKey().GetAccessSecret()
|
||||||
|
this.clusterConf = G.MetaMgr.GetCurrServer()
|
||||||
|
|
||||||
G.HttpServer.RegisterHandle("Analyse", "isOpen", this.__analyseIsOpen)
|
G.HttpServer.RegisterHandle("Analyse", "isOpen", this.__analyseIsOpen)
|
||||||
G.HttpServer.RegisterHandle("Ops", "dump", this.__opsDump)
|
G.HttpServer.RegisterHandle("Ops", "dump", this.__opsDump)
|
||||||
@ -254,6 +257,9 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) {
|
|||||||
channel := f5.ExtractChannelFromAccountId(accountId)
|
channel := f5.ExtractChannelFromAccountId(accountId)
|
||||||
|
|
||||||
remoteAddr := q5.GetRequestRemoteAddr(r)
|
remoteAddr := q5.GetRequestRemoteAddr(r)
|
||||||
|
if this.clusterConf.GetTesting() == 1 && q5.Request(r, "ip").GetString() != "" {
|
||||||
|
remoteAddr = q5.Request(r, "ip").GetString()
|
||||||
|
}
|
||||||
if G.RiskMgr.InIpWhiteList(remoteAddr) {
|
if G.RiskMgr.InIpWhiteList(remoteAddr) {
|
||||||
atomic.AddInt64(&this.totalIpWhiteListPassTimes, 1)
|
atomic.AddInt64(&this.totalIpWhiteListPassTimes, 1)
|
||||||
atomic.AddInt64(&this.ipWhiteListPassTimes, 1)
|
atomic.AddInt64(&this.ipWhiteListPassTimes, 1)
|
||||||
|
@ -18,6 +18,7 @@ message ServerInfo
|
|||||||
optional int32 instance_id = 1;
|
optional int32 instance_id = 1;
|
||||||
optional string listen_ip = 2;
|
optional string listen_ip = 2;
|
||||||
optional int32 listen_port = 3;
|
optional int32 listen_port = 3;
|
||||||
|
optional int32 testing = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ServerInfoMetas
|
message ServerInfoMetas
|
||||||
|
Loading…
x
Reference in New Issue
Block a user