31 lines
705 B
Go
31 lines
705 B
Go
package app
|
|
|
|
import (
|
|
"proxy-server/gateway/core"
|
|
)
|
|
|
|
var (
|
|
Id int32
|
|
Name string
|
|
PlatformSecret string // 平台密钥,验证接收的请求是否属于平台
|
|
|
|
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)
|
|
}
|