private void ReloadResolver(DnsCryptProxyType dnsCryptProxyType) { if (dnsCryptProxyType == DnsCryptProxyType.Primary) { if (_primaryResolver != null) { PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter = ConvertProxyEntryToParameter( _primaryResolver, DnsCryptProxyType.Primary); if (PrimaryDnsCryptProxyManager.WriteRegistry(DnsCryptProxyType.Primary)) { if (PrimaryDnsCryptProxyManager.IsDnsCryptProxyInstalled()) { RestartService(DnsCryptProxyType.Primary); } } } } else { if (_secondaryResolver != null) { SecondaryDnsCryptProxyManager.DnsCryptProxy.Parameter = ConvertProxyEntryToParameter(_secondaryResolver, DnsCryptProxyType.Secondary); if (SecondaryDnsCryptProxyManager.WriteRegistry(DnsCryptProxyType.Secondary)) { if (SecondaryDnsCryptProxyManager.IsDnsCryptProxyInstalled()) { RestartService(DnsCryptProxyType.Secondary); } } } } }
private async void HandleGlobalResolver(bool actAsGlobalGateway) { IsWorkingOnPrimaryService = true; if (actAsGlobalGateway) { PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalAddress = Global.GlobalGatewayAddress; PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalPort = Global.PrimaryResolverPort; PrimaryDnsCryptProxyManager.WriteRegistry(DnsCryptProxyType.Primary); await Task.Run(() => { PrimaryDnsCryptProxyManager.Restart(); }).ConfigureAwait(false); Thread.Sleep(Global.ServiceRestartTime); _isPrimaryResolverRunning = PrimaryDnsCryptProxyManager.IsDnsCryptProxyRunning(); NotifyOfPropertyChange(() => IsPrimaryResolverRunning); PrimaryResolverTitle = string.Format("{0} ({1}:{2})", LocalizationEx.GetUiString("default_settings_primary_header", Thread.CurrentThread.CurrentCulture), Global.GlobalGatewayAddress, Global.PrimaryResolverPort); } else { PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalAddress = Global.PrimaryResolverAddress; PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalPort = Global.PrimaryResolverPort; PrimaryDnsCryptProxyManager.WriteRegistry(DnsCryptProxyType.Primary); await Task.Run(() => { PrimaryDnsCryptProxyManager.Restart(); }).ConfigureAwait(false); Thread.Sleep(Global.ServiceRestartTime); _isPrimaryResolverRunning = PrimaryDnsCryptProxyManager.IsDnsCryptProxyRunning(); NotifyOfPropertyChange(() => IsPrimaryResolverRunning); PrimaryResolver.LocalPort = Global.PrimaryResolverPort; // reset the resolver port PrimaryResolverTitle = string.Format("{0}", LocalizationEx.GetUiString("default_settings_primary_header", Thread.CurrentThread.CurrentCulture)); } IsWorkingOnPrimaryService = false; }