Add methods to remove WireGuard default gateways

This commit is contained in:
Davide De Rosa 2022-09-14 18:42:13 +02:00
parent e2aaffc06f
commit 0db3f52931
1 changed files with 12 additions and 0 deletions

View File

@ -177,6 +177,18 @@ extension WireGuard {
}
}
public mutating func removeDefaultGateways(fromPeer peerIndex: Int) {
peers[peerIndex].allowedIPs.removeAll {
$0 == Self.defaultGateway4 || $0 == Self.defaultGateway6
}
}
public mutating func removeAllDefaultGateways() {
peers.indices.forEach {
removeDefaultGateways(fromPeer: $0)
}
}
public mutating func addAllowedIP(_ allowedIP: String, toPeer peerIndex: Int) {
guard let addr = IPAddressRange(from: allowedIP) else {
return