public override String getLocalHostName() { if (localHostname == null) { List <String> names = new List <String>(); names.AddRange(DomainUtil.getComputerHostNames()); names.Add(Dns.GetHostEntry("").HostName); names.Add(Dns.GetHostName()); foreach (String name in names) { if (!name.StartsWith("localhost") && !Regex.IsMatch(name, "^([0-9]{1,3}\\.){3}[0-9]{1,3}$")) { localHostname = name.EndsWith(".") ? name : (name + "."); break; } } } if (localHostname == null) { throw new Exception("UnknownHostException"); } return(localHostname); }
/** * Try to figure out the domain name(s) for the computer. * This includes reverse subnet addresses, as described in RFC 6763 chapter 11. * @return a list of potential domain names. */ public List <String> getComputerDomains() { return(DomainUtil.getComputerDomains()); }