diff --git a/server/analyseapi/app.go b/server/analyseapi/app.go new file mode 100644 index 0000000..8fc7439 --- /dev/null +++ b/server/analyseapi/app.go @@ -0,0 +1,31 @@ +package main + +import ( + "f5" +) + +type App_ struct { + f5.App_ +} + +var App = new (App_) + +func (this *App_) Init() { + f5.App = &this.App_ + f5.App.SetPkgName("analyseapi") + this.App_.Init() + G.MetaMgr = new(MetaMgr).Init() + G.GameLog = new(GameLog).Init() + G.HttpServer = new(f5.HttpServer).Init("httpserver", 1000 * 60) + G.RiskMgr = new(RiskMgr).Init() + + G.HttpServer.Start(G.MetaMgr.GetCurrServer().GetListenPort()); +} + +func (this *App_) UnInit() { + G.RiskMgr.UnInit() + G.HttpServer.UnInit() + G.GameLog.UnInit() + G.MetaMgr.UnInit() + this.App_.UnInit() +} diff --git a/server/analyseapi/constant.go b/server/analyseapi/constant.go new file mode 100644 index 0000000..4fed7ac --- /dev/null +++ b/server/analyseapi/constant.go @@ -0,0 +1,7 @@ +package main + +const ( + IM_GAMECONF_CREATE = 100 +) + +const SESSION_KEY = "f3a6a9a5-217a-4079-ab99-b5d69b8212be" diff --git a/server/analyseapi/g.go b/server/analyseapi/g.go new file mode 100644 index 0000000..c4385fb --- /dev/null +++ b/server/analyseapi/g.go @@ -0,0 +1,14 @@ +package main + +import ( + "f5" +) + +type GlobalVar struct { + MetaMgr *MetaMgr + HttpServer *f5.HttpServer + GameLog *GameLog + RiskMgr *RiskMgr +} + +var G *GlobalVar = &GlobalVar{} diff --git a/server/analyseapi/gamelog.go b/server/analyseapi/gamelog.go new file mode 100644 index 0000000..3fcc9f0 --- /dev/null +++ b/server/analyseapi/gamelog.go @@ -0,0 +1,17 @@ +package main + +import ( + "f5" +) + +type GameLog struct { + +} + +func (this *GameLog) Init() *GameLog { + f5.TgLog().SetPolyLog(true) + return this +} + +func (this *GameLog) UnInit() { +} diff --git a/server/analyseapi/go.mod b/server/analyseapi/go.mod new file mode 100644 index 0000000..fd41d96 --- /dev/null +++ b/server/analyseapi/go.mod @@ -0,0 +1,24 @@ +module analyseapi + +go 1.11 + +require q5 v1.0.0 + +require f5 v1.0.0 + +require mt v1.0.0 + +require ( + github.com/aliyun/alibaba-cloud-sdk-go v1.61.614 + github.com/golang/protobuf v1.4.2 + google.golang.org/protobuf v1.23.0 + im v1.0.0 +) + +replace q5 => ../../third_party/q5 + +replace f5 => ../../third_party/f5 + +replace im => ../../third_party/f5/im + +replace mt => ./mt diff --git a/server/analyseapi/go.sum b/server/analyseapi/go.sum new file mode 100644 index 0000000..bc7e259 --- /dev/null +++ b/server/analyseapi/go.sum @@ -0,0 +1,53 @@ +github.com/aliyun/alibaba-cloud-sdk-go v1.61.614 h1:FHWBfCJLqPmXTe/rdx1D0Dp0uQkNDcadDTmXEO5YcEE= +github.com/aliyun/alibaba-cloud-sdk-go v1.61.614/go.mod h1:pUKYbK5JQ+1Dfxk80P0qxGqe5dkxDoabbZS7zOcouyA= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc= +github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk= +gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/server/analyseapi/main.go b/server/analyseapi/main.go new file mode 100644 index 0000000..4575b2d --- /dev/null +++ b/server/analyseapi/main.go @@ -0,0 +1,7 @@ +package main + +func main() { + App.Init() + App.Run() + App.UnInit() +} diff --git a/server/analyseapi/makefile b/server/analyseapi/makefile new file mode 100644 index 0000000..514317f --- /dev/null +++ b/server/analyseapi/makefile @@ -0,0 +1,19 @@ +compile: + @. /etc/profile + + protoc --proto_path=proto --go_out=./mt proto/mt.proto + @export GOPROXY=https://goproxy.io + @go build -gcflags=all="-N -l" -o ../bin/analyseapi + @echo "compile done" + +debug: + @. /etc/profile + + protoc --proto_path=proto --go_out=./mt proto/mt.proto + @export GOPROXY=https://goproxy.io + @go build -gcflags=all="-N -l" -ldflags "-X q5.optDebug=1" -o ../bin/analyseapi + @echo "compile done" + +clean: + @rm -f ../bin/analyseapi + @echo "clean done" diff --git a/server/analyseapi/metamgr.go b/server/analyseapi/metamgr.go new file mode 100644 index 0000000..a5a42e5 --- /dev/null +++ b/server/analyseapi/metamgr.go @@ -0,0 +1,141 @@ +package main + +import ( + "f5" + "mt" +) + +const ( + MT_SERVER_INFO = 0 + MT_ALI_KEY = iota + MT_IP_WHITE_LIST + MT_IP_BLACK_LIST + MT_LAUNCH_WHITE_LIST + MT_LAUNCH_BLACK_LIST + MT_BLOCK_PROVINCE_CITY + MT_MAX +) + +type MetaMgr struct { + f5.MetaMgr +} + +func (this *MetaMgr) Init() *MetaMgr { + this.MetaMgr.Init() + configDir := "../config/" + if !f5.IsOnlineEnv() { + configDir = "/var/data/conf_test/analyseapi/" + } + metaClasses := &[]f5.MetaClass{ + f5.MetaClass{ + PrimKey: "InstanceId", + FileName: configDir + "analyseapi.cluster.json", + Idx: MT_SERVER_INFO, + RawMeta: (*mt.ServerInfoMetas)(nil), + WrapMeta: (*MtwServerInfo)(nil)}, + f5.MetaClass{ + FileName: configDir + "ali_key.json", + Idx: MT_ALI_KEY, + RawMeta: (*mt.AliKeyInfoMetas)(nil), + WrapMeta: (*MtwAliKeyConf)(nil)}, + f5.MetaClass{ + FileName: configDir + "ip_whitelist.json", + Idx: MT_IP_WHITE_LIST, + RawMeta: (*mt.IpWhiteListMetas)(nil), + WrapMeta: (*MtwIpWhiteList)(nil)}, + f5.MetaClass{ + FileName: configDir + "ip_blacklist.json", + Idx: MT_IP_BLACK_LIST, + RawMeta: (*mt.IpBlackListMetas)(nil), + WrapMeta: (*MtwIpBlackList)(nil)}, + f5.MetaClass{ + FileName: configDir + "launch_whitelist.json", + Idx: MT_LAUNCH_WHITE_LIST, + RawMeta: (*mt.LaunchWhiteListMetas)(nil), + WrapMeta: (*MtwLaunchWhiteList)(nil)}, + f5.MetaClass{ + FileName: configDir + "launch_blacklist.json", + Idx: MT_LAUNCH_BLACK_LIST, + RawMeta: (*mt.LaunchBlackListMetas)(nil), + WrapMeta: (*MtwLaunchBlackList)(nil)}, + f5.MetaClass{ + FileName: configDir + "block_province_city.json", + Idx: MT_BLOCK_PROVINCE_CITY, + RawMeta: (*mt.BlockProvinceCityMetas)(nil), + WrapMeta: (*MtwBlockProvinceCity)(nil)}, + } + this.MetaMgr.RegisterMetaClasses(metaClasses) + this.Load() + return this +} + +func (this *MetaMgr) UnInit() { + this.MetaMgr.UnInit() +} + +func (this *MetaMgr) GetServer(instance_id int32) *MtwServerInfo { + v, ok := this.MetaMgr.GetMetaById(MT_SERVER_INFO, instance_id).(*MtwServerInfo) + if ok { + return v + } else { + return nil + } +} + +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 { + return v + } else { + return nil + } +} + +func (this *MetaMgr) GetIpWhiteList() *MtwIpWhiteList { + v, ok := this.MetaMgr.GetMetaById(MT_IP_WHITE_LIST, 1).(*MtwIpWhiteList) + if ok { + return v + } else { + return nil + } +} + +func (this *MetaMgr) GetIpBlackList() *MtwIpBlackList { + v, ok := this.MetaMgr.GetMetaById(MT_IP_BLACK_LIST, 1).(*MtwIpBlackList) + if ok { + return v + } else { + return nil + } +} + +func (this *MetaMgr) GetLaunchWhiteList() *MtwLaunchWhiteList { + v, ok := this.MetaMgr.GetMetaById(MT_LAUNCH_WHITE_LIST, 1).(*MtwLaunchWhiteList) + if ok { + return v + } else { + return nil + } +} + +func (this *MetaMgr) GetLaunchBlackList() *MtwLaunchBlackList { + v, ok := this.MetaMgr.GetMetaById(MT_LAUNCH_BLACK_LIST, 1).(*MtwLaunchBlackList) + if ok { + return v + } else { + return nil + } +} + +func (this *MetaMgr) GetFixedBlockProvinceCity() *MtwBlockProvinceCity { + v, ok := this.MetaMgr.GetMetaById(MT_BLOCK_PROVINCE_CITY, 1).(*MtwBlockProvinceCity) + if ok { + return v + } else { + return nil + } +} diff --git a/server/analyseapi/metawrap.go b/server/analyseapi/metawrap.go new file mode 100644 index 0000000..4a3cb4a --- /dev/null +++ b/server/analyseapi/metawrap.go @@ -0,0 +1,31 @@ +package main + +import "mt" + +type MtwServerInfo struct { + *mt.ServerInfo +} + +type MtwAliKeyConf struct { + *mt.AliKeyConf +} + +type MtwIpWhiteList struct { + *mt.IpWhiteList +} + +type MtwIpBlackList struct { + *mt.IpBlackList +} + +type MtwLaunchWhiteList struct { + *mt.LaunchWhiteList +} + +type MtwLaunchBlackList struct { + *mt.LaunchBlackList +} + +type MtwBlockProvinceCity struct { + *mt.BlockProvinceCity +} diff --git a/server/analyseapi/mt/go.mod b/server/analyseapi/mt/go.mod new file mode 100644 index 0000000..8ac5839 --- /dev/null +++ b/server/analyseapi/mt/go.mod @@ -0,0 +1,8 @@ +module metatable + +go 1.15 + +require ( + github.com/golang/protobuf v1.4.2 + google.golang.org/protobuf v1.23.0 +) diff --git a/server/analyseapi/mt/go.sum b/server/analyseapi/mt/go.sum new file mode 100644 index 0000000..99386c1 --- /dev/null +++ b/server/analyseapi/mt/go.sum @@ -0,0 +1,19 @@ +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= diff --git a/server/analyseapi/mt/mt.pb.go b/server/analyseapi/mt/mt.pb.go new file mode 100644 index 0000000..289c8f2 --- /dev/null +++ b/server/analyseapi/mt/mt.pb.go @@ -0,0 +1,1006 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.23.0 +// protoc (unknown) +// source: mt.proto + +package mt + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type AliKeyConf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AccessKeyid *string `protobuf:"bytes,1,opt,name=access_keyid,json=accessKeyid" json:"access_keyid,omitempty"` + AccessSecret *string `protobuf:"bytes,2,opt,name=access_secret,json=accessSecret" json:"access_secret,omitempty"` +} + +func (x *AliKeyConf) Reset() { + *x = AliKeyConf{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AliKeyConf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AliKeyConf) ProtoMessage() {} + +func (x *AliKeyConf) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AliKeyConf.ProtoReflect.Descriptor instead. +func (*AliKeyConf) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{0} +} + +func (x *AliKeyConf) GetAccessKeyid() string { + if x != nil && x.AccessKeyid != nil { + return *x.AccessKeyid + } + return "" +} + +func (x *AliKeyConf) GetAccessSecret() string { + if x != nil && x.AccessSecret != nil { + return *x.AccessSecret + } + return "" +} + +type AliKeyInfoMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*AliKeyConf `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *AliKeyInfoMetas) Reset() { + *x = AliKeyInfoMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AliKeyInfoMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AliKeyInfoMetas) ProtoMessage() {} + +func (x *AliKeyInfoMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AliKeyInfoMetas.ProtoReflect.Descriptor instead. +func (*AliKeyInfoMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{1} +} + +func (x *AliKeyInfoMetas) GetValues() []*AliKeyConf { + if x != nil { + return x.Values + } + return nil +} + +type ServerInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InstanceId *int32 `protobuf:"varint,1,opt,name=instance_id,json=instanceId" json:"instance_id,omitempty"` + ListenIp *string `protobuf:"bytes,2,opt,name=listen_ip,json=listenIp" json:"listen_ip,omitempty"` + ListenPort *int32 `protobuf:"varint,3,opt,name=listen_port,json=listenPort" json:"listen_port,omitempty"` + Testing *int32 `protobuf:"varint,4,opt,name=testing" json:"testing,omitempty"` +} + +func (x *ServerInfo) Reset() { + *x = ServerInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerInfo) ProtoMessage() {} + +func (x *ServerInfo) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerInfo.ProtoReflect.Descriptor instead. +func (*ServerInfo) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{2} +} + +func (x *ServerInfo) GetInstanceId() int32 { + if x != nil && x.InstanceId != nil { + return *x.InstanceId + } + return 0 +} + +func (x *ServerInfo) GetListenIp() string { + if x != nil && x.ListenIp != nil { + return *x.ListenIp + } + return "" +} + +func (x *ServerInfo) GetListenPort() int32 { + if x != nil && x.ListenPort != nil { + return *x.ListenPort + } + return 0 +} + +func (x *ServerInfo) GetTesting() int32 { + if x != nil && x.Testing != nil { + return *x.Testing + } + return 0 +} + +type ServerInfoMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*ServerInfo `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *ServerInfoMetas) Reset() { + *x = ServerInfoMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerInfoMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerInfoMetas) ProtoMessage() {} + +func (x *ServerInfoMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerInfoMetas.ProtoReflect.Descriptor instead. +func (*ServerInfoMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{3} +} + +func (x *ServerInfoMetas) GetValues() []*ServerInfo { + if x != nil { + return x.Values + } + return nil +} + +type IpWhiteList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []string `protobuf:"bytes,1,rep,name=list" json:"list,omitempty"` +} + +func (x *IpWhiteList) Reset() { + *x = IpWhiteList{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IpWhiteList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IpWhiteList) ProtoMessage() {} + +func (x *IpWhiteList) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IpWhiteList.ProtoReflect.Descriptor instead. +func (*IpWhiteList) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{4} +} + +func (x *IpWhiteList) GetList() []string { + if x != nil { + return x.List + } + return nil +} + +type IpWhiteListMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*IpWhiteList `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *IpWhiteListMetas) Reset() { + *x = IpWhiteListMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IpWhiteListMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IpWhiteListMetas) ProtoMessage() {} + +func (x *IpWhiteListMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IpWhiteListMetas.ProtoReflect.Descriptor instead. +func (*IpWhiteListMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{5} +} + +func (x *IpWhiteListMetas) GetValues() []*IpWhiteList { + if x != nil { + return x.Values + } + return nil +} + +type IpBlackList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []string `protobuf:"bytes,1,rep,name=list" json:"list,omitempty"` +} + +func (x *IpBlackList) Reset() { + *x = IpBlackList{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IpBlackList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IpBlackList) ProtoMessage() {} + +func (x *IpBlackList) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IpBlackList.ProtoReflect.Descriptor instead. +func (*IpBlackList) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{6} +} + +func (x *IpBlackList) GetList() []string { + if x != nil { + return x.List + } + return nil +} + +type IpBlackListMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*IpBlackList `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *IpBlackListMetas) Reset() { + *x = IpBlackListMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IpBlackListMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IpBlackListMetas) ProtoMessage() {} + +func (x *IpBlackListMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IpBlackListMetas.ProtoReflect.Descriptor instead. +func (*IpBlackListMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{7} +} + +func (x *IpBlackListMetas) GetValues() []*IpBlackList { + if x != nil { + return x.Values + } + return nil +} + +type LaunchWhiteList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []string `protobuf:"bytes,1,rep,name=list" json:"list,omitempty"` +} + +func (x *LaunchWhiteList) Reset() { + *x = LaunchWhiteList{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LaunchWhiteList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LaunchWhiteList) ProtoMessage() {} + +func (x *LaunchWhiteList) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LaunchWhiteList.ProtoReflect.Descriptor instead. +func (*LaunchWhiteList) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{8} +} + +func (x *LaunchWhiteList) GetList() []string { + if x != nil { + return x.List + } + return nil +} + +type LaunchWhiteListMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*LaunchWhiteList `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *LaunchWhiteListMetas) Reset() { + *x = LaunchWhiteListMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LaunchWhiteListMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LaunchWhiteListMetas) ProtoMessage() {} + +func (x *LaunchWhiteListMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LaunchWhiteListMetas.ProtoReflect.Descriptor instead. +func (*LaunchWhiteListMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{9} +} + +func (x *LaunchWhiteListMetas) GetValues() []*LaunchWhiteList { + if x != nil { + return x.Values + } + return nil +} + +type LaunchBlackList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []string `protobuf:"bytes,1,rep,name=list" json:"list,omitempty"` +} + +func (x *LaunchBlackList) Reset() { + *x = LaunchBlackList{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LaunchBlackList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LaunchBlackList) ProtoMessage() {} + +func (x *LaunchBlackList) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LaunchBlackList.ProtoReflect.Descriptor instead. +func (*LaunchBlackList) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{10} +} + +func (x *LaunchBlackList) GetList() []string { + if x != nil { + return x.List + } + return nil +} + +type LaunchBlackListMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*LaunchBlackList `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *LaunchBlackListMetas) Reset() { + *x = LaunchBlackListMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LaunchBlackListMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LaunchBlackListMetas) ProtoMessage() {} + +func (x *LaunchBlackListMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LaunchBlackListMetas.ProtoReflect.Descriptor instead. +func (*LaunchBlackListMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{11} +} + +func (x *LaunchBlackListMetas) GetValues() []*LaunchBlackList { + if x != nil { + return x.Values + } + return nil +} + +type BlockProvinceCity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []string `protobuf:"bytes,1,rep,name=list" json:"list,omitempty"` +} + +func (x *BlockProvinceCity) Reset() { + *x = BlockProvinceCity{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockProvinceCity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockProvinceCity) ProtoMessage() {} + +func (x *BlockProvinceCity) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockProvinceCity.ProtoReflect.Descriptor instead. +func (*BlockProvinceCity) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{12} +} + +func (x *BlockProvinceCity) GetList() []string { + if x != nil { + return x.List + } + return nil +} + +type BlockProvinceCityMetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*BlockProvinceCity `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` +} + +func (x *BlockProvinceCityMetas) Reset() { + *x = BlockProvinceCityMetas{} + if protoimpl.UnsafeEnabled { + mi := &file_mt_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockProvinceCityMetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockProvinceCityMetas) ProtoMessage() {} + +func (x *BlockProvinceCityMetas) ProtoReflect() protoreflect.Message { + mi := &file_mt_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockProvinceCityMetas.ProtoReflect.Descriptor instead. +func (*BlockProvinceCityMetas) Descriptor() ([]byte, []int) { + return file_mt_proto_rawDescGZIP(), []int{13} +} + +func (x *BlockProvinceCityMetas) GetValues() []*BlockProvinceCity { + if x != nil { + return x.Values + } + return nil +} + +var File_mt_proto protoreflect.FileDescriptor + +var file_mt_proto_rawDesc = []byte{ + 0x0a, 0x08, 0x6d, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x6d, 0x74, 0x22, 0x39, + 0x0a, 0x0a, 0x41, 0x6c, 0x69, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x12, 0x14, 0x0a, 0x0c, + 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x12, 0x15, 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x65, 0x63, + 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x22, 0x31, 0x0a, 0x0f, 0x41, 0x6c, 0x69, + 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x1e, 0x0a, 0x06, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, + 0x74, 0x2e, 0x41, 0x6c, 0x69, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x22, 0x5a, 0x0a, 0x0a, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x13, 0x0a, 0x0b, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x12, + 0x11, 0x0a, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x12, 0x13, 0x0a, 0x0b, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x5f, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x12, 0x0f, 0x0a, 0x07, 0x74, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x22, 0x31, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x1e, 0x0a, 0x06, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, 0x74, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x1b, 0x0a, 0x0b, 0x49, + 0x70, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x04, 0x6c, 0x69, + 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x22, 0x33, 0x0a, 0x10, 0x49, 0x70, 0x57, 0x68, + 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x1f, 0x0a, 0x06, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6d, + 0x74, 0x2e, 0x49, 0x70, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x1b, 0x0a, + 0x0b, 0x49, 0x70, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x04, + 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x22, 0x33, 0x0a, 0x10, 0x49, 0x70, + 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x1f, + 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x6d, 0x74, 0x2e, 0x49, 0x70, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x22, + 0x1f, 0x0a, 0x0f, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x22, 0x3b, 0x0a, 0x14, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, + 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x23, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x74, 0x2e, 0x4c, 0x61, + 0x75, 0x6e, 0x63, 0x68, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x1f, 0x0a, + 0x0f, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, + 0x12, 0x0c, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x22, 0x3b, + 0x0a, 0x14, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, + 0x74, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x23, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x74, 0x2e, 0x4c, 0x61, 0x75, 0x6e, + 0x63, 0x68, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x21, 0x0a, 0x11, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x43, 0x69, 0x74, 0x79, + 0x12, 0x0c, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x22, 0x3f, + 0x0a, 0x16, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x43, + 0x69, 0x74, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6d, 0x74, 0x2e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x43, 0x69, 0x74, 0x79, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x6d, 0x74, +} + +var ( + file_mt_proto_rawDescOnce sync.Once + file_mt_proto_rawDescData = file_mt_proto_rawDesc +) + +func file_mt_proto_rawDescGZIP() []byte { + file_mt_proto_rawDescOnce.Do(func() { + file_mt_proto_rawDescData = protoimpl.X.CompressGZIP(file_mt_proto_rawDescData) + }) + return file_mt_proto_rawDescData +} + +var file_mt_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_mt_proto_goTypes = []interface{}{ + (*AliKeyConf)(nil), // 0: mt.AliKeyConf + (*AliKeyInfoMetas)(nil), // 1: mt.AliKeyInfoMetas + (*ServerInfo)(nil), // 2: mt.ServerInfo + (*ServerInfoMetas)(nil), // 3: mt.ServerInfoMetas + (*IpWhiteList)(nil), // 4: mt.IpWhiteList + (*IpWhiteListMetas)(nil), // 5: mt.IpWhiteListMetas + (*IpBlackList)(nil), // 6: mt.IpBlackList + (*IpBlackListMetas)(nil), // 7: mt.IpBlackListMetas + (*LaunchWhiteList)(nil), // 8: mt.LaunchWhiteList + (*LaunchWhiteListMetas)(nil), // 9: mt.LaunchWhiteListMetas + (*LaunchBlackList)(nil), // 10: mt.LaunchBlackList + (*LaunchBlackListMetas)(nil), // 11: mt.LaunchBlackListMetas + (*BlockProvinceCity)(nil), // 12: mt.BlockProvinceCity + (*BlockProvinceCityMetas)(nil), // 13: mt.BlockProvinceCityMetas +} +var file_mt_proto_depIdxs = []int32{ + 0, // 0: mt.AliKeyInfoMetas.values:type_name -> mt.AliKeyConf + 2, // 1: mt.ServerInfoMetas.values:type_name -> mt.ServerInfo + 4, // 2: mt.IpWhiteListMetas.values:type_name -> mt.IpWhiteList + 6, // 3: mt.IpBlackListMetas.values:type_name -> mt.IpBlackList + 8, // 4: mt.LaunchWhiteListMetas.values:type_name -> mt.LaunchWhiteList + 10, // 5: mt.LaunchBlackListMetas.values:type_name -> mt.LaunchBlackList + 12, // 6: mt.BlockProvinceCityMetas.values:type_name -> mt.BlockProvinceCity + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_mt_proto_init() } +func file_mt_proto_init() { + if File_mt_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_mt_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AliKeyConf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AliKeyInfoMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerInfoMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IpWhiteList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IpWhiteListMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IpBlackList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IpBlackListMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LaunchWhiteList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LaunchWhiteListMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LaunchBlackList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LaunchBlackListMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockProvinceCity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mt_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockProvinceCityMetas); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_mt_proto_rawDesc, + NumEnums: 0, + NumMessages: 14, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_mt_proto_goTypes, + DependencyIndexes: file_mt_proto_depIdxs, + MessageInfos: file_mt_proto_msgTypes, + }.Build() + File_mt_proto = out.File + file_mt_proto_rawDesc = nil + file_mt_proto_goTypes = nil + file_mt_proto_depIdxs = nil +} diff --git a/server/analyseapi/proto/mt.proto b/server/analyseapi/proto/mt.proto new file mode 100644 index 0000000..19eb827 --- /dev/null +++ b/server/analyseapi/proto/mt.proto @@ -0,0 +1,77 @@ +package mt; + +option go_package = ".;mt"; + +message AliKeyConf +{ + optional string access_keyid = 1; + optional string access_secret = 2; +} + +message AliKeyInfoMetas +{ + repeated AliKeyConf values = 1; +} + +message ServerInfo +{ + optional int32 instance_id = 1; + optional string listen_ip = 2; + optional int32 listen_port = 3; + optional int32 testing = 4; +} + +message ServerInfoMetas +{ + repeated ServerInfo values = 1; +} + +message IpWhiteList +{ + repeated string list = 1; +} + +message IpWhiteListMetas +{ + repeated IpWhiteList values = 1; +} + +message IpBlackList +{ + repeated string list = 1; +} + +message IpBlackListMetas +{ + repeated IpBlackList values = 1; +} + +message LaunchWhiteList +{ + repeated string list = 1; +} + +message LaunchWhiteListMetas +{ + repeated LaunchWhiteList values = 1; +} + +message LaunchBlackList +{ + repeated string list = 1; +} + +message LaunchBlackListMetas +{ + repeated LaunchBlackList values = 1; +} + +message BlockProvinceCity +{ + repeated string list = 1; +} + +message BlockProvinceCityMetas +{ + repeated BlockProvinceCity values = 1; +} diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go new file mode 100644 index 0000000..59125c4 --- /dev/null +++ b/server/analyseapi/riskmgr.go @@ -0,0 +1,267 @@ +package main + +import ( + "net/http" + "fmt" + "sync" + "sync/atomic" + "q5" + "f5" +) + +type RiskMgr struct { + fixedBlockProvinceCityHash map[string]int32 + fixedBlockProvinceCityHashMutex sync.RWMutex + + accessKeyId string + accessSecret string + sdkInfoMutex sync.RWMutex + + totalPassTimes int64 + totalBlockTimes int64 + passTimes int64 + blockTimes int64 + + totalHttpMethodBlockTimes int64 + httpMethodBlockTimes int64 + totalSessionErrBlockTimes int64 + sessionErrBlockTimes int64 + + gameHash map[int64]*GameConf + gameHashMutex sync.RWMutex + + clusterConf *MtwServerInfo +} + +func (this* RiskMgr) Init() *RiskMgr { + this.fixedBlockProvinceCityHashMutex.Lock() + this.gameHashMutex.Lock() + defer this.fixedBlockProvinceCityHashMutex.Unlock() + defer this.gameHashMutex.Unlock() + + this.fixedBlockProvinceCityHash = make(map[string]int32) + this.gameHash = make(map[int64]*GameConf) + for _, val := range G.MetaMgr.GetFixedBlockProvinceCity().GetList() { + this.fixedBlockProvinceCityHash[val] = 1 + } + + 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) + G.HttpServer.RegisterHandle("Ops", "syncConf", this.__opsSyncConf) + G.HttpServer.RegisterHandle("Ops", "info", this.__opsInfo) + f5.Timer().AddRepeatTimer(1000 * 60, + func (params* q5.XParams) { + }, + func (params* q5.XParams) { + this.OutputLog() + }) + f5.App.RegisterIMMsgHandle(IM_GAMECONF_CREATE, func (msgId int16, params *q5.XParams) { + G.RiskMgr.OnGameConfCreate( + params.Sender.GetInt32(), + params.Param1.GetInt32()) + }) + return this +} + +func (this* RiskMgr) UnInit() { +} + +func (this* RiskMgr) fetchGameConfList() []*GameConf { + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + + gameConfList := make([]*GameConf, 0) + for _, val := range this.gameHash { + gameConfList = append(gameConfList, val) + } + return gameConfList +} + +func (this* RiskMgr) OutputLog() { + for _, val := range this.fetchGameConfList() { + f5.SysLog().Info("gameid:%d channel:%d passobj %s", + val.gameId, + val.channel, + val.GetPassObj().ToJsonStr()) + f5.SysLog().Info("gameid:%d channel:%d blockobj %s", + val.gameId, + val.channel, + val.GetBlockObj().ToJsonStr()) + } + f5.SysLog().Info("global passobj %s", this.GetGlobalPassObj().ToJsonStr()) + f5.SysLog().Info("global blockobj %s", this.GetGlobalBlockObj().ToJsonStr()) + atomic.StoreInt64(&this.passTimes, 0) + atomic.StoreInt64(&this.blockTimes, 0) + atomic.StoreInt64(&this.passTimes, 0) + atomic.StoreInt64(&this.httpMethodBlockTimes, 0) + atomic.StoreInt64(&this.sessionErrBlockTimes, 0) +} + +func (this* RiskMgr) GetGlobalPassObj() *q5.XObject { + passObj := q5.NewMxoObject() + passObj.SetXValue("total", q5.NewXInt64(this.totalPassTimes)) + passObj.SetXValue("curr", q5.NewXInt64(this.passTimes)) + return passObj.AsXObject() +} + +func (this* RiskMgr) GetGlobalBlockObj() *q5.XObject { + blockObj := q5.NewMxoObject() + blockObj.SetXValue("total", q5.NewXInt64(this.totalBlockTimes)) + blockObj.SetXValue("curr", q5.NewXInt64(this.blockTimes)) + blockObj.SetXValue("total_methoderr", q5.NewXInt64(this.totalHttpMethodBlockTimes)) + blockObj.SetXValue("curr_methoderr", q5.NewXInt64(this.httpMethodBlockTimes)) + blockObj.SetXValue("total_sessonerr", q5.NewXInt64(this.totalSessionErrBlockTimes)) + blockObj.SetXValue("curr_sessionerr", q5.NewXInt64(this.sessionErrBlockTimes)) + return blockObj.AsXObject() +} + +func (this* RiskMgr) GetSdkInfo(accessKeyId* string, accessSecret* string) { + this.sdkInfoMutex.Lock() + defer this.sdkInfoMutex.Unlock() + *accessKeyId = "" + this.accessKeyId + *accessSecret = "" + this.accessSecret +} + +func (this *RiskMgr) ForceGameConf(gameId int32, channel int32) *GameConf { + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + if val, ok := this.gameHash[q5.MkInt64(gameId, channel)]; ok { + val.Active() + return val + } else { + gameConf := new(GameConf) + gameConf.gameId = gameId + gameConf.channel = channel + gameConf.Init() + this.gameHash[q5.MkInt64(gameId, channel)] = gameConf + gameConf.Active() + return gameConf + } +} + +func (this *RiskMgr) GetGameConf(gameId int32, channel int32) *GameConf { + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + val, _ := this.gameHash[q5.MkInt64(gameId, channel)] + return val +} + +func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { + var gameConf *GameConf + responseStr := "" + isPass := func () bool { + if r.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() + if !f5.IsValidSessionId(accountId, sessionId, SESSION_KEY) { + atomic.AddInt64(&this.totalSessionErrBlockTimes, 1) + atomic.AddInt64(&this.sessionErrBlockTimes, 1) + return false + } + gameId := f5.ExtractGameIdFromAccountId(accountId) + channel := f5.ExtractChannelFromAccountId(accountId) + + gameConf = this.ForceGameConf(gameId, channel) + if gameConf == nil { + return false + } + + remoteAddr := q5.GetRequestRemoteAddr(r) + if this.clusterConf.GetTesting() == 1 && q5.Request(r, "ip").GetString() != "" { + remoteAddr = q5.Request(r, "ip").GetString() + } + launchInfo := q5.GetPostBody(r).GetString() + return gameConf.IsPass(remoteAddr, launchInfo) + } + if isPass() { + atomic.AddInt64(&this.totalPassTimes, 1) + atomic.AddInt64(&this.passTimes, 1) + if this.clusterConf.GetTesting() == 1 { + if responseStr == "" { + responseStr = `""` + } + data := fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d, "data":%s}`, + 1, + responseStr) + q5.Response(w, data) + } else { + q5.ResponseInt32Ok(w, "is_open", 1) + } + } else { + atomic.AddInt64(&this.totalBlockTimes, 1) + atomic.AddInt64(&this.blockTimes, 1) + if this.clusterConf.GetTesting() == 1 { + if responseStr == "" { + responseStr = `""` + } + data := fmt.Sprintf(`{"errcode":0, "errmsg":"", "is_open":%d, "data":%s}`, + 0, + responseStr) + q5.Response(w, data) + } else { + q5.ResponseInt32Ok(w, "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() + gameConf := this.GetGameConf(gameId, channel) + if gameConf == nil { + q5.ResponseErr(w, 1, "数据不存在") + return + } + q5.Response(w, 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() + gameConf := this.GetGameConf(gameId, channel) + if gameConf == nil { + q5.ResponseErr(w, 1, "数据不存在") + return + } + gameConf.SyncConf() + q5.ResponseOk(w) +} + +func (this *RiskMgr) __opsInfo(w* http.ResponseWriter, r *http.Request) { + gameId := q5.Request(r, "gameid").GetInt32() + channel := q5.Request(r, "channel").GetInt32() + gameConf := this.GetGameConf(gameId, channel) + if gameConf == nil { + q5.ResponseErr(w, 1, "数据不存在") + return + } + respObj := q5.NewMxoObject() + respObj.SetXValue("errcode", q5.NewXInt32(0)) + respObj.SetXValue("errmsg", q5.NewXString("")) + respObj.SetXObject("pass", gameConf.GetPassObj()) + respObj.SetXObject("block", gameConf.GetBlockObj()) + q5.Response(w, respObj.ToJsonStr()) +} + +/* +安装定时器定时更新逻辑 +*/ +func (this *RiskMgr) OnGameConfCreate(gameId int32, channel int32) { + f5.Timer().AddRepeatTimer(1000 * 30, + func (params* q5.XParams) { + }, + func (params* q5.XParams) { + gameConf := this.GetGameConf(gameId, channel) + if gameConf != nil { + gameConf.SyncConf() + } + }) +} diff --git a/server/analyseapi/types.go b/server/analyseapi/types.go new file mode 100644 index 0000000..2edf9a8 --- /dev/null +++ b/server/analyseapi/types.go @@ -0,0 +1,274 @@ +package main + +import ( + "sync" + "github.com/aliyun/alibaba-cloud-sdk-go/services/geoip" + "f5" + "q5" +) + +type GameConf struct { + gameId int32 + channel int32 + syncTimes int64 + lastSyncTime int64 + lastActiveTime int64 + + ipWhiteList map[string]int32 + ipWhiteListMutex sync.RWMutex + + ipBlackList map[string]int32 + ipBlackListMutex sync.RWMutex + + launchWhiteList map[string]int32 + launchWhiteListMutex sync.RWMutex + + launchBlackList map[string]int32 + launchBlackListMutex sync.RWMutex + + blockProvinceCityHash map[string]int32 + blockProvinceCityHashMutex sync.RWMutex + + totalPassTimes int64 + totalBlockTimes int64 + passTimes int64 + blockTimes int64 + + totalIpWhiteListPassTimes int64 + ipWhiteListPassTimes int64 + totalLaunchWhiteListPassTimes int64 + launchWhiteListPassTimes int64 + totalSafeZonePassTimes int64 + safeZonePassTimes int64 + + totalHttpMethodBlockTimes int64 + httpMethodBlockTimes int64 + totalSessionErrBlockTimes int64 + sessionErrBlockTimes int64 + totalIpBlackListBlockTimes int64 + ipBlackListBlockTimes int64 + totalLaunchBlackListBlockTimes int64 + launchBlackListBlockTimes int64 + totalUnSafeZoneBlockTimes int64 + unSafeZoneBlockTimes int64 +} + +func (this *GameConf) IsPass(remoteAddr string, launchInfo string) bool { + /* + 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) + return true + } + if G.RiskMgr.InIpBlackList(remoteAddr) { + atomic.AddInt64(&this.totalIpBlackListBlockTimes, 1) + atomic.AddInt64(&this.ipBlackListBlockTimes, 1) + return false + } + launchInfo := q5.GetPostBody(r).GetString() + if G.RiskMgr.InLaunchWhiteList(gameId, channel, launchInfo) { + atomic.AddInt64(&this.totalLaunchWhiteListPassTimes, 1) + atomic.AddInt64(&this.launchWhiteListPassTimes, 1) + return true + } + if G.RiskMgr.InLaunchBlackList(gameId, channel, launchInfo) { + atomic.AddInt64(&this.totalLaunchBlackListBlockTimes, 1) + atomic.AddInt64(&this.launchBlackListBlockTimes, 1) + return false + } + if G.RiskMgr.IsSafeZone(gameId, channel, remoteAddr, &responseStr) { + atomic.AddInt64(&this.totalSafeZonePassTimes, 1) + atomic.AddInt64(&this.safeZonePassTimes, 1) + return true + } else { + atomic.AddInt64(&this.totalUnSafeZoneBlockTimes, 1) + atomic.AddInt64(&this.unSafeZoneBlockTimes, 1) + return false + } +*/ + return false +} + +func (this* GameConf) InIpWhiteList(ip string) bool { + this.ipWhiteListMutex.Lock() + defer this.ipWhiteListMutex.Unlock() + _, ok := this.ipWhiteList[ip] + return ok +} + +func (this* GameConf) InIpBlackList(ip string) bool { + this.ipBlackListMutex.Lock() + defer this.ipBlackListMutex.Unlock() + _, ok := this.ipBlackList[ip] + return ok +} + +func (this* GameConf) InLaunchWhiteList(gameId int32, channel int32, launchInfo string) bool { + this.launchWhiteListMutex.Lock() + defer this.launchWhiteListMutex.Unlock() + _, ok := this.launchWhiteList[launchInfo] + return ok +} + +func (this* GameConf) InLaunchBlackList(gameId int32, channel int32, launchInfo string) bool { + this.launchBlackListMutex.Lock() + defer this.launchBlackListMutex.Unlock() + _, ok := this.launchBlackList[launchInfo] + return ok +} + +func (this* GameConf) Init() { + this.ipWhiteListMutex.Lock() + this.ipBlackListMutex.Lock() + this.launchWhiteListMutex.Lock() + this.launchBlackListMutex.Lock() + this.blockProvinceCityHashMutex.Lock() + defer this.ipWhiteListMutex.Unlock() + defer this.ipBlackListMutex.Unlock() + defer this.launchWhiteListMutex.Unlock() + defer this.launchBlackListMutex.Unlock() + defer this.blockProvinceCityHashMutex.Unlock() + + this.ipWhiteList = make(map[string]int32) + this.ipBlackList = make(map[string]int32) + this.launchWhiteList = make(map[string]int32) + this.launchBlackList = make(map[string]int32) + this.blockProvinceCityHash = make(map[string]int32) + + for _, val := range G.MetaMgr.GetIpWhiteList().GetList() { + this.ipWhiteList[val] = 1 + } + for _, val := range G.MetaMgr.GetIpBlackList().GetList() { + this.ipBlackList[val] = 1 + } + for _, val := range G.MetaMgr.GetLaunchWhiteList().GetList() { + this.launchWhiteList[val] = 1 + } + for _, val := range G.MetaMgr.GetLaunchBlackList().GetList() { + this.launchBlackList[val] = 1 + } + for _, val := range G.MetaMgr.GetFixedBlockProvinceCity().GetList() { + this.blockProvinceCityHash[val] = 1 + } + this.lastActiveTime = f5.App.NowUnix() + f5.App.AddIMMsg(IM_GAMECONF_CREATE, new(q5.XParams).Init(func (params* q5.XParams) { + params.Sender.SetInt32(this.gameId) + params.Param1.SetInt32(this.channel) + })) +} + +func (this* GameConf) IsBlockZone(country string, province string, city string) bool { + if country == "" || province == "" || city == "" { + return true + } + if country != "中国" { + return true + } + + /*this.blockProvinceCityHashMutex.Lock() + defer this.blockProvinceCityHashMutex.Unlock() + if _, ok := this.blockProvinceCityHash[province]; ok { + return true + } + if _, ok := this.blockProvinceCityHash[city]; ok { + return true + } + if _, ok := this.blockProvinceCityHash[province + "/" + city]; ok { + return true + }*/ + return false +} + +func (this* GameConf) IsSafeZone(ip string, response_str* string) bool { + accessKeyId := "" + accessSecret := "" + G.RiskMgr.GetSdkInfo(&accessKeyId, &accessSecret) + client, err := geoip.NewClientWithAccessKey("cn-hangzhou", accessKeyId, accessSecret) + if err != nil { + f5.SysLog().Warning("NewClientWithAccessKey error %s", err.Error()) + return false + } + + request := geoip.CreateDescribeIpv4LocationRequest() + request.Scheme = "https" + request.Ip = ip + + response, err := client.DescribeIpv4Location(request) + if err != nil { + f5.SysLog().Warning("Ipv4Location error %s", err.Error()) + return false + } + *response_str = q5.EncodeJson(response) + return !this.IsBlockZone(response.Country, response.Province, response.City) +} + +func (this* GameConf) Dump() *q5.MutableXObject { + this.ipWhiteListMutex.Lock() + this.ipBlackListMutex.Lock() + this.launchWhiteListMutex.Lock() + this.launchBlackListMutex.Lock() + this.blockProvinceCityHashMutex.Lock() + //this.fixedBlockProvinceCityHashMutex.Lock() + defer this.ipWhiteListMutex.Unlock() + defer this.ipBlackListMutex.Unlock() + defer this.launchWhiteListMutex.Unlock() + defer this.launchBlackListMutex.Unlock() + defer this.blockProvinceCityHashMutex.Unlock() + //defer this.fixedBlockProvinceCityHashMutex.Unlock() + + fillRespObj := func(respObj* q5.MutableXObject, attrName string, mapObj* map[string]int32) { + list := q5.NewMxoArray() + for key, _ := range *mapObj { + list.PushXValue(q5.NewXString(key)) + } + respObj.SetXObject(attrName, list.AsXObject()) + } + + respObj := q5.NewMxoObject() + respObj.SetXValue("errcode", q5.NewXInt32(0)) + respObj.SetXValue("errmsg", q5.NewXString("")) + fillRespObj(respObj, "ip_white_list", &this.ipWhiteList) + fillRespObj(respObj, "ip_black_list", &this.ipBlackList) + fillRespObj(respObj, "launch_white_list", &this.launchWhiteList) + fillRespObj(respObj, "launch_black_list", &this.launchBlackList) + fillRespObj(respObj, "block_province_city_list", &this.blockProvinceCityHash) + //fillRespObj(respObj, "fixed_block_province_city_list", &this.fixedBlockProvinceCityHash) + return respObj +} + +func (this* GameConf) GetPassObj() *q5.XObject { + passObj := q5.NewMxoObject() + /*passObj.SetXValue("total_white_ip_times", q5.NewXInt64(this.totalIpWhiteListPassTimes)) + passObj.SetXValue("curr_white_ip_times", q5.NewXInt64(this.ipWhiteListPassTimes)) + passObj.SetXValue("total_white_launch_times", q5.NewXInt64(this.totalLaunchWhiteListPassTimes)) + passObj.SetXValue("curr_white_launch_times", q5.NewXInt64(this.launchWhiteListPassTimes)) + passObj.SetXValue("total_safezone_times", q5.NewXInt64(this.totalSafeZonePassTimes)) + passObj.SetXValue("curr_safezone_times", q5.NewXInt64(this.safeZonePassTimes))*/ + return passObj.AsXObject() +} + +func (this* GameConf) GetBlockObj() *q5.XObject { + blockObj := q5.NewMxoObject() + /*blockObj.SetXValue("total_method_err_times", q5.NewXInt64(this.totalHttpMethodBlockTimes)) + blockObj.SetXValue("curr_method_err_times", q5.NewXInt64(this.httpMethodBlockTimes)) + blockObj.SetXValue("total_session_err_times", q5.NewXInt64(this.totalSessionErrBlockTimes)) + blockObj.SetXValue("curr_session_err_times", q5.NewXInt64(this.sessionErrBlockTimes)) + blockObj.SetXValue("total_black_ip_times", q5.NewXInt64(this.totalIpBlackListBlockTimes)) + blockObj.SetXValue("curr_black_ip_times", q5.NewXInt64(this.ipBlackListBlockTimes)) + blockObj.SetXValue("total_black_launch_times", q5.NewXInt64(this.totalLaunchBlackListBlockTimes)) + blockObj.SetXValue("curr_black_launch_times", q5.NewXInt64(this.launchBlackListBlockTimes)) + blockObj.SetXValue("total_unsafezone_times", q5.NewXInt64(this.totalUnSafeZoneBlockTimes)) + blockObj.SetXValue("curr_unsafezone_times", q5.NewXInt64(this.unSafeZoneBlockTimes))*/ + return blockObj.AsXObject() +} + +func (this* GameConf) Active() { + this.lastActiveTime = f5.App.NowUnix() +} + +func (this* GameConf) SyncConf() { +}