public string CheckExternalHostName() { if (!m_CheckDynDns && !String.IsNullOrEmpty(m_lastExternalHostName)) { /* no recheck */ } else if (m_externalHostName == "SYSTEMIP") { if (DateTime.UtcNow - m_lastResolverTime > TimeSpan.FromMinutes(1)) { string newIP = Util.GetLocalHost().ToString(); lock (this) { if (newIP != m_lastExternalHostName && m_lastExternalHostName != string.Empty) { m_IPChanged = true; } if (newIP != m_lastExternalHostName || m_lastExternalHostName == string.Empty) { m_log.InfoFormat( "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}", m_externalHostName, m_regionName); } m_lastExternalHostName = newIP; m_lastResolverTime = DateTime.UtcNow; } } } else if (m_CheckDynDns) { if (DateTime.UtcNow - m_lastResolverTime > TimeSpan.FromMinutes(1)) { try { string newIP = Util.GetHostFromDNS(m_externalHostName).ToString(); lock (this) { if (newIP != m_lastExternalHostName && m_lastExternalHostName != string.Empty) { m_IPChanged = true; m_lastExternalHostName = newIP; } m_lastResolverTime = DateTime.UtcNow; } } catch { } } return(m_externalHostName); } else { m_lastExternalHostName = m_externalHostName; } return(m_lastExternalHostName); }
public bool ResolveDNS() { IPAddress ip = Util.GetHostFromDNS(Host); if (ip == null) { return(false); } return(true); }
public OSHTTPURI(string uri, bool withDNSResolve = false) { Flags = OSHTTPURIFlags.None; Port = -1; IP = null; Host = string.Empty; URI = string.Empty; URL = string.Empty; Path = string.Empty; if (string.IsNullOrEmpty(uri)) { return; } try { Uri m_checkuri = new Uri(uri); if (m_checkuri.Scheme != Uri.UriSchemeHttp && m_checkuri.Scheme != Uri.UriSchemeHttps) { return; } Flags = OSHTTPURIFlags.ValidHost; Host = m_checkuri.DnsSafeHost.ToLowerInvariant(); Port = m_checkuri.Port; Path = m_checkuri.AbsolutePath; if (Path[Path.Length - 1] == '/') { Path = Path.Substring(0, Path.Length - 1); } URL = m_checkuri.Scheme + "://" + Host + ":" + Port; URI = URL + Path; if (withDNSResolve) { IPAddress ip = Util.GetHostFromDNS(Host); if (ip != null) { IP = ip; Flags = OSHTTPURIFlags.ValidResolved; } } } catch { Flags = OSHTTPURIFlags.None; IP = null; URI = string.Empty; } }
public bool ResolveDNS() { IPAddress ip = Util.GetHostFromDNS(Host); if (ip == null) { Flags &= ~OSHTTPURIFlags.Resolved; return(false); } Flags |= OSHTTPURIFlags.Resolved; return(true); }
public static RegionInfo Create(UUID regionID, string regionName, uint regX, uint regY, string externalHostName, uint httpPort, uint simPort, uint remotingPort, string serverURI) { RegionInfo regionInfo; IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(externalHostName), (int)simPort); regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalHostName); regionInfo.RemotingPort = remotingPort; regionInfo.RemotingAddress = externalHostName; regionInfo.HttpPort = httpPort; regionInfo.RegionID = regionID; regionInfo.RegionName = regionName; regionInfo.ServerURI = serverURI; return(regionInfo); }
public bool ResolveDNS() { if ((Flags & URIFlags.HasHost) != 0) { IPAddress ip = Util.GetHostFromDNS(Host); if (ip != null) { IP = ip; Flags |= URIFlags.HasResolvedHost; return(true); } } return(false); }
public OSHTTPURI(string uri, bool withDNSResolve = false) { Host = string.Empty; Port = -1; m_URI = string.Empty; Path = string.Empty; HostType = UriHostNameType.Unknown; IP = null; if (string.IsNullOrEmpty(uri)) { return; } try { Uri m_checkuri = new Uri(uri); if (m_checkuri.Scheme != Uri.UriSchemeHttp && m_checkuri.Scheme != Uri.UriSchemeHttps) { return; } Host = m_checkuri.DnsSafeHost.ToLowerInvariant(); HostType = m_checkuri.HostNameType; Port = m_checkuri.Port; Path = m_checkuri.AbsolutePath; if (Path[Path.Length - 1] == '/') { Path = Path.Substring(0, Path.Length - 1); } m_URI = m_checkuri.Scheme + "://" + Host + ":" + Port + Path; if (withDNSResolve) { IPAddress ip = Util.GetHostFromDNS(Host); if (ip != null) { IP = ip; } } } catch { HostType = UriHostNameType.Unknown; IP = null; } }
public OSHHTPHost(string url, bool withDNSResolve = false) { Flags = OSHTTPURIFlags.Empty; Port = 80; IP = null; Host = string.Empty; URI = string.Empty; bool secureHTTP = false; if (string.IsNullOrEmpty(url)) { return; } Flags = OSHTTPURIFlags.None; url = url.ToLowerInvariant(); try { int urllen = url.Length; if (url[urllen - 1] == '/') { --urllen; } int start; if (url.StartsWith("http")) { if (url[4] == 's') { start = 8; secureHTTP = true; } else { start = 7; } } else { start = 0; } string host; UriHostNameType type; int indx = url.IndexOf(':', start, urllen - start); if (indx > 0) { host = url.Substring(start, indx - start); type = Uri.CheckHostName(host); if (type == UriHostNameType.Unknown || type == UriHostNameType.Basic) { return; } ++indx; string sport = url.Substring(indx, urllen - indx); int tmp; if (!int.TryParse(sport, out tmp) || tmp < 0 || tmp > 65535) { return; } Flags = OSHTTPURIFlags.ValidHost; Host = host; Port = tmp; URI = (secureHTTP ? "https://" : "http://") + Host + ":" + Port.ToString(); } else { host = url.Substring(start, urllen - start); type = Uri.CheckHostName(host); if (type == UriHostNameType.Unknown || type == UriHostNameType.Basic) { return; } Flags = OSHTTPURIFlags.ValidHost; Host = host; if (secureHTTP) { Port = 443; URI = "https://" + Host + ":443"; } else { Port = 80; URI = "http://" + Host + ":80"; } } if (withDNSResolve) { IPAddress ip = Util.GetHostFromDNS(host); if (ip != null) { Flags = OSHTTPURIFlags.ValidResolved; IP = ip; } } } catch { Flags = OSHTTPURIFlags.None; IP = null; URI = string.Empty; } }