重命名客户端相关术语为节点;移动 utils 包到根路径;优化网关对节点各种连接状态的处理,并在节点断联后统一清理资源
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user