diff --git a/server/analyseapi/app.go b/server/analyseapi/app.go index f03afb6..8fc7439 100644 --- a/server/analyseapi/app.go +++ b/server/analyseapi/app.go @@ -19,7 +19,7 @@ func (this *App_) Init() { G.HttpServer = new(f5.HttpServer).Init("httpserver", 1000 * 60) G.RiskMgr = new(RiskMgr).Init() - G.HttpServer.Start(G.MetaMgr.GetServer(1).GetListenPort()); + G.HttpServer.Start(G.MetaMgr.GetCurrServer().GetListenPort()); } func (this *App_) UnInit() { diff --git a/server/analyseapi/metamgr.go b/server/analyseapi/metamgr.go index 53881a0..a5a42e5 100644 --- a/server/analyseapi/metamgr.go +++ b/server/analyseapi/metamgr.go @@ -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 { v, ok := this.MetaMgr.GetMetaById(MT_ALI_KEY, 1).(*MtwAliKeyConf) if ok { diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index 09c2abd..3af8ef3 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -54,6 +54,8 @@ type RiskMgr struct { launchBlackListBlockTimes int64 totalUnSafeZoneBlockTimes int64 unSafeZoneBlockTimes int64 + + clusterConf *MtwServerInfo } func (this* RiskMgr) Init() *RiskMgr { @@ -94,6 +96,7 @@ func (this* RiskMgr) Init() *RiskMgr { } this.accessKeyId = G.MetaMgr.GetAliKey().GetAccessKeyid() this.accessSecret = G.MetaMgr.GetAliKey().GetAccessSecret() + this.clusterConf = G.MetaMgr.GetCurrServer() G.HttpServer.RegisterHandle("Analyse", "isOpen", this.__analyseIsOpen) 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) 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) { atomic.AddInt64(&this.totalIpWhiteListPassTimes, 1) atomic.AddInt64(&this.ipWhiteListPassTimes, 1) diff --git a/server/tools/protobuild/mt.proto b/server/tools/protobuild/mt.proto index 9069dc1..19eb827 100644 --- a/server/tools/protobuild/mt.proto +++ b/server/tools/protobuild/mt.proto @@ -18,6 +18,7 @@ message ServerInfo optional int32 instance_id = 1; optional string listen_ip = 2; optional int32 listen_port = 3; + optional int32 testing = 4; } message ServerInfoMetas