private AdvDnsClient GetDns() { string ip = Config.Dns.Server; int timeout = Config.Dns.Timeout; if (string.IsNullOrWhiteSpace(ip)) { Logger.Config("Take the default DNS configured on this host"); return(new AdvDnsClient(DnsClient.Default)); } Logger.Config("Take the configured DNS: {0} with timeout {1}", ip, timeout); return(new AdvDnsClient(IPAddress.Parse(ip), timeout)); }
private IPAddress[] GetDefaultNetworkInfo(out IPAddress ipv4, out IPAddress ipv6) { IPAddress[] ips = Advtools.AdvInterceptor.Network.GetIpsByWmi(); ipv4 = null; ipv6 = null; foreach (IPAddress ip in ips) { if (ipv4 == null && ip.AddressFamily == AddressFamily.InterNetwork) { Logger.Config("Default IPv4 address is {0}", ip); ipv4 = ip; } if (ipv6 == null && ip.AddressFamily == AddressFamily.InterNetworkV6) { Logger.Config("Default IPv6 address is {0}", ip); ipv6 = ip; } if (ipv4 != null && ipv6 != null) { break; } } if (ipv4 == null) { Logger.Warning("No valid default IPv4 address found, take the loopback"); ipv4 = IPAddress.Loopback; } if (ipv6 == null) { Logger.Warning("No valid default IPv6 address found, take the loopback"); ipv6 = IPAddress.IPv6Loopback; } return(ips); }