This commit is contained in:
aozhiwei 2021-01-07 10:53:52 +08:00
parent 0aeeca5e49
commit 8ddac568d9
2 changed files with 28 additions and 29 deletions

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"net/http"
"fmt" "fmt"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -150,17 +149,17 @@ func (this *RiskMgr) GetGameConf(gameId int32, channel int32) *GameConf {
return val return val
} }
func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { func (this *RiskMgr) __analyseIsOpen(c *f5.Context) {
var gameConf *GameConf var gameConf *GameConf
responseStr := "" responseStr := ""
isPass := func () bool { isPass := func () bool {
if r.Method != "POST" { if c.Method() != "POST" {
atomic.AddInt64(&this.totalHttpMethodBlockTimes, 1) atomic.AddInt64(&this.totalHttpMethodBlockTimes, 1)
atomic.AddInt64(&this.httpMethodBlockTimes, 1) atomic.AddInt64(&this.httpMethodBlockTimes, 1)
return false return false
} }
accountId := q5.Request(r, "account_id").GetString() accountId := c.Request("account_id").GetString()
sessionId := q5.Request(r, "session_id").GetString() sessionId := c.Request("session_id").GetString()
if !f5.IsValidSessionId(accountId, sessionId, SESSION_KEY) { if !f5.IsValidSessionId(accountId, sessionId, SESSION_KEY) {
atomic.AddInt64(&this.totalSessionErrBlockTimes, 1) atomic.AddInt64(&this.totalSessionErrBlockTimes, 1)
atomic.AddInt64(&this.sessionErrBlockTimes, 1) atomic.AddInt64(&this.sessionErrBlockTimes, 1)
@ -174,11 +173,11 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) {
return false return false
} }
remoteAddr := q5.GetRequestRemoteAddr(r) remoteAddr := c.GetRemoteAddr()
if this.clusterConf.GetTesting() == 1 && q5.Request(r, "ip").GetString() != "" { if this.clusterConf.GetTesting() == 1 && c.Request("ip").GetString() != "" {
remoteAddr = q5.Request(r, "ip").GetString() remoteAddr = c.Request("ip").GetString()
} }
launchInfo := q5.GetPostBody(r).GetString() launchInfo := c.GetBody().GetString()
return gameConf.IsPass(remoteAddr, launchInfo) return gameConf.IsPass(remoteAddr, launchInfo)
} }
if isPass() { 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}`, data := fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d, "data":%s}`,
1, 1,
responseStr) responseStr)
q5.Response(w, data) c.Response(data)
} else { } else {
q5.ResponseInt32Ok(w, "is_open", 1) c.ResponseInt32Ok("is_open", 1)
} }
} else { } else {
atomic.AddInt64(&this.totalBlockTimes, 1) 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}`, data := fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d, "data":%s}`,
0, 0,
responseStr) responseStr)
q5.Response(w, data) c.Response(data)
} else { } else {
q5.ResponseInt32Ok(w, "is_open", 0) c.ResponseInt32Ok("is_open", 0)
} }
} }
} }
func (this *RiskMgr) __opsDump(w* http.ResponseWriter, r *http.Request) { func (this *RiskMgr) __opsDump(c *f5.Context) {
gameId := q5.Request(r, "gameid").GetInt32() gameId := c.Request("gameid").GetInt32()
channel := q5.Request(r, "channel").GetInt32() channel := c.Request("channel").GetInt32()
gameConf := this.GetGameConf(gameId, channel) gameConf := this.GetGameConf(gameId, channel)
if gameConf == nil { if gameConf == nil {
q5.ResponseErr(w, 1, "数据不存在") c.ResponseErr(1, "数据不存在")
return return
} }
q5.Response(w, gameConf.Dump().ToJsonStr()) c.Response(gameConf.Dump().ToJsonStr())
} }
func (this *RiskMgr) __opsSyncConf(w* http.ResponseWriter, r *http.Request) { func (this *RiskMgr) __opsSyncConf(c *f5.Context) {
gameId := q5.Request(r, "gameid").GetInt32() gameId := c.Request("gameid").GetInt32()
channel := q5.Request(r, "channel").GetInt32() channel := c.Request("channel").GetInt32()
gameConf := this.GetGameConf(gameId, channel) gameConf := this.GetGameConf(gameId, channel)
if gameConf == nil { if gameConf == nil {
q5.ResponseErr(w, 1, "数据不存在") c.ResponseErr(1, "数据不存在")
return return
} }
gameConf.SyncConf() gameConf.SyncConf()
q5.ResponseOk(w) c.ResponseOk()
} }
func (this *RiskMgr) __opsInfo(w* http.ResponseWriter, r *http.Request) { func (this *RiskMgr) __opsInfo(c *f5.Context) {
gameId := q5.Request(r, "gameid").GetInt32() gameId := c.Request("gameid").GetInt32()
channel := q5.Request(r, "channel").GetInt32() channel := c.Request("channel").GetInt32()
gameConf := this.GetGameConf(gameId, channel) gameConf := this.GetGameConf(gameId, channel)
if gameConf == nil { if gameConf == nil {
q5.ResponseErr(w, 1, "数据不存在") c.ResponseErr(1, "数据不存在")
return return
} }
respObj := q5.NewMxoObject() respObj := q5.NewMxoObject()
@ -248,7 +247,7 @@ func (this *RiskMgr) __opsInfo(w* http.ResponseWriter, r *http.Request) {
respObj.SetXValue("errmsg", q5.NewXString("")) respObj.SetXValue("errmsg", q5.NewXString(""))
respObj.SetXObject("pass", gameConf.GetPassObj()) respObj.SetXObject("pass", gameConf.GetPassObj())
respObj.SetXObject("block", gameConf.GetBlockObj()) respObj.SetXObject("block", gameConf.GetBlockObj())
q5.Response(w, respObj.ToJsonStr()) c.Response(respObj.ToJsonStr())
} }
/* /*

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit b4b8898e1192b286b00ba04628f1f28f7e0b4f13 Subproject commit 17a44afd7cb2249356f911203ec83ca1c4d50e8b