重命名客户端相关术语为节点;移动 utils 包到根路径;优化网关对节点各种连接状态的处理,并在节点断联后统一清理资源

This commit is contained in:
2025-05-17 10:00:28 +08:00
parent 20ac7dbd91
commit 84e01d3b50
14 changed files with 150 additions and 129 deletions

View File

@@ -9,7 +9,22 @@ var (
Name string
PlatformSecret string // 平台密钥,验证接收的请求是否属于平台
Clients = core.SyncMap[int32, uint16]{} // 节点 ID -> 转发端口
Edges = core.SyncMap[int32, uint16]{} // 节点 ID -> 转发端口
Assigns = core.SyncMap[uint16, int32]{} // 转发端口 -> 节点 ID
Permits = core.SyncMap[uint16, *core.Permit]{} // 转发端口 -> 权限配置
)
func AddEdge(id int32, port uint16) {
Edges.Store(id, port)
Assigns.Store(port, id)
}
func DelEdge(port uint16) {
id, _ := Assigns.LoadAndDelete(port)
Edges.Delete(id)
Permits.Delete(port)
}
func PermitEdge(port uint16, permit *core.Permit) {
Permits.Store(port, permit)
}