Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Jul 6, 2023
1 parent f6728ac commit 79a4ea5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func getNetworkInterfaceAddresses() -> [String] {
var interface = interfaces
while interface != nil {
// Only consider IPv4 interfaces.
if interface?.pointee.ifa_addr.pointee.sa_family == UInt8(AF_INET) {
if interface!.pointee.ifa_addr.pointee.sa_family == UInt8(AF_INET) {
let addr = interface!.pointee.ifa_addr!.withMemoryRebound(to: sockaddr_in.self, capacity: 1) { $0.pointee.sin_addr }
if let ip = String(cString: inet_ntoa(addr), encoding: .utf8) {
addresses.append(ip)
Expand Down Expand Up @@ -129,13 +129,13 @@ func selectVpnAddress(interfaceAddresses: [String]) -> String {
}
}
}
if candidates.isEmpty {
guard !candidates.isEmpty else {
// Even though there is an interface bound to the subnet candidates, the collision probability
// with an actual address is low.
return kVpnSubnetCandidates.randomElement()?.value ?? ""
return kVpnSubnetCandidates.randomElement()!.value
}
// Select a random subnet from the remaining candidates.
return candidates.randomElement()?.value ?? ""
return candidates.randomElement()!.value
}

let kExcludedSubnets = [
Expand Down

0 comments on commit 79a4ea5

Please sign in to comment.