ca证书
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"omc/omc"
|
||||
|
||||
"github.com/aceld/zinx/ziface"
|
||||
"github.com/aceld/zinx/zlog"
|
||||
"github.com/aceld/zinx/znet"
|
||||
"omc/omc"
|
||||
)
|
||||
|
||||
// HeartBeatApi 心跳请求
|
||||
@@ -38,7 +37,6 @@ func (*HeartBeatApi) Handle(request ziface.IRequest) {
|
||||
Msg: make(map[string]string, 0),
|
||||
}
|
||||
ackBody.Msg["reqId"] = reqId
|
||||
ackBody.Keys = append(ackBody.Keys, "reqId")
|
||||
ackBody.Pack()
|
||||
request.GetConnection().SendMsg(omc.AckHeartBeat, ackBody.RawData)
|
||||
}
|
||||
|
||||
21
api/login.go
21
api/login.go
@@ -92,6 +92,19 @@ func (*CMCALoginSeq) Handle(request ziface.IRequest) {
|
||||
}
|
||||
ackBody.Msg["seqNo"] = seqNo
|
||||
ackBody.Pack()
|
||||
m := core.GetManager(request.GetConnection().GetName())
|
||||
uID, err := request.GetConnection().GetProperty("UID")
|
||||
if err != nil {
|
||||
zlog.Ins().ErrorF("GetProperty UID error %s", err)
|
||||
request.GetConnection().Stop()
|
||||
return
|
||||
}
|
||||
if m == nil {
|
||||
zlog.Ins().ErrorF("server internal error")
|
||||
request.GetConnection().SendMsg(omc.AckLoginAlarm, omc.ErrorMsg("ackLoginAlarm", "", "server internal error"))
|
||||
return
|
||||
}
|
||||
m.SetSeqNo(uID.(string), seqNo)
|
||||
|
||||
request.GetConnection().SendMsg(omc.AckCMCALoginSeq, ackBody.RawData)
|
||||
}
|
||||
@@ -118,9 +131,10 @@ func (*CMCALoginAlarm) Handle(request ziface.IRequest) {
|
||||
}
|
||||
|
||||
user, userOK := msgBody.Msg["user"]
|
||||
pw, pwOK := msgBody.Msg["key"]
|
||||
key, keyOK := msgBody.Msg["key"]
|
||||
cert, certOK := msgBody.Msg["cert"]
|
||||
tp, tpOK := msgBody.Msg["type"]
|
||||
if !userOK || !pwOK || !tpOK {
|
||||
if !userOK || !keyOK || certOK || !tpOK {
|
||||
zlog.Ins().ErrorF("missing parameter of message body")
|
||||
request.GetConnection().SendMsg(omc.AckLoginAlarm, omc.ErrorMsg("ackLoginAlarm", "", "missing parameter of message body"))
|
||||
return
|
||||
@@ -139,7 +153,8 @@ func (*CMCALoginAlarm) Handle(request ziface.IRequest) {
|
||||
}
|
||||
|
||||
//登录信息check
|
||||
if err := service.UserLogin(user, pw); err != nil {
|
||||
seqNo := m.GetUserByPID(uID.(string)).SeqNo
|
||||
if ok, err := service.CMCALogin(seqNo, key, cert); !ok || err != nil {
|
||||
zlog.Ins().ErrorF("LoginFail %s", err)
|
||||
request.GetConnection().SendMsg(omc.AckLoginAlarm, omc.ErrorMsg("ackLoginAlarm", "", "Incorrect username and password"))
|
||||
isClose, _ := m.LoginFail(uID.(string)) //登录错误超过3次,断开连接
|
||||
|
||||
Reference in New Issue
Block a user