26 lines
497 B
Swift
26 lines
497 B
Swift
//
|
|
// RuleMap.swift
|
|
// punchnet
|
|
//
|
|
// Created by 安礼成 on 2026/2/5.
|
|
//
|
|
|
|
struct IdentityRuleMap {
|
|
let ruleMap: [UInt32: [UInt32: UInt8]]
|
|
|
|
init(ruleMap: [UInt32: [UInt32: UInt8]]) {
|
|
self.ruleMap = ruleMap
|
|
}
|
|
|
|
func isAllow(proto: UInt32, port: UInt32) -> Bool {
|
|
if let portMap = self.ruleMap[proto],
|
|
let allowed = portMap[port],
|
|
allowed > 0 {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
}
|