28 lines
567 B
Swift
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
|
|
}
|
|
}
|
|
|
|
}
|