feat 网关鉴权

This commit is contained in:
2025-12-22 18:04:36 +08:00
parent 69cc960fe5
commit 670140e7d3
68 changed files with 1424 additions and 492 deletions

View File

@@ -7,33 +7,33 @@ import (
var UserMgr *userManager
type userManager struct {
userMap map[int32]*Client
userMap map[int64]*Client
sync.RWMutex
}
func init() {
UserMgr = &userManager{
userMap: make(map[int32]*Client),
userMap: make(map[int64]*Client),
}
}
func (m *userManager) Add(uid int32, client *Client) {
func (m *userManager) Add(usn int64, client *Client) {
m.Lock()
defer m.Unlock()
m.userMap[uid] = client
m.userMap[usn] = client
}
func (m *userManager) Delete(uid int32) {
func (m *userManager) Delete(usn int64) {
m.Lock()
defer m.Unlock()
delete(m.userMap, uid)
delete(m.userMap, usn)
}
func (m *userManager) GetAll() map[int32]*Client {
func (m *userManager) GetAll() map[int64]*Client {
m.RLock()
defer m.RUnlock()
copyMap := make(map[int32]*Client, len(m.userMap))
copyMap := make(map[int64]*Client, len(m.userMap))
for k, v := range m.userMap {
copyMap[k] = v
}
@@ -51,8 +51,8 @@ func (m *userManager) GetAllInterface() []interface{} {
return r
}
func (m *userManager) GetByUID(uid int32) *Client {
func (m *userManager) GetByUSN(usn int64) *Client {
m.RLock()
defer m.RUnlock()
return m.userMap[uid]
return m.userMap[usn]
}