fix Policy Rule

This commit is contained in:
anlicheng 2026-05-21 12:27:13 +08:00
parent f9f018630c
commit def15bd3c9
3 changed files with 7 additions and 7 deletions

View File

@ -1,11 +1,11 @@
//
// RuleMap.swift
// PolicyRuleMap.swift
// punchnet
//
// Created by on 2026/2/5.
//
struct IdentityRuleMap {
struct PolicyRuleMap {
let version: UInt32
// map[proto][port]
let ruleMap: [UInt8: [UInt16: Bool]]

View File

@ -9,13 +9,13 @@ import Foundation
final class PolicyRuleSnapshot: Snapshot {
typealias IdentityID = UInt32
private let ruleMapByIdentity: [IdentityID: IdentityRuleMap]
private let ruleMapByIdentity: [IdentityID: PolicyRuleMap]
init(ruleMapByIdentity: [IdentityID : IdentityRuleMap]) {
init(ruleMapByIdentity: [IdentityID : PolicyRuleMap]) {
self.ruleMapByIdentity = ruleMapByIdentity
}
func lookup(_ id: IdentityID) -> IdentityRuleMap? {
func lookup(_ id: IdentityID) -> PolicyRuleMap? {
return self.ruleMapByIdentity[id]
}

View File

@ -19,7 +19,7 @@ actor PolicyRuleStore {
nonisolated private let alloctor = ByteBufferAllocator()
private let publisher: SnapshotPublisher<PolicyRuleSnapshot>
private var ruleMapByIdentity: [UInt32: IdentityRuleMap] = [:]
private var ruleMapByIdentity: [UInt32: PolicyRuleMap] = [:]
init(publisher: SnapshotPublisher<PolicyRuleSnapshot>) {
self.publisher = publisher
@ -74,7 +74,7 @@ actor PolicyRuleStore {
}
ruleMap[proto, default: [:]][port] = true
}
self.ruleMapByIdentity[id] = IdentityRuleMap(version: version, ruleMap: ruleMap)
self.ruleMapByIdentity[id] = PolicyRuleMap(version: version, ruleMap: ruleMap)
//
let snapshot = compileSnapshot()