1
0

GridInfo.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Net;
  30. using System.Reflection;
  31. using log4net;
  32. using Nini.Config;
  33. namespace OpenSim.Framework
  34. {
  35. public enum OSHTTPURIFlags : byte
  36. {
  37. None = 0,
  38. ValidHost = 1,
  39. Resolved = 1 << 1,
  40. ValidResolved = ValidHost | Resolved
  41. }
  42. // full http or https schema, server host, port and possible server path any query is ignored.
  43. public struct OSHTTPURI:IComparable<OSHTTPURI>, IEquatable<OSHTTPURI>
  44. {
  45. public OSHTTPURIFlags Flags;
  46. public int Port;
  47. public IPAddress IP;
  48. public readonly string Host;
  49. public readonly string URL;
  50. public readonly string Path;
  51. public readonly string URI;
  52. public OSHTTPURI(string uri, bool withDNSResolve = false)
  53. {
  54. Flags = OSHTTPURIFlags.None;
  55. Port = -1;
  56. IP = null;
  57. Host = string.Empty;
  58. URI = string.Empty;
  59. URL = string.Empty;
  60. Path = string.Empty;
  61. if (string.IsNullOrEmpty(uri))
  62. return;
  63. try
  64. {
  65. Uri m_checkuri = new Uri(uri);
  66. if(m_checkuri.Scheme != Uri.UriSchemeHttp && m_checkuri.Scheme != Uri.UriSchemeHttps)
  67. return;
  68. Flags = OSHTTPURIFlags.ValidHost;
  69. Host = m_checkuri.DnsSafeHost.ToLowerInvariant();
  70. Port = m_checkuri.Port;
  71. Path = m_checkuri.AbsolutePath;
  72. if (Path[Path.Length - 1] == '/')
  73. Path = Path.Substring(0, Path.Length - 1);
  74. URL = m_checkuri.Scheme + "://" + Host + ":" + Port;
  75. URI = URL + Path;
  76. if (withDNSResolve)
  77. {
  78. IPAddress ip = Util.GetHostFromDNS(Host);
  79. if (ip != null)
  80. {
  81. IP = ip;
  82. Flags = OSHTTPURIFlags.ValidResolved;
  83. }
  84. }
  85. }
  86. catch
  87. {
  88. Flags = OSHTTPURIFlags.None;
  89. IP = null;
  90. URI = string.Empty;
  91. }
  92. }
  93. public bool ResolveDNS()
  94. {
  95. IPAddress ip = Util.GetHostFromDNS(Host);
  96. if (ip == null)
  97. {
  98. Flags &= ~OSHTTPURIFlags.Resolved;
  99. return false;
  100. }
  101. Flags |= OSHTTPURIFlags.Resolved;
  102. return true;
  103. }
  104. public bool IsValidHost
  105. {
  106. get { return Flags != OSHTTPURIFlags.None;}
  107. }
  108. public bool ValidAndResolved(out string error)
  109. {
  110. if (Flags == OSHTTPURIFlags.None)
  111. {
  112. error = "failed to parse uri";
  113. return false;
  114. }
  115. if ((Flags & OSHTTPURIFlags.Resolved) == 0)
  116. {
  117. error = "failed DNS resolve of uri host";
  118. return false;
  119. }
  120. error = string.Empty;
  121. return true;
  122. }
  123. public bool IsResolvedHost
  124. {
  125. get {return (Flags & OSHTTPURIFlags.Resolved) != 0; }
  126. }
  127. public string URIwEndSlash
  128. {
  129. get { return Flags == OSHTTPURIFlags.None ? "" : URI + "/";}
  130. }
  131. public int CompareTo(OSHTTPURI other)
  132. {
  133. if (Port == other.Port && ((Flags & other.Flags) & OSHTTPURIFlags.ValidHost) != 0)
  134. {
  135. if (Path.Equals(other.Path))
  136. return Host.CompareTo(other.Host);
  137. }
  138. return -1;
  139. }
  140. public bool Equals(OSHTTPURI other)
  141. {
  142. if (Port == other.Port && ((Flags & other.Flags) & OSHTTPURIFlags.ValidHost) != 0)
  143. {
  144. if (Path.Equals(other.Path))
  145. return Host.Equals(other.Host);
  146. }
  147. return false;
  148. }
  149. public override int GetHashCode()
  150. {
  151. return URI.GetHashCode();
  152. }
  153. }
  154. //host and port. Can not have server internal path or query. http scheme is assumed if not present
  155. public struct OSHHTPHost : IComparable<OSHHTPHost>, IEquatable<OSHHTPHost>
  156. {
  157. public OSHTTPURIFlags Flags;
  158. public int Port;
  159. public IPAddress IP;
  160. public readonly string Host;
  161. public readonly string URI;
  162. public OSHHTPHost(string url, bool withDNSResolve = false)
  163. {
  164. Flags = OSHTTPURIFlags.None;
  165. Port = 80;
  166. IP = null;
  167. Host = string.Empty;
  168. URI = string.Empty;
  169. bool secureHTTP = false;
  170. if (string.IsNullOrEmpty(url))
  171. return;
  172. url = url.ToLowerInvariant();
  173. try
  174. {
  175. int urllen = url.Length;
  176. if (url[urllen - 1] == '/')
  177. --urllen;
  178. int start;
  179. if (url.StartsWith("http"))
  180. {
  181. if (url[4] == 's')
  182. {
  183. start = 8;
  184. secureHTTP = true;
  185. }
  186. else
  187. start = 7;
  188. }
  189. else
  190. start = 0;
  191. string host;
  192. UriHostNameType type;
  193. int indx = url.IndexOf(':', start, urllen - start);
  194. if (indx > 0)
  195. {
  196. host = url.Substring(start, indx - start);
  197. type = Uri.CheckHostName(host);
  198. if (type == UriHostNameType.Unknown || type == UriHostNameType.Basic)
  199. return;
  200. ++indx;
  201. string sport = url.Substring(indx, urllen - indx);
  202. int tmp;
  203. if (!int.TryParse(sport, out tmp) || tmp < 0 || tmp > 65535)
  204. return;
  205. Flags = OSHTTPURIFlags.ValidHost;
  206. Host = host;
  207. Port = tmp;
  208. URI = (secureHTTP ? "https://" : "http://") + Host + ":" + Port.ToString();
  209. }
  210. else
  211. {
  212. host = url.Substring(start, urllen - start);
  213. type = Uri.CheckHostName(host);
  214. if (type == UriHostNameType.Unknown || type == UriHostNameType.Basic)
  215. return;
  216. Flags = OSHTTPURIFlags.ValidHost;
  217. Host = host;
  218. if (secureHTTP)
  219. {
  220. Port = 443;
  221. URI = "https://" + Host + ":443";
  222. }
  223. else
  224. {
  225. Port = 80;
  226. URI = "http://" + Host + ":80";
  227. }
  228. }
  229. if (withDNSResolve)
  230. {
  231. IPAddress ip = Util.GetHostFromDNS(host);
  232. if (ip != null)
  233. {
  234. Flags = OSHTTPURIFlags.ValidResolved;
  235. IP = ip;
  236. }
  237. }
  238. }
  239. catch
  240. {
  241. Flags = OSHTTPURIFlags.None;
  242. IP = null;
  243. URI = string.Empty;
  244. }
  245. }
  246. public bool ResolveDNS()
  247. {
  248. IPAddress ip = Util.GetHostFromDNS(Host);
  249. if (ip == null)
  250. {
  251. Flags &= ~OSHTTPURIFlags.Resolved;
  252. return false;
  253. }
  254. Flags |= OSHTTPURIFlags.Resolved;
  255. return true;
  256. }
  257. public bool IsValidHost
  258. {
  259. get { return Flags != OSHTTPURIFlags.None; }
  260. }
  261. public bool IsResolvedHost
  262. {
  263. get { return (Flags & OSHTTPURIFlags.Resolved) != 0; }
  264. }
  265. public bool ValidAndResolved(out string error)
  266. {
  267. if (Flags == OSHTTPURIFlags.None)
  268. {
  269. error = "failed to parse uri";
  270. return false;
  271. }
  272. if ((Flags & OSHTTPURIFlags.Resolved) == 0)
  273. {
  274. error = "failed DNS resolve of uri host";
  275. return false;
  276. }
  277. error = string.Empty;
  278. return true;
  279. }
  280. public string URIwEndSlash
  281. {
  282. get { return (Flags == OSHTTPURIFlags.None) ? "" : URI + "/"; }
  283. }
  284. public int CompareTo(OSHHTPHost other)
  285. {
  286. if (Port == other.Port && ((Flags & other.Flags) & OSHTTPURIFlags.ValidHost) != 0)
  287. {
  288. return Host.CompareTo(other.Host);
  289. }
  290. return -1;
  291. }
  292. public bool Equals(OSHHTPHost other)
  293. {
  294. if (Port == other.Port && ((Flags & other.Flags) & OSHTTPURIFlags.ValidHost) != 0)
  295. {
  296. return Host.Equals(other.Host);
  297. }
  298. return false;
  299. }
  300. public override int GetHashCode()
  301. {
  302. return URI.GetHashCode();
  303. }
  304. }
  305. public class GridInfo
  306. {
  307. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  308. private bool m_hasHGconfig;
  309. private OSHHTPHost m_gateKeeperURL;
  310. private HashSet<OSHHTPHost> m_gateKeeperAlias;
  311. private OSHHTPHost m_homeURL;
  312. private HashSet<OSHHTPHost> m_homeURLAlias;
  313. private string m_gridUrl = string.Empty;
  314. private string[] m_gridUrlAlias = null;
  315. private string m_GridName = string.Empty;
  316. private string m_GridNick = string.Empty;
  317. private string m_SearchURL = string.Empty;
  318. private string m_DestinationGuideURL = string.Empty;
  319. private string m_economyURL = string.Empty;
  320. public GridInfo (IConfigSource config, string defaultURI = "")
  321. {
  322. string[] sections = new string[] {"Const", "Startup", "Hypergrid"};
  323. string gatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", sections, String.Empty);
  324. if (string.IsNullOrEmpty(gatekeeper))
  325. {
  326. IConfig serverConfig = config.Configs["GatekeeperService"];
  327. if (serverConfig != null)
  328. gatekeeper = serverConfig.GetString("ExternalName", string.Empty);
  329. }
  330. if (string.IsNullOrEmpty(gatekeeper))
  331. {
  332. IConfig gridConfig = config.Configs["GridService"];
  333. if (gridConfig != null)
  334. gatekeeper = gridConfig.GetString("Gatekeeper", string.Empty);
  335. }
  336. if (string.IsNullOrEmpty(gatekeeper))
  337. {
  338. m_hasHGconfig = false;
  339. if (!string.IsNullOrEmpty(defaultURI))
  340. m_gateKeeperURL = new OSHHTPHost(defaultURI, true);
  341. }
  342. else
  343. {
  344. m_gateKeeperURL = new OSHHTPHost(gatekeeper, true);
  345. m_hasHGconfig = true;
  346. }
  347. if (!m_gateKeeperURL.IsResolvedHost)
  348. {
  349. m_log.Error(m_gateKeeperURL.IsValidHost ? "Could not resolve GatekeeperURI" : "GatekeeperURI is a invalid host");
  350. throw new Exception("GatekeeperURI configuration error");
  351. }
  352. m_gridUrl = m_gateKeeperURL.URI;
  353. string gatekeeperURIAlias = Util.GetConfigVarFromSections<string>(config, "GatekeeperURIAlias", sections, string.Empty);
  354. if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias))
  355. {
  356. string[] alias = gatekeeperURIAlias.Split(',');
  357. for (int i = 0; i < alias.Length; ++i)
  358. {
  359. OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false);
  360. if (tmp.IsValidHost)
  361. {
  362. if (m_gateKeeperAlias == null)
  363. m_gateKeeperAlias = new HashSet<OSHHTPHost>();
  364. m_gateKeeperAlias.Add(tmp);
  365. }
  366. }
  367. }
  368. if (m_gateKeeperAlias != null && m_gateKeeperAlias.Count > 0)
  369. {
  370. m_gridUrlAlias = new string[m_gateKeeperAlias.Count];
  371. int i = 0;
  372. foreach (OSHHTPHost a in m_gateKeeperAlias)
  373. m_gridUrlAlias[i++] = a.URI;
  374. }
  375. string home = Util.GetConfigVarFromSections<string>(config, "HomeURI", sections, string.Empty);
  376. if (string.IsNullOrEmpty(home))
  377. {
  378. if (!string.IsNullOrEmpty(gatekeeper))
  379. m_homeURL = m_gateKeeperURL;
  380. else if (!string.IsNullOrEmpty(defaultURI))
  381. m_homeURL = new OSHHTPHost(defaultURI, true);
  382. }
  383. else
  384. m_homeURL = new OSHHTPHost(home, true);
  385. if (!m_homeURL.IsResolvedHost)
  386. {
  387. m_log.Error(m_homeURL.IsValidHost ? "Could not resolve HomeURI" : "HomeURI is a invalid host");
  388. throw new Exception("HomeURI configuration error");
  389. }
  390. string homeAlias = Util.GetConfigVarFromSections<string>(config, "HomeURIAlias", sections, String.Empty);
  391. if (!string.IsNullOrWhiteSpace(homeAlias))
  392. {
  393. string[] alias = homeAlias.Split(',');
  394. for (int i = 0; i < alias.Length; ++i)
  395. {
  396. OSHHTPHost tmp = new OSHHTPHost(alias[i].Trim(), false);
  397. if (tmp.IsValidHost)
  398. {
  399. if (m_homeURLAlias == null)
  400. m_homeURLAlias = new HashSet<OSHHTPHost>();
  401. m_homeURLAlias.Add(tmp);
  402. }
  403. }
  404. }
  405. string[] namessections = new string[] { "Const", "GridInfo", "SimulatorFeatures" };
  406. m_GridName = Util.GetConfigVarFromSections<string>(config, "GridName", namessections, string.Empty);
  407. if (string.IsNullOrEmpty(m_GridName))
  408. m_GridName = Util.GetConfigVarFromSections<string>(config, "gridname", namessections, string.Empty);
  409. m_GridNick = Util.GetConfigVarFromSections<string>(config, "GridNick", namessections, string.Empty);
  410. if (m_GridName == string.Empty)
  411. m_GridName = "Another bad configured grid";
  412. OSHTTPURI tmpuri;
  413. m_SearchURL = Util.GetConfigVarFromSections<string>(config,"SearchServerURI", namessections, string.Empty);
  414. if (!string.IsNullOrEmpty(m_SearchURL))
  415. {
  416. tmpuri = new OSHTTPURI(m_SearchURL.Trim(), true);
  417. if (!tmpuri.IsResolvedHost)
  418. {
  419. m_log.Error(tmpuri.IsValidHost ? "Could not resolve SearchServerURI" : "SearchServerURI is a invalid host");
  420. throw new Exception("SearchServerURI configuration error");
  421. }
  422. m_SearchURL = tmpuri.URIwEndSlash;
  423. }
  424. m_DestinationGuideURL = Util.GetConfigVarFromSections<string>(config, "DestinationGuideURI",namessections, string.Empty);
  425. if (string.IsNullOrEmpty(m_DestinationGuideURL)) // Make this consistent with the variable in the LoginService config
  426. m_DestinationGuideURL = Util.GetConfigVarFromSections<string>(config, "DestinationGuide", namessections, string.Empty);
  427. if (!string.IsNullOrEmpty(m_DestinationGuideURL))
  428. {
  429. tmpuri = new OSHTTPURI(m_DestinationGuideURL.Trim(), true);
  430. if (!tmpuri.IsResolvedHost)
  431. {
  432. m_log.Error(tmpuri.IsValidHost ? "Could not resolve DestinationGuideURL" : "DestinationGuideURL is a invalid host");
  433. throw new Exception("DestinationGuideURL configuration error");
  434. }
  435. m_DestinationGuideURL = tmpuri.URIwEndSlash;
  436. }
  437. m_economyURL = Util.GetConfigVarFromSections<string>(config, "economy", new string[] { "Economy", "GridInfo" });
  438. if (!string.IsNullOrEmpty(m_economyURL))
  439. {
  440. tmpuri = new OSHTTPURI(m_economyURL.Trim(), true);
  441. if (!tmpuri.IsResolvedHost)
  442. {
  443. m_log.Error(tmpuri.IsValidHost ? "Could not resolve economyURL" : "economyURL is a invalid host");
  444. throw new Exception("economyURL configuration error");
  445. }
  446. m_economyURL = tmpuri.URIwEndSlash;
  447. }
  448. }
  449. public bool HasHGConfig
  450. {
  451. get { return m_hasHGconfig; }
  452. }
  453. public string GateKeeperURL
  454. {
  455. get { return m_gateKeeperURL.URIwEndSlash; }
  456. }
  457. public string GateKeeperURLNoEndSlash
  458. {
  459. get { return m_gateKeeperURL.URI; }
  460. }
  461. public string HGGateKeeperURL
  462. {
  463. get
  464. {
  465. if (m_hasHGconfig)
  466. return m_gateKeeperURL.URIwEndSlash;
  467. return string.Empty;
  468. }
  469. }
  470. public string HGGateKeeperURLNoEndSlash
  471. {
  472. get
  473. {
  474. if (m_hasHGconfig)
  475. return m_gateKeeperURL.URI;
  476. return string.Empty;
  477. }
  478. }
  479. public string HomeURL
  480. {
  481. get { return m_homeURL.URIwEndSlash; }
  482. }
  483. public string HomeURLNoEndSlash
  484. {
  485. get { return m_homeURL.URI; }
  486. }
  487. public string HGHomeURL
  488. {
  489. get
  490. {
  491. if (m_hasHGconfig)
  492. return m_homeURL.URIwEndSlash;
  493. return string.Empty;
  494. }
  495. }
  496. public string HGHomeURLNoEndSlash
  497. {
  498. get
  499. {
  500. if (m_hasHGconfig)
  501. return m_homeURL.URI;
  502. return string.Empty;
  503. }
  504. }
  505. // -2 dns failed
  506. // -1 if bad url
  507. // 0 if not local
  508. // 1 if local
  509. public int IsLocalGrid(string othergatekeeper)
  510. {
  511. OSHHTPHost tmp = new OSHHTPHost(othergatekeeper, false);
  512. if (!tmp.IsValidHost)
  513. return -1;
  514. if (tmp.Equals(m_gateKeeperURL))
  515. return 1;
  516. if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(tmp))
  517. return 1;
  518. return 0;
  519. }
  520. public int IsLocalGrid(string othergatekeeper, bool withResolveCheck)
  521. {
  522. OSHHTPHost tmp = new OSHHTPHost(othergatekeeper, false);
  523. if (!tmp.IsValidHost)
  524. return -1;
  525. if (tmp.Equals(m_gateKeeperURL))
  526. return 1;
  527. if (m_gateKeeperAlias != null && m_gateKeeperAlias.Contains(tmp))
  528. return 1;
  529. if (withResolveCheck)
  530. {
  531. if (tmp.IsResolvedHost)
  532. return 0;
  533. return tmp.ResolveDNS() ? 0 : -2;
  534. }
  535. return 0;
  536. }
  537. public int IsLocalHome(string otherhome)
  538. {
  539. OSHHTPHost tmp = new OSHHTPHost(otherhome, false);
  540. if (!tmp.IsValidHost)
  541. return -1;
  542. if (tmp.Equals(m_homeURL))
  543. return 1;
  544. if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp))
  545. return 1;
  546. return 0;
  547. }
  548. public int IsLocalHome(string otherhome, bool withResolveCheck)
  549. {
  550. OSHHTPHost tmp = new OSHHTPHost(otherhome, false);
  551. if (!tmp.IsValidHost)
  552. return -1;
  553. if (tmp.Equals(m_homeURL))
  554. return 1;
  555. if (m_homeURLAlias != null && m_homeURLAlias.Contains(tmp))
  556. return 1;
  557. if (withResolveCheck)
  558. {
  559. if (tmp.IsResolvedHost)
  560. return 0;
  561. return tmp.ResolveDNS() ? 0 : -2;
  562. }
  563. return 0;
  564. }
  565. public string[] GridUrlAlias
  566. {
  567. get { return m_gridUrlAlias; }
  568. set
  569. {
  570. if(value.Length > 0)
  571. {
  572. for (int i = 0; i < value.Length; ++i)
  573. {
  574. OSHHTPHost tmp = new OSHHTPHost(value[i].Trim(), false);
  575. if (tmp.IsValidHost)
  576. {
  577. if (m_gateKeeperAlias == null)
  578. m_gateKeeperAlias = new HashSet<OSHHTPHost>();
  579. m_gateKeeperAlias.Add(tmp);
  580. }
  581. }
  582. if (m_gateKeeperAlias != null && m_gateKeeperAlias.Count > 0)
  583. {
  584. m_gridUrlAlias = new string[m_gateKeeperAlias.Count];
  585. int i = 0;
  586. foreach (OSHHTPHost a in m_gateKeeperAlias)
  587. m_gridUrlAlias[i++] = a.URI;
  588. }
  589. }
  590. }
  591. }
  592. public string GridName
  593. {
  594. get { return m_GridName; }
  595. set
  596. {
  597. if (!string.IsNullOrEmpty(value))
  598. m_GridName = value;
  599. }
  600. }
  601. public string GridNick
  602. {
  603. get { return m_GridNick; }
  604. set
  605. {
  606. if (!string.IsNullOrEmpty(value))
  607. m_GridNick = value;
  608. }
  609. }
  610. public string GridUrl
  611. {
  612. get { return m_gridUrl; }
  613. set
  614. {
  615. OSHHTPHost tmp = new OSHHTPHost(value, true);
  616. if (tmp.IsResolvedHost)
  617. m_gridUrl = tmp.URI;
  618. else
  619. m_log.Error((tmp.IsValidHost ? "Could not resolve GridUrl" : "GridUrl is a invalid host ") + value ?? "");
  620. }
  621. }
  622. public string SearchURL
  623. {
  624. get { return m_SearchURL; }
  625. set
  626. {
  627. OSHTTPURI tmp = new OSHTTPURI(value, true);
  628. if (tmp.IsResolvedHost)
  629. m_SearchURL = tmp.URIwEndSlash;
  630. else
  631. m_log.Error((tmp.IsValidHost ? "Could not resolve SearchURL" : "SearchURL is a invalid host ") + value??"");
  632. }
  633. }
  634. public string DestinationGuideURL
  635. {
  636. get { return m_DestinationGuideURL; }
  637. set
  638. {
  639. OSHTTPURI tmp = new OSHTTPURI(value, true);
  640. if (tmp.IsResolvedHost)
  641. m_DestinationGuideURL = tmp.URIwEndSlash;
  642. else
  643. m_log.Error((tmp.IsValidHost ? "Could not resolve DestinationGuideURL" : "DestinationGuideURL is a invalid host ") + value ?? "");
  644. }
  645. }
  646. public string EconomyURL
  647. {
  648. get { return m_economyURL; }
  649. set
  650. {
  651. OSHTTPURI tmp = new OSHTTPURI(value, true);
  652. if (tmp.IsResolvedHost)
  653. m_economyURL = tmp.URIwEndSlash;
  654. else
  655. m_log.Error((tmp.IsValidHost ? "Could not resolve EconomyURL" : "EconomyURL is a invalid host ") + value ?? "");
  656. }
  657. }
  658. }
  659. }