I inserted a breakpoint where the app calls NETunnelProviderManager.loadAllFromPreferences
, and it called the completion with only one value, so there are no other active providers on the device. When I looked for a place where we set tunnelRemoteAddress
, I found this bit of code in WireGuardKit:
func generateNetworkSettings() -> NEPacketTunnelNetworkSettings {
/* iOS requires a tunnel endpoint, whereas in WireGuard it's valid for
* a tunnel to have no endpoint, or for there to be many endpoints, in
* which case, displaying a single one in settings doesn't really
* make sense. So, we fill it in with this placeholder, which is not
* a valid IP address that will actually route over the Internet.
*/
let networkSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
For one, WireGuardKit is an external dependency of the application, so going through the necessary steps to change it would be possible, but more difficult than just changing a value. When I overrode this piece of code on my machine to set it to the remote endpoint's address, however, I noticed that the connections were still timing out and the issue was not fixed.
These are the only logs in Console that I see in the extension related to the network connection. The "cancelled" messages are due to the application timing out the connection and trying again. Originally the timeout was set to 60s, I moved it down to 10s to make it easier to see in the logs:
5657 default 10:53:58.307219+0200 MyNetworkExtension [C6 687052A1-4CA6-430A-9EA9-D39FD8E7F92E Hostname#dddc988d:443 tcp, tls, attribution: developer, context: Default Network Context (private), proc: 58CA1BEC-474A-365D-857F-027B884B9BED, required interface: utun3(16)] start
5657 default 10:53:58.308305+0200 MyNetworkExtension [C6 Hostname#dddc988d:443 initial path ((null))] event: path:start @0.000s
5657 default 10:53:58.309396+0200 MyNetworkExtension [C6 Hostname#dddc988d:443 waiting path (unsatisfied (Interface utun3[16] is required by parameters), interface: en0, scoped, ipv4, ipv6, dns)] event: path:unsatisfied @0.000s, uuid: D2339D03-2826-47AE-88E8-D122D0F78EB0
5657 default 10:53:58.309731+0200 MyNetworkExtension nw_connection_report_state_with_handler_on_nw_queue [C6] reporting state waiting
5657 default 10:53:58.311177+0200 MyNetworkExtension [C6 Hostname#dddc988d:443 waiting path (unsatisfied (Interface utun3[16] is required by parameters), interface: en0, scoped, ipv4, ipv6, dns)] event: null:null @0.001s
5657 default 10:53:58.312155+0200 MyNetworkExtension [C7 15EA8717-040A-4634-BE44-9168217C792C Hostname#e7bf2ee1:443 tcp, tls, attribution: developer, context: Default Network Context (private), proc: 58CA1BEC-474A-365D-857F-027B884B9BED, required interface: utun3(16)] start
5657 default 10:53:58.312637+0200 MyNetworkExtension [C7 Hostname#e7bf2ee1:443 initial path ((null))] event: path:start @0.000s
5657 default 10:53:58.313308+0200 MyNetworkExtension [C7 Hostname#e7bf2ee1:443 waiting path (unsatisfied (Interface utun3[16] is required by parameters), interface: en0, scoped, ipv4, ipv6, dns)] event: path:unsatisfied @0.002s, uuid: D9AFA7E1-4F51-46AD-BC30-0DC0A8BD9C68
5657 default 10:53:58.313453+0200 MyNetworkExtension nw_connection_report_state_with_handler_on_nw_queue [C7] reporting state waiting
5657 default 10:53:58.314203+0200 MyNetworkExtension [C7 Hostname#e7bf2ee1:443 waiting path (unsatisfied (Interface utun3[16] is required by parameters), interface: en0, scoped, ipv4, ipv6, dns)] event: null:null @0.002s
5657 default 10:53:58.910804+0200 MyNetworkExtension [C8 866110BB-E8A4-4239-8B55-82EBA9A396CC Hostname#dddc988d:443 tcp, tls, attribution: developer, context: Default Network Context (private), proc: 58CA1BEC-474A-365D-857F-027B884B9BED, required interface: utun3(16)] start
5657 default 10:53:58.911659+0200 MyNetworkExtension [C8 Hostname#dddc988d:443 initial path ((null))] event: path:start @0.000s
5657 default 10:53:58.912632+0200 MyNetworkExtension [C8 Hostname#dddc988d:443 waiting path (unsatisfied (Interface utun3[16] is required by parameters), interface: en0, scoped, ipv4, ipv6, dns)] event: path:unsatisfied @0.000s, uuid: D2339D03-2826-47AE-88E8-D122D0F78EB0
5657 default 10:53:58.912796+0200 MyNetworkExtension nw_connection_report_state_with_handler_on_nw_queue [C8] reporting state waiting
5657 default 10:53:58.914132+0200 MyNetworkExtension [C8 Hostname#dddc988d:443 waiting path (unsatisfied (Interface utun3[16] is required by parameters), interface: en0, scoped, ipv4, ipv6, dns)] event: null:null @0.002s
5657 default 10:54:07.321548+0200 MyNetworkExtension [C6 687052A1-4CA6-430A-9EA9-D39FD8E7F92E Hostname#dddc988d:443 tcp, interface: utun3, tls, attribution: developer] cancel
5657 default 10:54:07.321672+0200 MyNetworkExtension [C6 Hostname#dddc988d:443 tcp, interface: utun3, tls, attribution: developer] cancelled
5657 default 10:54:07.322047+0200 MyNetworkExtension nw_connection_report_state_with_handler_on_nw_queue [C6] reporting state cancelled
5657 error 10:54:07.323093+0200 MyNetworkExtension -[NWTCPConnection setupEventHandler]_block_invoke Connection went away while waiting for event
5657 default 10:54:07.323945+0200 MyNetworkExtension [C7 15EA8717-040A-4634-BE44-9168217C792C Hostname#e7bf2ee1:443 tcp, interface: utun3, tls, attribution: developer] cancel
5657 default 10:54:07.324302+0200 MyNetworkExtension [C7 Hostname#e7bf2ee1:443 tcp, interface: utun3, tls, attribution: developer] cancelled
5657 default 10:54:07.325110+0200 MyNetworkExtension nw_connection_report_state_with_handler_on_nw_queue [C7] reporting state cancelled
5657 error 10:54:07.325596+0200 MyNetworkExtension -[NWTCPConnection setupEventHandler]_block_invoke Connection went away while waiting for event