Exemplo n.º 1
0
        private System.Net.IPAddress ResolveListenIP(RouteMapConfigurationItem routeSetting)
        {
            if (!string.IsNullOrEmpty(routeSetting.ListenIP))
            {
                IPAddress ret = null;
                if (IPAddress.TryParse(routeSetting.ListenIP, out ret))
                {
                    return(ret);
                }
                ret = Dns.GetHostAddresses(routeSetting.ListenIP).FirstOrDefault();
                if (ret != null)
                {
                    return(ret);
                }
            }
            // don't use localhost/127.0.0.1 as that is short-circuited in loopback adapter
            var addrs = Dns.GetHostAddresses(Environment.MachineName);

            foreach (var addr in addrs)
            {
                if (!addr.IsIPv6LinkLocal && !addr.IsIPv6Multicast &&
                    !addr.IsIPv6SiteLocal && !addr.IsIPv6Teredo)
                {
                    return(addr);
                }
            }
            return(addrs.First());
        }
Exemplo n.º 2
0
 private string ResolveTargetHost(RouteMapConfigurationItem routeSetting)
 {
     if (!string.IsNullOrEmpty(routeSetting.TargetHost))
     {
         return(routeSetting.TargetHost);
     }
     return(ResolveListenIP(routeSetting).ToString());
 }
Exemplo n.º 3
0
 private int ResolveTargetPort(RouteMapConfigurationItem routeSetting)
 {
     if (!string.IsNullOrEmpty(routeSetting.TargetPort))
     {
         return(int.Parse(routeSetting.TargetPort));
     }
     return(int.Parse(routeSetting.ListenPort));
 }
Exemplo n.º 4
0
 private string ResolveRouteName(RouteMapConfigurationItem routeSetting)
 {
     if (!string.IsNullOrEmpty(routeSetting.RouteName))
     {
         return(routeSetting.RouteName);
     }
     return(ResolveListenIP(routeSetting).ToString() + ":" + routeSetting.ListenPort.ToString());
 }