From eb1f3c91749da3d14de5f44b18002367e87cf70b Mon Sep 17 00:00:00 2001 From: Ivan Ilin Date: Tue, 9 Jul 2019 19:29:29 +0300 Subject: [PATCH 1/2] fix issue with jumping dns server selection --- .../AdguardApp/Services/APVPNManager.m | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/AdguardExtension/AdguardApp/Services/APVPNManager.m b/AdguardExtension/AdguardApp/Services/APVPNManager.m index 9c0ec854e..0b15d5a29 100644 --- a/AdguardExtension/AdguardApp/Services/APVPNManager.m +++ b/AdguardExtension/AdguardApp/Services/APVPNManager.m @@ -45,7 +45,6 @@ @implementation APVPNManager{ ACLExecuteBlockDelayed *_delayedSendNotify; NETunnelProviderManager *_manager; - NETunnelProviderProtocol *_protocolConfiguration; NSMutableArray *_observers; BOOL _enabled; @@ -572,12 +571,10 @@ - (void)loadConfiguration{ } _manager = nil; - _protocolConfiguration = nil; } else { _manager = managers[0]; - _protocolConfiguration = (NETunnelProviderProtocol *)_manager.protocolConfiguration; } } } @@ -615,14 +612,11 @@ - (void)updateConfigurationForRemoteServer:(DnsServerInfo *)remoteServer tunnelM remoteServer = self.defaultServer; } - NETunnelProviderProtocol *protocol; + NETunnelProviderProtocol *protocol = (NETunnelProviderProtocol *)_manager.protocolConfiguration; NETunnelProviderManager *newManager; - if (_protocolConfiguration) { - protocol = _protocolConfiguration; - } - else{ - + if (!protocol) + { protocol = [NETunnelProviderProtocol new]; protocol.providerBundleIdentifier = AP_TUNNEL_ID; } @@ -707,7 +701,6 @@ - (void)removeVpnConfiguration { } _manager = nil; - _protocolConfiguration = nil; } } @@ -723,7 +716,8 @@ - (void)setStatuses{ if (_manager) { - NSData *remoteDnsServerData = _protocolConfiguration.providerConfiguration[APVpnManagerParameterRemoteDnsServer]; + NETunnelProviderProtocol * protocolConfiguration = (NETunnelProviderProtocol *)_manager.protocolConfiguration; + NSData *remoteDnsServerData = protocolConfiguration.providerConfiguration[APVpnManagerParameterRemoteDnsServer]; // Getting current settings from configuration. //If settings are incorrect, then we assign default values. @@ -734,14 +728,14 @@ - (void)setStatuses{ _resources.activeDnsServer = _activeDnsServer; [self willChangeValueForKey:@"tunnelMode"]; - _tunnelMode = _protocolConfiguration.providerConfiguration[APVpnManagerParameterTunnelMode] ? - [_protocolConfiguration.providerConfiguration[APVpnManagerParameterTunnelMode] unsignedIntValue] : APVpnManagerTunnelModeSplit; + _tunnelMode = protocolConfiguration.providerConfiguration[APVpnManagerParameterTunnelMode] ? + [protocolConfiguration.providerConfiguration[APVpnManagerParameterTunnelMode] unsignedIntValue] : APVpnManagerTunnelModeSplit; [self didChangeValueForKey:@"tunnelMode"]; //------------- - _restartByReachability = _protocolConfiguration.providerConfiguration[APVpnManagerRestartByReachability] ? - [_protocolConfiguration.providerConfiguration[APVpnManagerRestartByReachability] boolValue] : NO; // NO by default + _restartByReachability = protocolConfiguration.providerConfiguration[APVpnManagerRestartByReachability] ? + [protocolConfiguration.providerConfiguration[APVpnManagerRestartByReachability] boolValue] : NO; // NO by default NSString *connectionStatusReason = @"Unknown"; @@ -818,7 +812,9 @@ - (void)attachToNotifications{ if(!error) { DDLogInfo(@"(APVPNManager) Notify that vpn configuration changed."); - [self setStatuses]; + dispatch_sync(workingQueue, ^{ + [self setStatuses]; + }); } else { DDLogError(@"(APVPNManager) Error loading vpn configuration: %@, %ld, %@", error.domain, error.code, error.localizedDescription); _lastError = _standartError; @@ -838,7 +834,9 @@ - (void)attachToNotifications{ if(!error) { DDLogInfo(@"(APVPNManager) Notify that vpn connection status changed."); - [self setStatuses]; + dispatch_sync(workingQueue, ^{ + [self setStatuses]; + }); } else { DDLogError(@"(APVPNManager) Error loading vpn configuration: %@, %ld, %@", error.domain, error.code, error.localizedDescription); _lastError = _standartError; From 503252cb2be9511ecac5c327c602ee94e09bcd50 Mon Sep 17 00:00:00 2001 From: Ivan Ilin Date: Tue, 9 Jul 2019 19:32:07 +0300 Subject: [PATCH 2/2] version up --- AdguardExtension/Adguard-Config.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdguardExtension/Adguard-Config.xcconfig b/AdguardExtension/Adguard-Config.xcconfig index 3c61d50a4..912b63c23 100644 --- a/AdguardExtension/Adguard-Config.xcconfig +++ b/AdguardExtension/Adguard-Config.xcconfig @@ -19,7 +19,7 @@ // Global product settings AG_PRODUCT = AdGuard AG_VERSION = 3.0.1 -AG_BUILD = 155 +AG_BUILD = 156 // URL scheme for receiving commands in Adguard main app from Safari ADGUARD_URL_SCHEME = adguard