punchnet-macos/Tun/Punchnet/Policy/IdentityRuleMap.swift
2026-02-15 00:34:40 +08:00

28 lines
567 B
Swift

//
// RuleMap.swift
// punchnet
//
// Created by on 2026/2/5.
//
struct IdentityRuleMap {
let version: UInt32
// map[proto][port]
let ruleMap: [UInt8: [UInt16: Bool]]
init(version: UInt32, ruleMap: [UInt8: [UInt16: Bool]]) {
self.version = version
self.ruleMap = ruleMap
}
func isAllow(proto: UInt8, port: UInt16) -> Bool {
if let portMap = self.ruleMap[proto],
let allowed = portMap[port] {
return allowed
} else {
return false
}
}
}