feat: improve operations diagnostics and channel management

This commit is contained in:
hectorzhao
2026-08-09 14:27:19 +08:00
parent 44352aeb2f
commit 4724b9db6a
65 changed files with 1211 additions and 293 deletions
+14 -10
View File
@@ -13,10 +13,12 @@ import (
)
type authRequest struct {
Account string `json:"account"`
AuthSource string `json:"authSource"`
Timestamp uint32 `json:"timestamp"`
RemoteIP string `json:"remoteIp,omitempty"`
Account string `json:"account"`
AuthSource string `json:"authSource"`
Timestamp uint32 `json:"timestamp"`
RemoteIP string `json:"remoteIp,omitempty"`
Version string `json:"version"`
RequestedVersion uint8 `json:"requestedVersion"`
}
type authResponse struct {
@@ -42,7 +44,7 @@ func (s Server) handleLogin(response *cmpp.Response, packet *cmpp.Packet, logger
setInboundConnectResponse(response.Packer, cmpp.ErrnoConnVerTooHigh, req.AuthSrc, "", cmpp.V30)
return false, cmpp.ConnRspStatusErrMap[cmpp.ErrnoConnVerTooHigh]
}
auth, err := s.authenticate(packet.Conn.Conn.RemoteAddr(), account, req.AuthSrc, req.Timestamp)
auth, err := s.authenticate(packet.Conn.Conn.RemoteAddr(), account, req.AuthSrc, req.Timestamp, req.Version)
if err != nil {
logger.Printf("cmpp inbound auth failed account=%s remote=%s err=%v", account, packet.Conn.Conn.RemoteAddr(), err)
setInboundConnectResponse(response.Packer, cmpp.ErrnoConnAuthFailed, req.AuthSrc, "", req.Version)
@@ -114,12 +116,14 @@ func cmppVersionName(version cmpp.Type) string {
}
}
func (s Server) authenticate(remote net.Addr, account string, authSource string, timestamp uint32) (authResponse, error) {
func (s Server) authenticate(remote net.Addr, account string, authSource string, timestamp uint32, version cmpp.Type) (authResponse, error) {
payload := authRequest{
Account: account,
AuthSource: base64.StdEncoding.EncodeToString([]byte(authSource)),
Timestamp: timestamp,
RemoteIP: remoteIP(remote),
Account: account,
AuthSource: base64.StdEncoding.EncodeToString([]byte(authSource)),
Timestamp: timestamp,
RemoteIP: remoteIP(remote),
Version: cmppVersionName(version),
RequestedVersion: uint8(version),
}
var result authResponse
err := s.post(context.Background(), "/gateway/events/inbound/authenticate", payload, &result)