From 8ddac568d933b33cf15a14fdb3c798b719f130e6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 7 Jan 2021 10:53:52 +0800 Subject: [PATCH] 1 --- server/analyseapi/riskmgr.go | 55 ++++++++++++++++++------------------ third_party/f5 | 2 +- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index 59125c4..fb6875e 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -1,7 +1,6 @@ package main import ( - "net/http" "fmt" "sync" "sync/atomic" @@ -150,17 +149,17 @@ func (this *RiskMgr) GetGameConf(gameId int32, channel int32) *GameConf { return val } -func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { +func (this *RiskMgr) __analyseIsOpen(c *f5.Context) { var gameConf *GameConf responseStr := "" isPass := func () bool { - if r.Method != "POST" { + if c.Method() != "POST" { atomic.AddInt64(&this.totalHttpMethodBlockTimes, 1) atomic.AddInt64(&this.httpMethodBlockTimes, 1) return false } - accountId := q5.Request(r, "account_id").GetString() - sessionId := q5.Request(r, "session_id").GetString() + accountId := c.Request("account_id").GetString() + sessionId := c.Request("session_id").GetString() if !f5.IsValidSessionId(accountId, sessionId, SESSION_KEY) { atomic.AddInt64(&this.totalSessionErrBlockTimes, 1) atomic.AddInt64(&this.sessionErrBlockTimes, 1) @@ -174,11 +173,11 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { return false } - remoteAddr := q5.GetRequestRemoteAddr(r) - if this.clusterConf.GetTesting() == 1 && q5.Request(r, "ip").GetString() != "" { - remoteAddr = q5.Request(r, "ip").GetString() + remoteAddr := c.GetRemoteAddr() + if this.clusterConf.GetTesting() == 1 && c.Request("ip").GetString() != "" { + remoteAddr = c.Request("ip").GetString() } - launchInfo := q5.GetPostBody(r).GetString() + launchInfo := c.GetBody().GetString() return gameConf.IsPass(remoteAddr, launchInfo) } if isPass() { @@ -191,9 +190,9 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { data := fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d, "data":%s}`, 1, responseStr) - q5.Response(w, data) + c.Response(data) } else { - q5.ResponseInt32Ok(w, "is_open", 1) + c.ResponseInt32Ok("is_open", 1) } } else { atomic.AddInt64(&this.totalBlockTimes, 1) @@ -205,42 +204,42 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { data := fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d, "data":%s}`, 0, responseStr) - q5.Response(w, data) + c.Response(data) } else { - q5.ResponseInt32Ok(w, "is_open", 0) + c.ResponseInt32Ok("is_open", 0) } } } -func (this *RiskMgr) __opsDump(w* http.ResponseWriter, r *http.Request) { - gameId := q5.Request(r, "gameid").GetInt32() - channel := q5.Request(r, "channel").GetInt32() +func (this *RiskMgr) __opsDump(c *f5.Context) { + gameId := c.Request("gameid").GetInt32() + channel := c.Request("channel").GetInt32() gameConf := this.GetGameConf(gameId, channel) if gameConf == nil { - q5.ResponseErr(w, 1, "数据不存在") + c.ResponseErr(1, "数据不存在") return } - q5.Response(w, gameConf.Dump().ToJsonStr()) + c.Response(gameConf.Dump().ToJsonStr()) } -func (this *RiskMgr) __opsSyncConf(w* http.ResponseWriter, r *http.Request) { - gameId := q5.Request(r, "gameid").GetInt32() - channel := q5.Request(r, "channel").GetInt32() +func (this *RiskMgr) __opsSyncConf(c *f5.Context) { + gameId := c.Request("gameid").GetInt32() + channel := c.Request("channel").GetInt32() gameConf := this.GetGameConf(gameId, channel) if gameConf == nil { - q5.ResponseErr(w, 1, "数据不存在") + c.ResponseErr(1, "数据不存在") return } gameConf.SyncConf() - q5.ResponseOk(w) + c.ResponseOk() } -func (this *RiskMgr) __opsInfo(w* http.ResponseWriter, r *http.Request) { - gameId := q5.Request(r, "gameid").GetInt32() - channel := q5.Request(r, "channel").GetInt32() +func (this *RiskMgr) __opsInfo(c *f5.Context) { + gameId := c.Request("gameid").GetInt32() + channel := c.Request("channel").GetInt32() gameConf := this.GetGameConf(gameId, channel) if gameConf == nil { - q5.ResponseErr(w, 1, "数据不存在") + c.ResponseErr(1, "数据不存在") return } respObj := q5.NewMxoObject() @@ -248,7 +247,7 @@ func (this *RiskMgr) __opsInfo(w* http.ResponseWriter, r *http.Request) { respObj.SetXValue("errmsg", q5.NewXString("")) respObj.SetXObject("pass", gameConf.GetPassObj()) respObj.SetXObject("block", gameConf.GetBlockObj()) - q5.Response(w, respObj.ToJsonStr()) + c.Response(respObj.ToJsonStr()) } /* diff --git a/third_party/f5 b/third_party/f5 index b4b8898..17a44af 160000 --- a/third_party/f5 +++ b/third_party/f5 @@ -1 +1 @@ -Subproject commit b4b8898e1192b286b00ba04628f1f28f7e0b4f13 +Subproject commit 17a44afd7cb2249356f911203ec83ca1c4d50e8b