Rework DNS and routes in network extension
The DNS resolver prior had useless comments, awful nesting, converted bytes into strings and back into bytes, and generally made no sense. That's been rewritten now. But more fundumentally, this commit made the DNS resolver actually accomplish its objective, by passing AI_ALL to it. It turns out, though, that the Go library isn't actually using GAI in the way we need for parsing IP addresses, so we actually need to do another round, this time with hints flag as zero, so that we get the DNS64 address. Additionally, since we're now binding sockets to interfaces, we can entirely remove the excludedRoutes logic. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -17,6 +17,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
networkMonitor?.cancel()
|
||||
}
|
||||
|
||||
//swiftlint:disable:next function_body_length
|
||||
override func startTunnel(options: [String: NSObject]?, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
|
||||
let activationAttemptId = options?["activationAttemptId"] as? String
|
||||
let errorNotifier = ErrorNotifier(activationAttemptId: activationAttemptId)
|
||||
@@ -65,6 +66,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
if getsockopt(fileDescriptor, 2 /* SYSPROTO_CONTROL */, 2 /* UTUN_OPT_IFNAME */, ifnamePtr, &ifnameSize) == 0 {
|
||||
self.ifname = String(cString: ifnamePtr)
|
||||
}
|
||||
ifnamePtr.deallocate()
|
||||
wg_log(.info, message: "Tunnel interface is \(self.ifname ?? "unknown")")
|
||||
let handle = self.packetTunnelSettingsGenerator!.uapiConfiguration().withGoString { return wgTurnOn($0, fileDescriptor) }
|
||||
if handle < 0 {
|
||||
|
||||
Reference in New Issue
Block a user