punchnet-macos/Tun/Punchnet/Policy/IdentityRuleMap.swift
2026-02-05 23:13:37 +08:00

26 lines
495 B
Swift

//
// RuleMap.swift
// punchnet
//
// Created by on 2026/2/5.
//
struct IdentityRuleMap {
// map[proto][port]
let ruleMap: [UInt8: [UInt16: Bool]]
init(ruleMap: [UInt8: [UInt16: Bool]]) {
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
}
}
}