private void UpdateDnsServersIfNeeded() { if ((IPBanService.UtcNow - lastDnsServersUpdate) > dnsServerUpdateInterval) { try { dnsServers = new HashSet <IPAddress>(NetworkUtility.GetLocalDnsServers()); lastDnsServersUpdate = IPBanService.UtcNow; } catch (Exception ex) { Logger.Error(ex); } } }
private void UpdateDnsServersIfNeeded() { if ((IPBanService.UtcNow - lastDnsServersUpdate) > dnsServerUpdateInterval) { try { HashSet <IPAddress> newDnsServers = new HashSet <IPAddress>(NetworkUtility.GetLocalDnsServers()); foreach (var ip in Dns.GetHostAddresses(Dns.GetHostName())) { newDnsServers.Add(ip); } dnsServers = newDnsServers; lastDnsServersUpdate = IPBanService.UtcNow; } catch (Exception ex) { Logger.Error(ex); } } }