private void GetHostAddressesCallback(IAsyncResult ar) { // Make sure the request was still relevant if ((ar.AsyncState as string) != Text) { try { _ = Dns.EndGetHostAddresses(ar); } catch { } return; } Resolving = false; IpAddresses = null; try { IpAddresses = Dns.EndGetHostAddresses(ar).Where(a => a.AddressFamily == AddressFamily.InterNetwork || a.AddressFamily == AddressFamily.InterNetworkV6); } catch (SocketException) { } if (IpAddresses == null || !IpAddresses.Any()) { OnResolveFailed(Text); ForeColor = ErrorForeColor; return; } ResolvedSuccessfully = true; OnResolveSuccessful(Text, IpAddresses); }
public bool IsWhitelisted(IPAddress ip) { return(IpAddresses.Any(x => x.Equals(ip))); }