NE: Handle bad domain names and Activate On Demand

This combination causes iOS to keep trying to bring up the tunnel,
leading to a lot of displayMessage() alerts.

In this fix, if we get a DNS resolution error in an Activate On Demand
enabled tunnel, we silently retry 9 times (with a 4-second delay before
each retry) and then show the displayMessage() alert.

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-12-19 15:38:00 +05:30
parent 04a8c2ff5a
commit fa51e3f1d1
4 changed files with 59 additions and 19 deletions
@@ -18,8 +18,12 @@ class ErrorNotifier {
switch error {
case .savedProtocolConfigurationIsInvalid:
return ("Activation failure", "Could not retrieve tunnel information from the saved configuration")
case .dnsResolutionFailure:
return ("DNS resolution failure", "One or more endpoint domains could not be resolved")
case .dnsResolutionFailure(let tunnelName, let isActivateOnDemandEnabled):
if isActivateOnDemandEnabled {
return ("DNS resolution failure", "This tunnel has Activate On Demand enabled, so activation might be retried. You may turn off Activate On Demand in the WireGuard app by navigating to: '\(tunnelName)' > Edit")
} else {
return ("DNS resolution failure", "One or more endpoint domains could not be resolved")
}
case .couldNotStartWireGuard:
return ("Activation failure", "WireGuard backend could not be started")
case .coultNotSetNetworkSettings: