public int IsLocalHome(string otherhome, bool withResolveCheck) { OSHHTPHost tmp = new OSHHTPHost(otherhome, false); if (!tmp.IsValidHost) { return(-1); } if (tmp.Equals(m_homeURL)) { return(1); } if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp)) { return(1); } if (withResolveCheck) { if (tmp.IsResolvedHost) { return(0); } return(tmp.ResolveDNS() ? 0 : -2); } return(0); }
public int IsLocalGrid(string othergatekeeper, bool withResolveCheck) { OSHHTPHost tmp = new OSHHTPHost(othergatekeeper, false); if (!tmp.IsValidHost) { return(((tmp.Flags & OSHTTPURIFlags.Empty) == 0) ? -1 : 1); } if (tmp.Equals(m_gateKeeperURL)) { return(1); } if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(tmp)) { return(1); } if (withResolveCheck) { if (tmp.IsResolvedHost) { return(0); } return(tmp.ResolveDNS() ? 0 : -2); } return(0); }
public int IsLocalGrid(OSHHTPHost othergatekeeper) { if (!othergatekeeper.IsValidHost) { return(-1); } if (othergatekeeper.Equals(m_gateKeeperURL)) { return(1); } if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(othergatekeeper)) { return(1); } return(0); }
public int IsLocalGrid(OSHHTPHost othergatekeeper) { if (!othergatekeeper.IsValidHost) { return(((othergatekeeper.Flags & OSHTTPURIFlags.Empty) == 0) ? -1 : 1); } if (othergatekeeper.Equals(m_gateKeeperURL)) { return(1); } if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(othergatekeeper)) { return(1); } return(0); }
public int IsLocalHome(string otherhome) { OSHHTPHost tmp = new OSHHTPHost(otherhome, false); if (!tmp.IsValidHost) { return(((tmp.Flags & OSHTTPURIFlags.Empty) == 0) ? -1 : 1); } if (tmp.Equals(m_homeURL)) { return(1); } if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp)) { return(1); } return(0); }
public int IsLocalHome(string otherhome) { OSHHTPHost tmp = new OSHHTPHost(otherhome, false); if (!tmp.IsValidHost) { return(-1); } if (tmp.Equals(m_homeURL)) { return(1); } if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp)) { return(1); } return(0); }
// -2 dns failed // -1 if bad url // 0 if not local // 1 if local public int IsLocalGrid(string othergatekeeper) { OSHHTPHost tmp = new OSHHTPHost(othergatekeeper, false); if (!tmp.IsValidHost) { return(-1); } if (tmp.Equals(m_gateKeeperURL)) { return(1); } if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(tmp)) { return(1); } return(0); }
public int IsLocalHome(string otherhome) { OSHHTPHost tmp = new OSHHTPHost(otherhome, false); if (tmp.HostType == UriHostNameType.Unknown) { return(-1); } if (tmp.Equals(m_homeURL)) { return(1); } if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp)) { return(1); } return(0); }
// -2 dns failed // -1 if bad url // 0 if not local // 1 if local public int IsLocalGrid(string othergatekeeper, bool withResolveCheck = false) { OSHHTPHost tmp = new OSHHTPHost(othergatekeeper, false); if (tmp.HostType == UriHostNameType.Unknown) { return(-1); } if (tmp.Equals(m_gateKeeperURL)) { return(1); } if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(tmp)) { return(1); } if (withResolveCheck) { return(tmp.ResolveDNS() ? 0 : -2); } return(0); }
public GridInfo(IConfigSource config, string defaultURI = "") { string[] sections = new string[] { "Const", "Startup", "Hypergrid" }; string gatekeeper = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI", sections, string.Empty); if (string.IsNullOrEmpty(gatekeeper)) { IConfig serverConfig = config.Configs["GatekeeperService"]; if (serverConfig != null) { gatekeeper = serverConfig.GetString("ExternalName", string.Empty); } } if (string.IsNullOrEmpty(gatekeeper)) { IConfig gridConfig = config.Configs["GridService"]; if (gridConfig != null) { gatekeeper = gridConfig.GetString("Gatekeeper", string.Empty); } } if (string.IsNullOrEmpty(gatekeeper)) { m_hasHGconfig = false; if (!string.IsNullOrEmpty(defaultURI)) { m_gateKeeperURL = new OSHHTPHost(defaultURI, true); } } else { m_gateKeeperURL = new OSHHTPHost(gatekeeper, true); m_hasHGconfig = true; } if (!m_gateKeeperURL.IsResolvedHost) { m_log.Error(m_gateKeeperURL.IsValidHost ? "Could not resolve GatekeeperURI" : "GatekeeperURI is a invalid host"); throw new Exception("GatekeeperURI configuration error"); } m_gridUrl = m_gateKeeperURL.URI; string gatekeeperURIAlias = Util.GetConfigVarFromSections <string>(config, "GatekeeperURIAlias", sections, string.Empty); if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias)) { string[] alias = gatekeeperURIAlias.Split(','); for (int i = 0; i < alias.Length; ++i) { OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false); if (tmp.IsValidHost) { if (m_gateKeeperAlias == null) { m_gateKeeperAlias = new HashSet <OSHHTPHost>(); } m_gateKeeperAlias.Add(tmp); } } } if (m_gateKeeperAlias != null && m_gateKeeperAlias.Count > 0) { m_gridUrlAlias = new string[m_gateKeeperAlias.Count]; int i = 0; foreach (OSHHTPHost a in m_gateKeeperAlias) { m_gridUrlAlias[i++] = a.URI; } } string home = Util.GetConfigVarFromSections <string>(config, "HomeURI", sections, string.Empty); if (string.IsNullOrEmpty(home)) { if (!string.IsNullOrEmpty(gatekeeper)) { m_homeURL = m_gateKeeperURL; } else if (!string.IsNullOrEmpty(defaultURI)) { m_homeURL = new OSHHTPHost(defaultURI, true); } } else { m_homeURL = new OSHHTPHost(home, true); } if (!m_homeURL.IsResolvedHost) { m_log.Error(m_homeURL.IsValidHost ? "Could not resolve HomeURI" : "HomeURI is a invalid host"); throw new Exception("HomeURI configuration error"); } string homeAlias = Util.GetConfigVarFromSections <string>(config, "HomeURIAlias", sections, string.Empty); if (!string.IsNullOrWhiteSpace(homeAlias)) { string[] alias = homeAlias.Split(','); for (int i = 0; i < alias.Length; ++i) { OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false); if (tmp.IsValidHost) { if (m_homeURLAlias == null) { m_homeURLAlias = new HashSet <OSHHTPHost>(); } m_homeURLAlias.Add(tmp); } } } string[] namessections = new string[] { "Const", "GridInfo", "SimulatorFeatures" }; m_GridName = Util.GetConfigVarFromSections <string>(config, "GridName", namessections, string.Empty); if (string.IsNullOrEmpty(m_GridName)) { m_GridName = Util.GetConfigVarFromSections <string>(config, "gridname", namessections, string.Empty); } m_GridNick = Util.GetConfigVarFromSections <string>(config, "GridNick", namessections, string.Empty); if (m_GridName == string.Empty) { m_GridName = "Another bad configured grid"; } OSHTTPURI tmpuri; m_SearchURL = Util.GetConfigVarFromSections <string>(config, "SearchServerURI", namessections, string.Empty); if (!string.IsNullOrEmpty(m_SearchURL)) { tmpuri = new OSHTTPURI(m_SearchURL.Trim(), true); if (!tmpuri.IsResolvedHost) { m_log.Error(tmpuri.IsValidHost ? "Could not resolve SearchServerURI" : "SearchServerURI is a invalid host"); throw new Exception("SearchServerURI configuration error"); } m_SearchURL = tmpuri.URI; } m_DestinationGuideURL = Util.GetConfigVarFromSections <string>(config, "DestinationGuideURI", namessections, string.Empty); if (string.IsNullOrEmpty(m_DestinationGuideURL)) // Make this consistent with the variable in the LoginService config { m_DestinationGuideURL = Util.GetConfigVarFromSections <string>(config, "DestinationGuide", namessections, string.Empty); } if (!string.IsNullOrEmpty(m_DestinationGuideURL)) { tmpuri = new OSHTTPURI(m_DestinationGuideURL.Trim(), true); if (!tmpuri.IsResolvedHost) { m_log.Error(tmpuri.IsValidHost ? "Could not resolve DestinationGuideURL" : "DestinationGuideURL is a invalid host"); throw new Exception("DestinationGuideURL configuration error"); } m_DestinationGuideURL = tmpuri.URI; } m_economyURL = Util.GetConfigVarFromSections <string>(config, "economy", new string[] { "Economy", "GridInfo" }); if (!string.IsNullOrEmpty(m_economyURL)) { tmpuri = new OSHTTPURI(m_economyURL.Trim(), true); if (!tmpuri.IsResolvedHost) { m_log.Error(tmpuri.IsValidHost ? "Could not resolve economyURL" : "economyURL is a invalid host"); throw new Exception("economyURL configuration error"); } m_economyURL = tmpuri.URI; } }
public GridInfo(IConfigSource config, string defaultURI = "") { string[] sections = new string[] { "Startup", "Hypergrid" }; string gatekeeper = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI", sections, String.Empty); if (string.IsNullOrEmpty(gatekeeper)) { IConfig serverConfig = config.Configs["GatekeeperService"]; if (serverConfig != null) { gatekeeper = serverConfig.GetString("ExternalName", string.Empty); } } if (string.IsNullOrEmpty(gatekeeper)) { IConfig gridConfig = config.Configs["GridService"]; if (gridConfig != null) { gatekeeper = gridConfig.GetString("Gatekeeper", string.Empty); } } if (string.IsNullOrEmpty(gatekeeper)) { m_hasHGconfig = false; if (!string.IsNullOrEmpty(defaultURI)) { m_gateKeeperURL = new OSHHTPHost(defaultURI, true); } } else { m_gateKeeperURL = new OSHHTPHost(gatekeeper, true); m_hasHGconfig = true; } if (!m_gateKeeperURL.IsResolvedHost) { m_log.Error(m_gateKeeperURL.IsValidHost ? "Could not resolve GatekeeperURI" : "GatekeeperURI is a invalid host"); throw new Exception("GatekeeperURI configuration error"); } string gatekeeperURIAlias = Util.GetConfigVarFromSections <string>(config, "GatekeeperURIAlias", sections, String.Empty); if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias)) { string[] alias = gatekeeperURIAlias.Split(','); for (int i = 0; i < alias.Length; ++i) { OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false); if (tmp.IsValidHost) { if (m_gateKeeperAlias == null) { m_gateKeeperAlias = new HashSet <OSHHTPHost>(); } m_gateKeeperAlias.Add(tmp); } } } string home = Util.GetConfigVarFromSections <string>(config, "HomeURI", sections, string.Empty); if (string.IsNullOrEmpty(home)) { if (!string.IsNullOrEmpty(gatekeeper)) { m_homeURL = m_gateKeeperURL; } else if (!string.IsNullOrEmpty(defaultURI)) { m_homeURL = new OSHHTPHost(defaultURI, true); } } else { m_homeURL = new OSHHTPHost(home, true); } if (!m_homeURL.IsResolvedHost) { m_log.Error(m_homeURL.IsValidHost ? "Could not resolve HomeURI" : "HomeURI is a invalid host"); throw new Exception("HomeURI configuration error"); } string homeAlias = Util.GetConfigVarFromSections <string>(config, "HomeURIAlias", sections, String.Empty); if (!string.IsNullOrWhiteSpace(homeAlias)) { string[] alias = homeAlias.Split(','); for (int i = 0; i < alias.Length; ++i) { OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false); if (tmp.IsValidHost) { if (m_homeURLAlias == null) { m_homeURLAlias = new HashSet <OSHHTPHost>(); } m_homeURLAlias.Add(tmp); } } } }