1
This commit is contained in:
parent
156634c3e8
commit
b49eac4934
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"net/http"
|
||||
"sync"
|
||||
"fmt"
|
||||
"q5"
|
||||
"f5"
|
||||
)
|
||||
|
||||
type RiskMgr struct {
|
||||
@ -70,41 +70,61 @@ func (this* RiskMgr) InIpBlackList(ip string) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this* RiskMgr) InLaunchWhiteList(launchInfo string) bool {
|
||||
func (this* RiskMgr) InLaunchWhiteList(gameId int32, channel int32, launchInfo string) bool {
|
||||
this.launchWhiteListMutex.Lock()
|
||||
defer this.launchWhiteListMutex.Unlock()
|
||||
_, ok := this.launchWhiteList[launchInfo]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this* RiskMgr) InLaunchBlackList(launchInfo string) bool {
|
||||
func (this* RiskMgr) InLaunchBlackList(gameId int32, channel int32, launchInfo string) bool {
|
||||
this.launchBlackListMutex.Lock()
|
||||
defer this.launchBlackListMutex.Unlock()
|
||||
_, ok := this.launchBlackList[launchInfo]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this* RiskMgr) IsSafeZone(gameId int32, channel int32, ip string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *RiskMgr) __analyseIsOpen(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
w.Write([]byte(fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d}`, 1)))
|
||||
q5.ResponseInt32Ok(w, "is_open", 0)
|
||||
return
|
||||
}
|
||||
accountId := q5.Request(r, "account_id").GetString()
|
||||
sessionId := q5.Request(r, "session_id").GetString()
|
||||
if !f5.IsValidSessionId(accountId, sessionId, SESSION_KEY) {
|
||||
q5.ResponseInt32Ok(w, "is_open", 0)
|
||||
return
|
||||
}
|
||||
gameId := f5.ExtractGameIdFromAccountId(accountId)
|
||||
channel := f5.ExtractChannelFromAccountId(accountId)
|
||||
|
||||
remoteAddr := q5.GetRequestRemoteAddr(r)
|
||||
if G.RiskMgr.InIpWhiteList(remoteAddr) {
|
||||
w.Write([]byte(fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d}`, 1)))
|
||||
q5.ResponseInt32Ok(w, "is_open", 1)
|
||||
return
|
||||
}
|
||||
if G.RiskMgr.InIpBlackList(remoteAddr) {
|
||||
w.Write([]byte(fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d}`, 0)))
|
||||
q5.ResponseInt32Ok(w, "is_open", 0)
|
||||
return
|
||||
}
|
||||
launchInfo := q5.GetPostBody(r).GetString()
|
||||
if G.RiskMgr.InLaunchWhiteList(launchInfo) {
|
||||
w.Write([]byte(fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d}`, 1)))
|
||||
if G.RiskMgr.InLaunchWhiteList(gameId, channel, launchInfo) {
|
||||
q5.ResponseInt32Ok(w, "is_open", 1)
|
||||
return
|
||||
}
|
||||
if G.RiskMgr.InLaunchBlackList(launchInfo) {
|
||||
w.Write([]byte(fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d}`, 0)))
|
||||
if G.RiskMgr.InLaunchBlackList(gameId, channel, launchInfo) {
|
||||
q5.ResponseInt32Ok(w, "is_open", 0)
|
||||
return
|
||||
}
|
||||
if G.RiskMgr.IsSafeZone(gameId, channel, remoteAddr) {
|
||||
q5.ResponseInt32Ok(w, "is_open", 1)
|
||||
return
|
||||
} else {
|
||||
q5.ResponseInt32Ok(w, "is_open", 0)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
2
third_party/q5
vendored
2
third_party/q5
vendored
@ -1 +1 @@
|
||||
Subproject commit 933ed5c972526defdfc035714f769ac10e0ce8c5
|
||||
Subproject commit f9776ebd7cdd0b60b64c762b7d3325b691714745
|
Loading…
x
Reference in New Issue
Block a user