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() {
//登录
sec := r.BuildSecStr()
// log.Printf("client secret key:%s", sec)
loginReg := &pb.UserLoginReq{
Sec: sec,
Account: r.opts.Account,
Sid: r.opts.ServerId,
}
head := &pb.UserMessage{
MainType: "user",
SubType: "login",
Sec: r.BuildSecStr(),
}
defer traceFunc(head.MainType, head.SubType, "0", 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)
case "pack":
r.handlePackMsg(msg)
case comm.MainType_Notify:
r.handleNotifyMsg(msg)
default:
log.Fatal("module route no exist")
}
@ -83,7 +85,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
//在这里添加玩家成功登录以后的测试方法
func (r *Robot) onUserLoaded() {
//user
r.CreateUser("乐谷616")
r.CreateUser("乐谷6171")
//friend
// r.FriendApply("1_62aa8f30d25fb8c1a7d90b50")
@ -102,6 +104,7 @@ func (r *Robot) onUserLoaded() {
}
func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error {
msg.Sec = r.BuildSecStr()
if comm.ProtoMarshal(rsp, msg) {
data, _ := proto.Marshal(msg)
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)
//登录
loginReg := &pb.UserLoginReq{
Sec: r.BuildSecStr(),
Account: account,
Sid: sid,
}
head := &pb.UserMessage{
MainType: "user",
SubType: "login",
Sec: r.BuildSecStr(),
}
err = r.SendToClient(head, loginReg)
if err != nil {

View File

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

View File

@ -2,18 +2,22 @@ package gateway
import (
"context"
"encoding/base64"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"sync"
"sync/atomic"
"time"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/container/id"
"github.com/golang/protobuf/ptypes"
"github.com/gorilla/websocket"
"github.com/tidwall/gjson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
)
/*
@ -70,7 +74,23 @@ locp:
go this.Close()
break locp
} 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)
@ -102,6 +122,46 @@ locp:
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 {
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{}
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{
@ -155,14 +215,16 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) {
Message: msg.Data,
}, reply); err != nil {
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
return
return err
}
if reply.Code != pb.ErrorCode_Success {
data, _ := ptypes.MarshalAny(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: reply.Code})
this.WriteMsg(&pb.UserMessage{
MainType: "notify",
SubType: "errornotify",
data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: reply.Code})
err := this.WriteMsg(&pb.UserMessage{
MainType: comm.MainType_Notify,
SubType: comm.SubType_ErrorNotify,
Data: data,
})
return err
}
return nil
}

View File

@ -11,6 +11,7 @@ import (
"go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db"
"reflect"
"time"
"go.mongodb.org/mongo-driver/bson"
"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格式的对象
// attrs 操作可选项目 eg.传入WithDisabledMgoLog() 表示关闭日志,否则开启;WithND() 传入表示插入操作不传表示更新前提不能传入传入WithDisabledMgoLog()
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 {
log.Errorf("set err:%v", err)
return err

View File

@ -1,40 +1,16 @@
package user
import (
"encoding/base64"
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/event"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/cache"
"go_dreamfactory/utils"
"time"
"github.com/tidwall/gjson"
"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) {
result = map[string]interface{}{}
@ -44,92 +20,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) {
var (
err error
db_user *pb.DB_UserData
err error
user *pb.DB_UserData
)
defer func() {
if db_user != nil {
session.SendMsg(string(this.module.GetType()), User_SubType_Login, &pb.UserLoginResp{
Data: db_user,
if user != nil {
err = session.SendMsg(string(this.module.GetType()), User_SubType_Login, &pb.UserLoginResp{
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) {
code = pb.ErrorCode_SecKeyInvalid
return
}
// user := decodeUserData(req.Sec)
user := decodeUserData(req.Sec)
db_user, err = this.module.modelUser.User_FindByAccount(user)
//从mgo查询user
user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account)
if err != nil {
if err != mongo.ErrNoDocuments {
return
}
}
cache_user := &pb.Cache_UserData{
SessionId: session.GetSessionId(),
GatewayServiceId: session.GetGatewayServiceId(),
}
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
if db_user == nil {
//新玩家
if user == nil {
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
err = this.module.modelUser.User_Create(user)
if err != nil {
log.Errorf("User_CreateUser err %v", err)
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 {
code = pb.ErrorCode_DBError
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 {
code = pb.ErrorCode_BindUser
return
}
data := &pb.Cache_UserData{
Uid: db_user.Uid,
SessionId: cache_user.SessionId,
GatewayServiceId: cache_user.GatewayServiceId,
}
// data := map[string]interface{}{
// "sessionId": cache_user.SessionId,
// "gatewayServiceId": cache_user.GatewayServiceId,
// }
err = this.module.modelSession.SetObj(db_user.Uid, data, cache.WithDisabledMgoLog())
if err != nil {
code = pb.ErrorCode_DBError
return
}
}
err = this.module.modelUser.SetObj(db_user.Uid, db_user)
if err != nil {
code = pb.ErrorCode_DBError
return
}
//bind user
err = session.Bind(user.Uid, this.service.GetId())
if err != nil {
code = pb.ErrorCode_BindUser
return
}
//set user other info
user.Logintime = time.Now().Unix()
user.Lastloginip = session.GetIP()
user.Createip = session.GetIP()
//缓存user session
err = this.module.modelSession.SetObj(user.Uid, &pb.Cache_UserData{
Uid: user.Uid,
SessionId: session.GetSessionId(),
GatewayServiceId: session.GetGatewayServiceId(),
},
cache.WithExpire(time.Hour*12),
cache.WithDisabledMgoLog())
if err != nil {
code = pb.ErrorCode_DBError
return
}
//缓存user
err = this.module.modelUser.SetObj(user.Uid, user)
if err != nil {
code = pb.ErrorCode_DBError
return
}
return

View File

@ -27,10 +27,10 @@ func (this *ModelUser) Init(service core.IService, module core.IModule, comp cor
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{
"sid": user.Sid,
"binduid": user.Binduid,
"sid": sid,
"binduid": account,
}
sr := this.DB.FindOne(DB_UserTable, filter)
var nd *pb.DB_UserData

View File

@ -27,9 +27,11 @@ type UserMessage struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
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 的处理函数
Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data"`
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 的处理函数
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() {
@ -85,6 +87,13 @@ func (x *UserMessage) GetData() *anypb.Any {
return nil
}
func (x *UserMessage) GetSec() string {
if x != nil {
return x.Sec
}
return ""
}
//代理用户转发消息结构
type AgentMessage struct {
state protoimpl.MessageState
@ -173,7 +182,7 @@ func (x *AgentMessage) GetMessage() *anypb.Any {
return nil
}
//RPC 服务固定回复结构
// RPC 服务固定回复结构
type RPCMessageReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -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,
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,
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,
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, 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,
0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e,
0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72,
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61,
0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 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, 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,
0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67,
0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65,
0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 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,
0x41, 0x6e, 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, 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 (

View File

@ -4,64 +4,62 @@ import "errorcode.proto";
import "google/protobuf/any.proto";
//
message UserMessage {
string MainType =1; // :user user的模块
string SubType = 2; // :login user的模块中 api_login
google.protobuf.Any data = 3;
message UserMessage {
string MainType = 1; // :user user的模块
string SubType = 2; // :login user的模块中
// api_login
google.protobuf.Any data = 3;
string sec = 4; //
}
//
message AgentMessage {
string Ip = 1;
string UserSessionId = 2;
string UserId = 3;
string GatewayServiceId = 4;
string Method = 5;
google.protobuf.Any Message = 6;
string Ip = 1;
string UserSessionId = 2;
string UserId = 3;
string GatewayServiceId = 4;
string Method = 5;
google.protobuf.Any Message = 6;
}
//RPC
// RPC
message RPCMessageReply {
ErrorCode Code = 1;
string Message = 2;
string Data = 3;
ErrorCode Code = 1;
string Message = 2;
string Data = 3;
}
//Uid请求
message AgentBuildReq {
string UserSessionId = 1;
string UserId = 2;
string WorkerId = 3;
string UserSessionId = 1;
string UserId = 2;
string WorkerId = 3;
}
//
message AgentUnBuildReq {
string UserSessionId = 1;
}
message AgentUnBuildReq { string UserSessionId = 1; }
//
message AgentSendMessageReq {
string UserSessionId = 1;
string MainType = 2;
string SubType = 3;
google.protobuf.Any Data = 4;
string UserSessionId = 1;
string MainType = 2;
string SubType = 3;
google.protobuf.Any Data = 4;
}
//
message BatchMessageReq {
repeated string UserSessionIds = 1;
string MainType = 2;
string SubType = 3;
google.protobuf.Any Data = 4;
repeated string UserSessionIds = 1;
string MainType = 2;
string SubType = 3;
google.protobuf.Any Data = 4;
}
//广
message BroadCastMessageReq {
string MainType = 1; //
string SubType = 2;
google.protobuf.Any Data = 3;
string MainType = 1; //
string SubType = 2;
google.protobuf.Any Data = 3;
}
//
message AgentCloseeReq {
string UserSessionId = 1;
}
message AgentCloseeReq { string UserSessionId = 1; }

View File

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

View File

@ -26,7 +26,8 @@ type UserLoginReq struct {
sizeCache protoimpl.SizeCache
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() {
@ -61,13 +62,20 @@ func (*UserLoginReq) Descriptor() ([]byte, []int) {
return file_user_user_msg_proto_rawDescGZIP(), []int{0}
}
func (x *UserLoginReq) GetSec() string {
func (x *UserLoginReq) GetAccount() string {
if x != nil {
return x.Sec
return x.Account
}
return ""
}
func (x *UserLoginReq) GetSid() int32 {
if x != nil {
return x.Sid
}
return 0
}
type UserLoginResp struct {
state protoimpl.MessageState
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,
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,
0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x20, 0x0a, 0x0c, 0x55, 0x73,
0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65,
0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0x31, 0x0a, 0x0d,
0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42,
0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,
0x3d, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52,
0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03,
0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x4b,
0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73,
0x70, 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, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32, 0x0a, 0x0b, 0x55,
0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65,
0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,
0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71,
0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 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,
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, 0x18, 0x0a, 0x07, 0x61, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x31, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f,
0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44,
0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3d, 0x0a, 0x0f, 0x55, 0x73, 0x65,
0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07,
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x22, 0x4b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 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, 0x61,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61,
0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44,
0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69,
0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69,
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 (

View File

@ -1,8 +1,12 @@
package cache
import "fmt"
import (
"fmt"
"time"
)
const (
ATTR_EXPIRE = "expire"
ATTR_MGOLOG = "mgolog"
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))
}
//缓存过期时间设置
func WithExpire(t time.Duration) *OperationAttr {
return &OperationAttr{
Name: ATTR_EXPIRE,
Value: t,
}
}
//禁用Mgolog操作
func WithDisabledMgoLog() *OperationAttr {
return &OperationAttr{
Name: ATTR_MGOLOG,
@ -39,6 +52,7 @@ func WithDisabledMgoLog() *OperationAttr {
}
}
//新记录插入操作
func WithND() *OperationAttr {
return &OperationAttr{
Name: ATTR_INSERT,

View File

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