fix Policy Rule
This commit is contained in:
parent
f9f018630c
commit
def15bd3c9
@ -1,11 +1,11 @@
|
|||||||
//
|
//
|
||||||
// RuleMap.swift
|
// PolicyRuleMap.swift
|
||||||
// punchnet
|
// punchnet
|
||||||
//
|
//
|
||||||
// Created by 安礼成 on 2026/2/5.
|
// Created by 安礼成 on 2026/2/5.
|
||||||
//
|
//
|
||||||
|
|
||||||
struct IdentityRuleMap {
|
struct PolicyRuleMap {
|
||||||
let version: UInt32
|
let version: UInt32
|
||||||
// map[proto][port]
|
// map[proto][port]
|
||||||
let ruleMap: [UInt8: [UInt16: Bool]]
|
let ruleMap: [UInt8: [UInt16: Bool]]
|
||||||
@ -9,13 +9,13 @@ import Foundation
|
|||||||
final class PolicyRuleSnapshot: Snapshot {
|
final class PolicyRuleSnapshot: Snapshot {
|
||||||
typealias IdentityID = UInt32
|
typealias IdentityID = UInt32
|
||||||
|
|
||||||
private let ruleMapByIdentity: [IdentityID: IdentityRuleMap]
|
private let ruleMapByIdentity: [IdentityID: PolicyRuleMap]
|
||||||
|
|
||||||
init(ruleMapByIdentity: [IdentityID : IdentityRuleMap]) {
|
init(ruleMapByIdentity: [IdentityID : PolicyRuleMap]) {
|
||||||
self.ruleMapByIdentity = ruleMapByIdentity
|
self.ruleMapByIdentity = ruleMapByIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
func lookup(_ id: IdentityID) -> IdentityRuleMap? {
|
func lookup(_ id: IdentityID) -> PolicyRuleMap? {
|
||||||
return self.ruleMapByIdentity[id]
|
return self.ruleMapByIdentity[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ actor PolicyRuleStore {
|
|||||||
nonisolated private let alloctor = ByteBufferAllocator()
|
nonisolated private let alloctor = ByteBufferAllocator()
|
||||||
|
|
||||||
private let publisher: SnapshotPublisher<PolicyRuleSnapshot>
|
private let publisher: SnapshotPublisher<PolicyRuleSnapshot>
|
||||||
private var ruleMapByIdentity: [UInt32: IdentityRuleMap] = [:]
|
private var ruleMapByIdentity: [UInt32: PolicyRuleMap] = [:]
|
||||||
|
|
||||||
init(publisher: SnapshotPublisher<PolicyRuleSnapshot>) {
|
init(publisher: SnapshotPublisher<PolicyRuleSnapshot>) {
|
||||||
self.publisher = publisher
|
self.publisher = publisher
|
||||||
@ -74,7 +74,7 @@ actor PolicyRuleStore {
|
|||||||
}
|
}
|
||||||
ruleMap[proto, default: [:]][port] = true
|
ruleMap[proto, default: [:]][port] = true
|
||||||
}
|
}
|
||||||
self.ruleMapByIdentity[id] = IdentityRuleMap(version: version, ruleMap: ruleMap)
|
self.ruleMapByIdentity[id] = PolicyRuleMap(version: version, ruleMap: ruleMap)
|
||||||
|
|
||||||
// 发布新的快照信息
|
// 发布新的快照信息
|
||||||
let snapshot = compileSnapshot()
|
let snapshot = compileSnapshot()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user