Ejemplo n.º 1
0
        public IPAddress CalculateServerIPAddress()
        {
            // if there is override address, use it
            var overrideIPAddress = WebServerIPAddress;

            if ((overrideIPAddress != null) && (!overrideIPAddress.Equals(IPAddress.Any)))
            {
                return(overrideIPAddress);
            }

            var ipAddresses = GetIPv4Addresses(NetworkInterfaceType.Unknown, true, false);

            var hsAddress = IPAddress.Parse(HS.GetIPAddress());

            // if nothing is specified and hs address is in local addresses, us it
            if (ipAddresses.Contains(hsAddress))
            {
                return(hsAddress);
            }

            if (ipAddresses.Length == 0)
            {
                throw new IOException("No Local IP4 Address Found");
            }
            return(ipAddresses.First());
        }