Beispiel #1
0
        public HostInfo FindFirstNonLoopbackHostInfo()
        {
            var address = FindFirstNonLoopbackAddress();

            if (address != null)
            {
                return(ConvertAddress(address));
            }

            HostInfo hostInfo = new HostInfo();

            hostInfo.Hostname  = _options.DefaultHostname;
            hostInfo.IpAddress = _options.DefaultIpAddress;
            return(hostInfo);
        }
Beispiel #2
0
        public virtual HostInfo FindFirstNonLoopbackHostInfo()
        {
            var address = FindFirstNonLoopbackAddress();

            if (address != null)
            {
                return(ConvertAddress(address));
            }

            var hostInfo = new HostInfo
            {
                Hostname  = _options.DefaultHostname,
                IpAddress = _options.DefaultIpAddress
            };

            return(hostInfo);
        }
Beispiel #3
0
        internal HostInfo ConvertAddress(IPAddress address)
        {
            HostInfo hostInfo = new HostInfo();
            string   hostname;

            try
            {
                var hostEntry = Dns.GetHostEntry(address);
                hostname = hostEntry.HostName;
            }
            catch (Exception e)
            {
                _logger?.LogInformation(e, "Cannot determine local hostname");
                hostname = "localhost";
            }

            hostInfo.Hostname  = hostname;
            hostInfo.IpAddress = address.ToString();
            return(hostInfo);
        }