接入腾讯ip服务

This commit is contained in:
aozhiwei 2021-08-12 13:41:43 +08:00
parent dd70c62ed0
commit fabaaa22ce
6 changed files with 339 additions and 83 deletions

View File

@ -9,6 +9,7 @@ import (
const (
MT_SERVER_INFO = 0
MT_ALI_KEY = iota
MT_TX_KEY
MT_SCENE_WHITE_LIST
MT_LAUNCH_WHITE_LIST
MT_BLOCK_PROVINCE_CITY
@ -18,6 +19,8 @@ const (
type MetaMgr struct {
f5.MetaMgr
txKey string
txSecretKey string
accessKeyId string
accessSecret string
sdkInfoMutex sync.RWMutex
@ -44,6 +47,11 @@ func (this *MetaMgr) Init() *MetaMgr {
Idx: MT_ALI_KEY,
RawMeta: (*mt.AliKeyInfoMetas)(nil),
WrapMeta: (*MtwAliKeyConf)(nil)},
f5.MetaClass{
FileName: configDir + "tx_key.json",
Idx: MT_TX_KEY,
RawMeta: (*mt.TxKeyInfoMetas)(nil),
WrapMeta: (*MtwTxKeyConf)(nil)},
f5.MetaClass{
FileName: configDir + "scene_whitelist.json",
Idx: MT_SCENE_WHITE_LIST,
@ -76,6 +84,8 @@ func (this *MetaMgr) secondInit() {
defer this.sdkInfoMutex.Unlock()
defer this.fixedBlockRegionHashMutex.Unlock()
this.txKey = this.GetTxKey().GetKey()
this.txSecretKey = this.GetTxKey().GetSecretKey()
this.accessKeyId = this.GetAliKey().GetAccessKeyid()
this.accessSecret = this.GetAliKey().GetAccessSecret()
@ -108,6 +118,15 @@ func (this *MetaMgr) GetAliKey() *MtwAliKeyConf {
}
}
func (this *MetaMgr) GetTxKey() *MtwTxKeyConf {
v, ok := this.MetaMgr.GetMetaById(MT_TX_KEY, 1).(*MtwTxKeyConf)
if ok {
return v
} else {
return nil
}
}
func (this *MetaMgr) GetSceneWhiteList() *MtwSceneWhiteList {
v, ok := this.MetaMgr.GetMetaById(MT_SCENE_WHITE_LIST, 1).(*MtwSceneWhiteList)
if ok {
@ -135,13 +154,20 @@ func (this *MetaMgr) GetFixedBlockRegion() *MtwBlockProvinceCity {
}
}
func (this* MetaMgr) GetSdkInfo(accessKeyId* string, accessSecret* string) {
func (this* MetaMgr) GetAliSdkInfo(accessKeyId* string, accessSecret* string) {
this.sdkInfoMutex.Lock()
defer this.sdkInfoMutex.Unlock()
*accessKeyId = "" + this.accessKeyId
*accessSecret = "" + this.accessSecret
}
func (this* MetaMgr) GetTxSdkInfo(txKey* string, secretKey* string) {
this.sdkInfoMutex.Lock()
defer this.sdkInfoMutex.Unlock()
*txKey = "" + this.txKey
*secretKey = "" + this.txSecretKey
}
func (this* MetaMgr) IsBlockZone(country string, province string, city string) bool {
this.fixedBlockRegionHashMutex.Lock()
defer this.fixedBlockRegionHashMutex.Unlock()

View File

@ -10,6 +10,10 @@ type MtwAliKeyConf struct {
*mt.AliKeyConf
}
type MtwTxKeyConf struct {
*mt.TxKeyConf
}
type MtwSceneWhiteList struct {
*mt.SceneWhiteList
}

View File

@ -127,6 +127,108 @@ func (x *AliKeyInfoMetas) GetValues() []*AliKeyConf {
return nil
}
type TxKeyConf struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
SecretKey *string `protobuf:"bytes,2,opt,name=secret_key,json=secretKey" json:"secret_key,omitempty"`
}
func (x *TxKeyConf) Reset() {
*x = TxKeyConf{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TxKeyConf) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TxKeyConf) ProtoMessage() {}
func (x *TxKeyConf) 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 TxKeyConf.ProtoReflect.Descriptor instead.
func (*TxKeyConf) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{2}
}
func (x *TxKeyConf) GetKey() string {
if x != nil && x.Key != nil {
return *x.Key
}
return ""
}
func (x *TxKeyConf) GetSecretKey() string {
if x != nil && x.SecretKey != nil {
return *x.SecretKey
}
return ""
}
type TxKeyInfoMetas struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Values []*TxKeyConf `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
}
func (x *TxKeyInfoMetas) Reset() {
*x = TxKeyInfoMetas{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TxKeyInfoMetas) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TxKeyInfoMetas) ProtoMessage() {}
func (x *TxKeyInfoMetas) 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 TxKeyInfoMetas.ProtoReflect.Descriptor instead.
func (*TxKeyInfoMetas) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{3}
}
func (x *TxKeyInfoMetas) GetValues() []*TxKeyConf {
if x != nil {
return x.Values
}
return nil
}
type ServerInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -141,7 +243,7 @@ type ServerInfo struct {
func (x *ServerInfo) Reset() {
*x = ServerInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[2]
mi := &file_mt_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -154,7 +256,7 @@ func (x *ServerInfo) String() string {
func (*ServerInfo) ProtoMessage() {}
func (x *ServerInfo) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[2]
mi := &file_mt_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -167,7 +269,7 @@ func (x *ServerInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use ServerInfo.ProtoReflect.Descriptor instead.
func (*ServerInfo) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{2}
return file_mt_proto_rawDescGZIP(), []int{4}
}
func (x *ServerInfo) GetInstanceId() int32 {
@ -209,7 +311,7 @@ type ServerInfoMetas struct {
func (x *ServerInfoMetas) Reset() {
*x = ServerInfoMetas{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[3]
mi := &file_mt_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -222,7 +324,7 @@ func (x *ServerInfoMetas) String() string {
func (*ServerInfoMetas) ProtoMessage() {}
func (x *ServerInfoMetas) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[3]
mi := &file_mt_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -235,7 +337,7 @@ func (x *ServerInfoMetas) ProtoReflect() protoreflect.Message {
// Deprecated: Use ServerInfoMetas.ProtoReflect.Descriptor instead.
func (*ServerInfoMetas) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{3}
return file_mt_proto_rawDescGZIP(), []int{5}
}
func (x *ServerInfoMetas) GetValues() []*ServerInfo {
@ -256,7 +358,7 @@ type SceneWhiteList struct {
func (x *SceneWhiteList) Reset() {
*x = SceneWhiteList{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[4]
mi := &file_mt_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -269,7 +371,7 @@ func (x *SceneWhiteList) String() string {
func (*SceneWhiteList) ProtoMessage() {}
func (x *SceneWhiteList) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[4]
mi := &file_mt_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -282,7 +384,7 @@ func (x *SceneWhiteList) ProtoReflect() protoreflect.Message {
// Deprecated: Use SceneWhiteList.ProtoReflect.Descriptor instead.
func (*SceneWhiteList) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{4}
return file_mt_proto_rawDescGZIP(), []int{6}
}
func (x *SceneWhiteList) GetList() []string {
@ -303,7 +405,7 @@ type SceneWhiteListMetas struct {
func (x *SceneWhiteListMetas) Reset() {
*x = SceneWhiteListMetas{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[5]
mi := &file_mt_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -316,7 +418,7 @@ func (x *SceneWhiteListMetas) String() string {
func (*SceneWhiteListMetas) ProtoMessage() {}
func (x *SceneWhiteListMetas) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[5]
mi := &file_mt_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -329,7 +431,7 @@ func (x *SceneWhiteListMetas) ProtoReflect() protoreflect.Message {
// Deprecated: Use SceneWhiteListMetas.ProtoReflect.Descriptor instead.
func (*SceneWhiteListMetas) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{5}
return file_mt_proto_rawDescGZIP(), []int{7}
}
func (x *SceneWhiteListMetas) GetValues() []*SceneWhiteList {
@ -350,7 +452,7 @@ type LaunchWhiteList struct {
func (x *LaunchWhiteList) Reset() {
*x = LaunchWhiteList{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[6]
mi := &file_mt_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -363,7 +465,7 @@ func (x *LaunchWhiteList) String() string {
func (*LaunchWhiteList) ProtoMessage() {}
func (x *LaunchWhiteList) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[6]
mi := &file_mt_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -376,7 +478,7 @@ func (x *LaunchWhiteList) ProtoReflect() protoreflect.Message {
// Deprecated: Use LaunchWhiteList.ProtoReflect.Descriptor instead.
func (*LaunchWhiteList) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{6}
return file_mt_proto_rawDescGZIP(), []int{8}
}
func (x *LaunchWhiteList) GetList() []string {
@ -397,7 +499,7 @@ type LaunchWhiteListMetas struct {
func (x *LaunchWhiteListMetas) Reset() {
*x = LaunchWhiteListMetas{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[7]
mi := &file_mt_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -410,7 +512,7 @@ func (x *LaunchWhiteListMetas) String() string {
func (*LaunchWhiteListMetas) ProtoMessage() {}
func (x *LaunchWhiteListMetas) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[7]
mi := &file_mt_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -423,7 +525,7 @@ func (x *LaunchWhiteListMetas) ProtoReflect() protoreflect.Message {
// Deprecated: Use LaunchWhiteListMetas.ProtoReflect.Descriptor instead.
func (*LaunchWhiteListMetas) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{7}
return file_mt_proto_rawDescGZIP(), []int{9}
}
func (x *LaunchWhiteListMetas) GetValues() []*LaunchWhiteList {
@ -444,7 +546,7 @@ type BlockProvinceCity struct {
func (x *BlockProvinceCity) Reset() {
*x = BlockProvinceCity{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[8]
mi := &file_mt_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -457,7 +559,7 @@ func (x *BlockProvinceCity) String() string {
func (*BlockProvinceCity) ProtoMessage() {}
func (x *BlockProvinceCity) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[8]
mi := &file_mt_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -470,7 +572,7 @@ func (x *BlockProvinceCity) ProtoReflect() protoreflect.Message {
// Deprecated: Use BlockProvinceCity.ProtoReflect.Descriptor instead.
func (*BlockProvinceCity) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{8}
return file_mt_proto_rawDescGZIP(), []int{10}
}
func (x *BlockProvinceCity) GetList() []string {
@ -491,7 +593,7 @@ type BlockProvinceCityMetas struct {
func (x *BlockProvinceCityMetas) Reset() {
*x = BlockProvinceCityMetas{}
if protoimpl.UnsafeEnabled {
mi := &file_mt_proto_msgTypes[9]
mi := &file_mt_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -504,7 +606,7 @@ func (x *BlockProvinceCityMetas) String() string {
func (*BlockProvinceCityMetas) ProtoMessage() {}
func (x *BlockProvinceCityMetas) ProtoReflect() protoreflect.Message {
mi := &file_mt_proto_msgTypes[9]
mi := &file_mt_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -517,7 +619,7 @@ func (x *BlockProvinceCityMetas) ProtoReflect() protoreflect.Message {
// Deprecated: Use BlockProvinceCityMetas.ProtoReflect.Descriptor instead.
func (*BlockProvinceCityMetas) Descriptor() ([]byte, []int) {
return file_mt_proto_rawDescGZIP(), []int{9}
return file_mt_proto_rawDescGZIP(), []int{11}
}
func (x *BlockProvinceCityMetas) GetValues() []*BlockProvinceCity {
@ -537,34 +639,40 @@ var file_mt_proto_rawDesc = []byte{
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, 0x1e, 0x0a, 0x0e, 0x53,
0x63, 0x65, 0x6e, 0x65, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x0c, 0x0a,
0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x22, 0x39, 0x0a, 0x13, 0x53,
0x63, 0x65, 0x6e, 0x65, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74,
0x61, 0x73, 0x12, 0x22, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x74, 0x2e, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x57, 0x68, 0x69,
0x74, 0x65, 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, 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,
0x74, 0x2e, 0x41, 0x6c, 0x69, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x22, 0x2c, 0x0a, 0x09,
0x54, 0x78, 0x4b, 0x65, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x12, 0x0b, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x12, 0x12, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x22, 0x2f, 0x0a, 0x0e, 0x54, 0x78,
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x12, 0x1d, 0x0a, 0x06,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6d,
0x74, 0x2e, 0x54, 0x78, 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, 0x1e, 0x0a, 0x0e, 0x53, 0x63,
0x65, 0x6e, 0x65, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x04,
0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x22, 0x39, 0x0a, 0x13, 0x53, 0x63,
0x65, 0x6e, 0x65, 0x57, 0x68, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61,
0x73, 0x12, 0x22, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x74, 0x2e, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x57, 0x68, 0x69, 0x74,
0x65, 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, 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 (
@ -579,30 +687,33 @@ func file_mt_proto_rawDescGZIP() []byte {
return file_mt_proto_rawDescData
}
var file_mt_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_mt_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
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
(*SceneWhiteList)(nil), // 4: mt.SceneWhiteList
(*SceneWhiteListMetas)(nil), // 5: mt.SceneWhiteListMetas
(*LaunchWhiteList)(nil), // 6: mt.LaunchWhiteList
(*LaunchWhiteListMetas)(nil), // 7: mt.LaunchWhiteListMetas
(*BlockProvinceCity)(nil), // 8: mt.BlockProvinceCity
(*BlockProvinceCityMetas)(nil), // 9: mt.BlockProvinceCityMetas
(*TxKeyConf)(nil), // 2: mt.TxKeyConf
(*TxKeyInfoMetas)(nil), // 3: mt.TxKeyInfoMetas
(*ServerInfo)(nil), // 4: mt.ServerInfo
(*ServerInfoMetas)(nil), // 5: mt.ServerInfoMetas
(*SceneWhiteList)(nil), // 6: mt.SceneWhiteList
(*SceneWhiteListMetas)(nil), // 7: mt.SceneWhiteListMetas
(*LaunchWhiteList)(nil), // 8: mt.LaunchWhiteList
(*LaunchWhiteListMetas)(nil), // 9: mt.LaunchWhiteListMetas
(*BlockProvinceCity)(nil), // 10: mt.BlockProvinceCity
(*BlockProvinceCityMetas)(nil), // 11: 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.SceneWhiteListMetas.values:type_name -> mt.SceneWhiteList
6, // 3: mt.LaunchWhiteListMetas.values:type_name -> mt.LaunchWhiteList
8, // 4: mt.BlockProvinceCityMetas.values:type_name -> mt.BlockProvinceCity
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
0, // 0: mt.AliKeyInfoMetas.values:type_name -> mt.AliKeyConf
2, // 1: mt.TxKeyInfoMetas.values:type_name -> mt.TxKeyConf
4, // 2: mt.ServerInfoMetas.values:type_name -> mt.ServerInfo
6, // 3: mt.SceneWhiteListMetas.values:type_name -> mt.SceneWhiteList
8, // 4: mt.LaunchWhiteListMetas.values:type_name -> mt.LaunchWhiteList
10, // 5: mt.BlockProvinceCityMetas.values:type_name -> mt.BlockProvinceCity
6, // [6:6] is the sub-list for method output_type
6, // [6:6] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_mt_proto_init() }
@ -636,7 +747,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ServerInfo); i {
switch v := v.(*TxKeyConf); i {
case 0:
return &v.state
case 1:
@ -648,7 +759,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ServerInfoMetas); i {
switch v := v.(*TxKeyInfoMetas); i {
case 0:
return &v.state
case 1:
@ -660,7 +771,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SceneWhiteList); i {
switch v := v.(*ServerInfo); i {
case 0:
return &v.state
case 1:
@ -672,7 +783,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SceneWhiteListMetas); i {
switch v := v.(*ServerInfoMetas); i {
case 0:
return &v.state
case 1:
@ -684,7 +795,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LaunchWhiteList); i {
switch v := v.(*SceneWhiteList); i {
case 0:
return &v.state
case 1:
@ -696,7 +807,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LaunchWhiteListMetas); i {
switch v := v.(*SceneWhiteListMetas); i {
case 0:
return &v.state
case 1:
@ -708,7 +819,7 @@ func file_mt_proto_init() {
}
}
file_mt_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BlockProvinceCity); i {
switch v := v.(*LaunchWhiteList); i {
case 0:
return &v.state
case 1:
@ -720,6 +831,30 @@ func file_mt_proto_init() {
}
}
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.(*BlockProvinceCity); 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.(*BlockProvinceCityMetas); i {
case 0:
return &v.state
@ -738,7 +873,7 @@ func file_mt_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_mt_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumMessages: 12,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -13,6 +13,17 @@ message AliKeyInfoMetas
repeated AliKeyConf values = 1;
}
message TxKeyConf
{
optional string key = 1;
optional string secret_key = 2;
}
message TxKeyInfoMetas
{
repeated TxKeyConf values = 1;
}
message ServerInfo
{
optional int32 instance_id = 1;

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"sync"
"encoding/json"
"sync/atomic"
"github.com/aliyun/alibaba-cloud-sdk-go/services/geoip"
"q5"
@ -256,9 +257,34 @@ func (this *RiskMgr) OnGameConfCreate(gameId int32, channel int32) {
}
func (this* RiskMgr) IsSafeZone(ip string, responseStr* string) bool {
country := ""
province := ""
city := ""
if this.GetIpInfo(ip, responseStr, &country, &province, &city) {
return !G.MetaMgr.IsBlockZone(country, province, city)
} else {
return false;
}
}
func (this* RiskMgr) GetIpInfo(
ip string,
responseStr* string,
country* string,
province* string,
city* string) bool {
return this.GetIpInfoByTx(ip, responseStr, country, province, city)
}
func (this* RiskMgr) GetIpInfoByAli(
ip string,
responseStr* string,
country* string,
province* string,
city* string) bool {
accessKeyId := ""
accessSecret := ""
G.MetaMgr.GetSdkInfo(&accessKeyId, &accessSecret)
G.MetaMgr.GetAliSdkInfo(&accessKeyId, &accessSecret)
client, err := geoip.NewClientWithAccessKey("cn-hangzhou", accessKeyId, accessSecret)
if err != nil {
f5.SysLog().Warning("NewClientWithAccessKey error %s", err.Error())
@ -278,5 +304,59 @@ func (this* RiskMgr) IsSafeZone(ip string, responseStr* string) bool {
f5.SysLog().Info("ali_response: ", response)
}
*responseStr = q5.EncodeJson(response)
return !G.MetaMgr.IsBlockZone(response.Country, response.Province, response.City)
*country = response.Country
*province = response.Province
*city = response.City
return true
}
func (this* RiskMgr) GetIpInfoByTx(
ip string,
responseStr* string,
country* string,
province* string,
city* string) bool {
txKey := ""
txSK := ""
G.MetaMgr.GetTxSdkInfo(&txKey, &txSK)
url := "https://apis.map.qq.com/ws/location/v1/ip"
sign := q5.Md5Str("/ws/location/v1/ip?" + "ip=" + ip + "&key=" + txKey + txSK)
params := q5.NewMxoObject()
params.SetXValue("ip", q5.NewXString(ip))
params.SetXValue("key", q5.NewXString(txKey))
params.SetXValue("sig", q5.NewXString(sign))
_, respStr, err := q5.HttpGetAsJson(
url,
params.AsXObject())
if err != nil {
f5.SysLog().Warning("GetIpInfoByTx error %s", err.Error())
return false
}
*responseStr = respStr
respObj := struct {
Status *int32 `json:"status"`
Result *struct {
AdInfo *struct {
Country string `json:"country"`
Province string `json:"province"`
City string `json:"city"`
} `json:"ad_info"`
} `json:"result"`
}{}
if err := json.Unmarshal([]byte(respStr), &respObj); err != nil || respObj.Status == nil {
f5.SysLog().Warning("GetIpInfoByTx response1 %s", respStr)
return false
}
if respObj.Result == nil {
f5.SysLog().Warning("GetIpInfoByTx response2 %s", respStr)
return false
}
if respObj.Result.AdInfo == nil {
f5.SysLog().Warning("GetIpInfoByTx response3 %s", respStr)
return false
}
*country = respObj.Result.AdInfo.Country
*province = respObj.Result.AdInfo.Province
*city = respObj.Result.AdInfo.City
return true
}

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit 562242ca3f859d2320252b3fce5bee06f055aa80
Subproject commit d82df9df793ddbd61123a186461372c740a1c254