This commit is contained in:
liwei1dao 2022-06-17 18:43:36 +08:00
commit 3f9a16e01e
14 changed files with 327 additions and 240 deletions

View File

@ -33,15 +33,16 @@ func (r *Robot) BuildSecStr() string {
//处理登录请求 //处理登录请求
func (r *Robot) AccountLogin() { func (r *Robot) AccountLogin() {
//登录 //登录
sec := r.BuildSecStr()
// log.Printf("client secret key:%s", sec) // log.Printf("client secret key:%s", sec)
loginReg := &pb.UserLoginReq{ loginReg := &pb.UserLoginReq{
Sec: sec, Account: r.opts.Account,
Sid: r.opts.ServerId,
} }
head := &pb.UserMessage{ head := &pb.UserMessage{
MainType: "user", MainType: "user",
SubType: "login", SubType: "login",
Sec: r.BuildSecStr(),
} }
defer traceFunc(head.MainType, head.SubType, "0", loginReg) defer traceFunc(head.MainType, head.SubType, "0", loginReg)
err := r.SendToClient(head, loginReg) err := r.SendToClient(head, loginReg)

26
cmd/robot/notify.go Normal file
View File

@ -0,0 +1,26 @@
package robot
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//统一通知处理
func (r *Robot) handleNotifyMsg(msg *pb.UserMessage) {
switch msg.SubType {
case comm.SubType_ErrorNotify:
r.handleError(msg)
default:
fmt.Printf("subType: %s not define", msg.SubType)
}
}
//处理错误
func (r *Robot) handleError(msg *pb.UserMessage) {
rsp := &pb.ErrorNotify{}
if !comm.ProtoUnmarshal(msg, rsp) {
return
}
printReply(msg, rsp)
}

View File

@ -75,6 +75,8 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
r.handleFriendMsg(msg) r.handleFriendMsg(msg)
case "pack": case "pack":
r.handlePackMsg(msg) r.handlePackMsg(msg)
case comm.MainType_Notify:
r.handleNotifyMsg(msg)
default: default:
log.Fatal("module route no exist") log.Fatal("module route no exist")
} }
@ -83,7 +85,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
//在这里添加玩家成功登录以后的测试方法 //在这里添加玩家成功登录以后的测试方法
func (r *Robot) onUserLoaded() { func (r *Robot) onUserLoaded() {
//user //user
r.CreateUser("乐谷616") r.CreateUser("乐谷6171")
//friend //friend
// r.FriendApply("1_62aa8f30d25fb8c1a7d90b50") // r.FriendApply("1_62aa8f30d25fb8c1a7d90b50")
@ -102,6 +104,7 @@ func (r *Robot) onUserLoaded() {
} }
func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error { func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error {
msg.Sec = r.BuildSecStr()
if comm.ProtoMarshal(rsp, msg) { if comm.ProtoMarshal(rsp, msg) {
data, _ := proto.Marshal(msg) data, _ := proto.Marshal(msg)
return r.ws.WriteMessage(websocket.BinaryMessage, data) return r.ws.WriteMessage(websocket.BinaryMessage, data)
@ -138,12 +141,14 @@ func (r *Robot) AccountRegister(account string, sid int32) {
fmt.Printf("account:%s 注册成功", regRsp.Account) fmt.Printf("account:%s 注册成功", regRsp.Account)
//登录 //登录
loginReg := &pb.UserLoginReq{ loginReg := &pb.UserLoginReq{
Sec: r.BuildSecStr(), Account: account,
Sid: sid,
} }
head := &pb.UserMessage{ head := &pb.UserMessage{
MainType: "user", MainType: "user",
SubType: "login", SubType: "login",
Sec: r.BuildSecStr(),
} }
err = r.SendToClient(head, loginReg) err = r.SendToClient(head, loginReg)
if err != nil { if err != nil {

View File

@ -8,7 +8,6 @@ import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/anypb"
) )
@ -22,6 +21,12 @@ const (
Service_Worker = "worker" Service_Worker = "worker"
) )
//ERR
const (
MainType_Notify = "notify" //通知
SubType_ErrorNotify = "errornotify" //错误通知
)
//模块名定义处 //模块名定义处
const ( const (
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块

View File

@ -2,18 +2,22 @@ package gateway
import ( import (
"context" "context"
"encoding/base64"
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/container/id" "go_dreamfactory/lego/utils/container/id"
"github.com/golang/protobuf/ptypes"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/tidwall/gjson"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
) )
/* /*
@ -70,7 +74,23 @@ locp:
go this.Close() go this.Close()
break locp break locp
} else { } else {
this.messageDistribution(msg) err = this.secAuth(msg)
if err == nil {
if err := this.messageDistribution(msg); err != nil {
go this.Close()
break locp
}
} else {
data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode_SecKeyInvalid})
if err = this.WriteMsg(&pb.UserMessage{
MainType: comm.MainType_Notify,
SubType: comm.SubType_ErrorNotify,
Data: data,
}); err != nil {
go this.Close()
break locp
}
}
} }
} }
log.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId) log.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId)
@ -102,6 +122,46 @@ locp:
log.Debugf("agent:%s uId:%s writeLoop end!", this.sessionId, this.uId) log.Debugf("agent:%s uId:%s writeLoop end!", this.sessionId, this.uId)
} }
//安全认证 所有协议
func (this *Agent) secAuth(msg *pb.UserMessage) error {
if !utils.ValidSecretKey(msg.Sec) { //验证失败
return fmt.Errorf("key invalid")
}
return decodeUserData(msg)
}
//解码
func decodeUserData(msg *pb.UserMessage) error {
//只有login的时候才需要解码
if msg.MainType == "user" && msg.SubType == "login" {
base64Str := msg.Sec
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
if err != nil {
log.Errorf("base64 decode err %v", err)
return nil
}
now := time.Now().Unix()
jsonRet := gjson.Parse(string(dec))
serverId := jsonRet.Get("serverId").Int()
timestamp := jsonRet.Get("timestamp").Int()
if now-time.Unix(timestamp, 0).Unix() > 100 {
return nil
}
account := jsonRet.Get("account").String()
req := &pb.UserLoginReq{
Account: account,
Sid: int32(serverId),
}
ad, err := anypb.New(req)
if err != nil {
return err
}
msg.Data = ad
}
return nil
}
func (this *Agent) SessionId() string { func (this *Agent) SessionId() string {
return this.sessionId return this.sessionId
} }
@ -143,7 +203,7 @@ func (this *Agent) Close() {
} }
//分发用户消息 //分发用户消息
func (this *Agent) messageDistribution(msg *pb.UserMessage) { func (this *Agent) messageDistribution(msg *pb.UserMessage) error {
reply := &pb.RPCMessageReply{} reply := &pb.RPCMessageReply{}
log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
if err := this.gateway.Service().RpcCall(context.Background(), comm.Service_Worker, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{ if err := this.gateway.Service().RpcCall(context.Background(), comm.Service_Worker, string(comm.Rpc_GatewayRoute), &pb.AgentMessage{
@ -155,14 +215,16 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) {
Message: msg.Data, Message: msg.Data,
}, reply); err != nil { }, reply); err != nil {
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err) log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
return return err
} }
if reply.Code != pb.ErrorCode_Success { if reply.Code != pb.ErrorCode_Success {
data, _ := ptypes.MarshalAny(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: reply.Code}) data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: reply.Code})
this.WriteMsg(&pb.UserMessage{ err := this.WriteMsg(&pb.UserMessage{
MainType: "notify", MainType: comm.MainType_Notify,
SubType: "errornotify", SubType: comm.SubType_ErrorNotify,
Data: data, Data: data,
}) })
return err
} }
return nil
} }

View File

@ -11,6 +11,7 @@ import (
"go_dreamfactory/sys/cache" "go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"reflect" "reflect"
"time"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
@ -108,7 +109,8 @@ func (this *Model_Comp) UpdateModelLogs(table string, uID string, where bson.M,
//data 值允许protobuf格式的对象 //data 值允许protobuf格式的对象
// attrs 操作可选项目 eg.传入WithDisabledMgoLog() 表示关闭日志,否则开启;WithND() 传入表示插入操作不传表示更新前提不能传入传入WithDisabledMgoLog() // attrs 操作可选项目 eg.传入WithDisabledMgoLog() 表示关闭日志,否则开启;WithND() 传入表示插入操作不传表示更新前提不能传入传入WithDisabledMgoLog()
func (this *Model_Comp) SetObj(uid string, data proto.Message, attrs ...*cache.OperationAttr) error { func (this *Model_Comp) SetObj(uid string, data proto.Message, attrs ...*cache.OperationAttr) error {
err := this.Redis.Set(this.ukey(uid), data, 0) expr := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(time.Second * 0).(time.Duration)
err := this.Redis.Set(this.ukey(uid), data, expr)
if err != nil { if err != nil {
log.Errorf("set err:%v", err) log.Errorf("set err:%v", err)
return err return err

View File

@ -1,40 +1,16 @@
package user package user
import ( import (
"encoding/base64"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/cache" "go_dreamfactory/sys/cache"
"go_dreamfactory/utils"
"time" "time"
"github.com/tidwall/gjson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
) )
//解码
func decodeUserData(base64Str string) *pb.DB_UserData {
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
if err != nil {
log.Errorf("base64 decode err %v", err)
return nil
}
now := time.Now().Unix()
jsonRet := gjson.Parse(string(dec))
serverId := jsonRet.Get("serverId").Int()
timestamp := jsonRet.Get("timestamp").Int()
if now-time.Unix(timestamp, 0).Unix() > 100 {
return nil
}
account := jsonRet.Get("account").String()
return &pb.DB_UserData{
Sid: int32(serverId),
Binduid: account,
}
}
//参数校验 //参数校验
func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) { func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) {
result = map[string]interface{}{} result = map[string]interface{}{}
@ -45,92 +21,72 @@ func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.UserLoginRe
func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) { func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) {
var ( var (
err error err error
db_user *pb.DB_UserData user *pb.DB_UserData
) )
defer func() { defer func() {
if db_user != nil { if user != nil {
session.SendMsg(string(this.module.GetType()), User_SubType_Login, &pb.UserLoginResp{ err = session.SendMsg(string(this.module.GetType()), User_SubType_Login, &pb.UserLoginResp{
Data: db_user, Data: user,
}) })
event.TriggerEvent(comm.Event_UserLogin, db_user.Uid) if err != nil {
code = pb.ErrorCode_SystemError
return
}
event.TriggerEvent(comm.Event_UserLogin, user.Uid)
} }
}() }()
if !utils.ValidSecretKey(req.Sec) { // user := decodeUserData(req.Sec)
code = pb.ErrorCode_SecKeyInvalid
return
}
user := decodeUserData(req.Sec) //从mgo查询user
user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account)
db_user, err = this.module.modelUser.User_FindByAccount(user)
if err != nil { if err != nil {
if err != mongo.ErrNoDocuments { if err != mongo.ErrNoDocuments {
return return
} }
} }
cache_user := &pb.Cache_UserData{ if user == nil {
SessionId: session.GetSessionId(),
GatewayServiceId: session.GetGatewayServiceId(),
}
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面 //如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
if db_user == nil {
//新玩家
err = this.module.modelUser.User_Create(user) err = this.module.modelUser.User_Create(user)
if err != nil { if err != nil {
log.Errorf("User_CreateUser err %v", err) log.Errorf("User_CreateUser err %v", err)
return return
} }
session.Bind(user.Uid, this.service.GetId())
// data := map[string]interface{}{
// "sessionId": cache_user.SessionId,
// "gatewayServiceId": cache_user.GatewayServiceId,
// }
data := &pb.Cache_UserData{
Uid: user.Uid,
SessionId: cache_user.SessionId,
GatewayServiceId: cache_user.GatewayServiceId,
} }
err = this.module.modelSession.SetObj(cache_user.Uid, data)
if err != nil { //bind user
code = pb.ErrorCode_DBError err = session.Bind(user.Uid, this.service.GetId())
return
}
err = this.module.modelUser.SetObj(cache_user.Uid, user, cache.WithND())
if err != nil {
code = pb.ErrorCode_DBError
return
}
} else {
err := session.Bind(db_user.Uid, this.service.GetId())
if err != nil { if err != nil {
code = pb.ErrorCode_BindUser code = pb.ErrorCode_BindUser
return return
} }
data := &pb.Cache_UserData{
Uid: db_user.Uid, //set user other info
SessionId: cache_user.SessionId, user.Logintime = time.Now().Unix()
GatewayServiceId: cache_user.GatewayServiceId, user.Lastloginip = session.GetIP()
} user.Createip = session.GetIP()
// data := map[string]interface{}{
// "sessionId": cache_user.SessionId, //缓存user session
// "gatewayServiceId": cache_user.GatewayServiceId, err = this.module.modelSession.SetObj(user.Uid, &pb.Cache_UserData{
// } Uid: user.Uid,
err = this.module.modelSession.SetObj(db_user.Uid, data, cache.WithDisabledMgoLog()) SessionId: session.GetSessionId(),
GatewayServiceId: session.GetGatewayServiceId(),
},
cache.WithExpire(time.Hour*12),
cache.WithDisabledMgoLog())
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
err = this.module.modelUser.SetObj(db_user.Uid, db_user) //缓存user
err = this.module.modelUser.SetObj(user.Uid, user)
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
}
return return
} }

View File

@ -27,10 +27,10 @@ func (this *ModelUser) Init(service core.IService, module core.IModule, comp cor
return return
} }
func (this *ModelUser) User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) { func (this *ModelUser) User_FindByAccount(sid int32, account string) (*pb.DB_UserData, error) {
filter := bson.M{ filter := bson.M{
"sid": user.Sid, "sid": sid,
"binduid": user.Binduid, "binduid": account,
} }
sr := this.DB.FindOne(DB_UserTable, filter) sr := this.DB.FindOne(DB_UserTable, filter)
var nd *pb.DB_UserData var nd *pb.DB_UserData

View File

@ -28,8 +28,10 @@ type UserMessage struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType"` //用户消息处理 模块名 例如:user 对应项目中 user的模块 MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType"` //用户消息处理 模块名 例如:user 对应项目中 user的模块
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType"` //用户消息处理函数名 例如:login 对应项目中 user的模块中 api_login 的处理函数 SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType"` //用户消息处理函数名 例如:login 对应项目中 user的模块中
// api_login 的处理函数
Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data"` Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data"`
Sec string `protobuf:"bytes,4,opt,name=sec,proto3" json:"sec"` //密文
} }
func (x *UserMessage) Reset() { func (x *UserMessage) Reset() {
@ -85,6 +87,13 @@ func (x *UserMessage) GetData() *anypb.Any {
return nil return nil
} }
func (x *UserMessage) GetSec() string {
if x != nil {
return x.Sec
}
return ""
}
//代理用户转发消息结构 //代理用户转发消息结构
type AgentMessage struct { type AgentMessage struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -611,75 +620,76 @@ var file_comm_proto_rawDesc = []byte{
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72,
0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61,
0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7f, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54,
0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54,
0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e,
0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x04,
0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70,
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65,
0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01,
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69,
0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x4d, 0x65, 0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05,
0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5f, 0x0a, 0x0f, 0x52, 0x50,
0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a,
0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a,
0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18,
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x69, 0x0a, 0x0d, 0x41,
0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x57, 0x6f,
0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x57, 0x6f,
0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x55,
0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22,
0x9b, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a,
0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62,
0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54,
0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 0x01,
0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65,
0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69,
0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69,
0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12,
0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5f, 0x0a, 0x0f,
0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12,
0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e,
0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x69, 0x0a,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24,
0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18,
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e,
0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55,
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
0x64, 0x22, 0x9b, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53,
0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75,
0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22,
0x99, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d,
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d,
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70,
0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42,
0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52,
0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61,
0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65,
0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73,
0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View File

@ -6,8 +6,10 @@ import "google/protobuf/any.proto";
// //
message UserMessage { message UserMessage {
string MainType = 1; // :user user的模块 string MainType = 1; // :user user的模块
string SubType = 2; // :login user的模块中 api_login string SubType = 2; // :login user的模块中
// api_login
google.protobuf.Any data = 3; google.protobuf.Any data = 3;
string sec = 4; //
} }
// //
@ -34,9 +36,7 @@ message AgentBuildReq {
string WorkerId = 3; string WorkerId = 3;
} }
// //
message AgentUnBuildReq { message AgentUnBuildReq { string UserSessionId = 1; }
string UserSessionId = 1;
}
// //
message AgentSendMessageReq { message AgentSendMessageReq {
@ -62,6 +62,4 @@ message BroadCastMessageReq {
} }
// //
message AgentCloseeReq { message AgentCloseeReq { string UserSessionId = 1; }
string UserSessionId = 1;
}

View File

@ -5,7 +5,8 @@ import "user/user_db.proto";
// //
message UserLoginReq { message UserLoginReq {
string sec = 1; // string account = 1; //
int32 sid = 2; //
} }
message UserLoginResp { DB_UserData data = 1; } message UserLoginResp { DB_UserData data = 1; }

View File

@ -26,7 +26,8 @@ type UserLoginReq struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Sec string `protobuf:"bytes,1,opt,name=sec,proto3" json:"sec"` //密文 Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account"` //账号
Sid int32 `protobuf:"varint,2,opt,name=sid,proto3" json:"sid"` //区服编号
} }
func (x *UserLoginReq) Reset() { func (x *UserLoginReq) Reset() {
@ -61,13 +62,20 @@ func (*UserLoginReq) Descriptor() ([]byte, []int) {
return file_user_user_msg_proto_rawDescGZIP(), []int{0} return file_user_user_msg_proto_rawDescGZIP(), []int{0}
} }
func (x *UserLoginReq) GetSec() string { func (x *UserLoginReq) GetAccount() string {
if x != nil { if x != nil {
return x.Sec return x.Account
} }
return "" return ""
} }
func (x *UserLoginReq) GetSid() int32 {
if x != nil {
return x.Sid
}
return 0
}
type UserLoginResp struct { type UserLoginResp struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -364,29 +372,31 @@ var file_user_user_msg_proto_rawDesc = []byte{
0x0a, 0x13, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x0a, 0x13, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65,
0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, 0x0a, 0x0c, 0x55, 0x73, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3a, 0x0a, 0x0c, 0x55, 0x73,
0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63,
0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0x31, 0x0a, 0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63,
0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x31, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f,
0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x3d, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44,
0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3d, 0x0a, 0x0f, 0x55, 0x73, 0x65,
0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07,
0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x4b, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20,
0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x4b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72,
0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43,
0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f,
0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61,
0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61,
0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44,
0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69,
0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View File

@ -1,8 +1,12 @@
package cache package cache
import "fmt" import (
"fmt"
"time"
)
const ( const (
ATTR_EXPIRE = "expire"
ATTR_MGOLOG = "mgolog" ATTR_MGOLOG = "mgolog"
ATTR_INSERT = "insert" ATTR_INSERT = "insert"
@ -32,6 +36,15 @@ func (this OperationAttrs) Find(name string) *InterfaceResult {
return NewInterfaceResult(nil, fmt.Errorf("Operationattrs not found err: %v", name)) return NewInterfaceResult(nil, fmt.Errorf("Operationattrs not found err: %v", name))
} }
//缓存过期时间设置
func WithExpire(t time.Duration) *OperationAttr {
return &OperationAttr{
Name: ATTR_EXPIRE,
Value: t,
}
}
//禁用Mgolog操作
func WithDisabledMgoLog() *OperationAttr { func WithDisabledMgoLog() *OperationAttr {
return &OperationAttr{ return &OperationAttr{
Name: ATTR_MGOLOG, Name: ATTR_MGOLOG,
@ -39,6 +52,7 @@ func WithDisabledMgoLog() *OperationAttr {
} }
} }
//新记录插入操作
func WithND() *OperationAttr { func WithND() *OperationAttr {
return &OperationAttr{ return &OperationAttr{
Name: ATTR_INSERT, Name: ATTR_INSERT,

View File

@ -29,9 +29,6 @@ func ValidSecretKey(secStr string) bool {
clientMd5Key := secStr[3:35] clientMd5Key := secStr[3:35]
rawmsg := secStr[35:] rawmsg := secStr[35:]
log.Debugf("data base: %s", rawmsg) log.Debugf("data base: %s", rawmsg)
serverMd5Key := MD5Str(rawmsg) serverMd5Key := MD5Str(rawmsg) //这里可以再加上客户端和服务端的秘钥再MD5
if !strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) { return strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key))
return false
}
return true
} }