Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 /**
  * 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());
 }