RegionInfo.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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 OpenSim 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.Net;
  29. using System.Net.Sockets;
  30. using System.Xml;
  31. using Nini.Config;
  32. using OpenMetaverse;
  33. using OpenMetaverse.StructuredData;
  34. namespace OpenSim.Framework
  35. {
  36. [Serializable]
  37. public class SimpleRegionInfo
  38. {
  39. // private static readonly log4net.ILog m_log
  40. // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  41. /// <summary>
  42. /// The port by which http communication occurs with the region (most noticeably, CAPS communication)
  43. /// </summary>
  44. public uint HttpPort
  45. {
  46. get { return m_httpPort; }
  47. set { m_httpPort = value; }
  48. }
  49. protected uint m_httpPort;
  50. /// <summary>
  51. /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
  52. /// </summary>
  53. public string ServerURI
  54. {
  55. get { return m_serverURI; }
  56. set { m_serverURI = value; }
  57. }
  58. protected string m_serverURI;
  59. protected bool Allow_Alternate_Ports;
  60. public bool m_allow_alternate_ports;
  61. protected string m_externalHostName;
  62. protected IPEndPoint m_internalEndPoint;
  63. protected uint? m_regionLocX;
  64. protected uint? m_regionLocY;
  65. protected uint m_remotingPort;
  66. public UUID RegionID = UUID.Zero;
  67. public string RemotingAddress;
  68. public SimpleRegionInfo()
  69. {
  70. }
  71. public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
  72. {
  73. m_regionLocX = regionLocX;
  74. m_regionLocY = regionLocY;
  75. m_internalEndPoint = internalEndPoint;
  76. m_externalHostName = externalUri;
  77. }
  78. public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, uint port)
  79. {
  80. m_regionLocX = regionLocX;
  81. m_regionLocY = regionLocY;
  82. m_externalHostName = externalUri;
  83. m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) port);
  84. }
  85. public SimpleRegionInfo(RegionInfo ConvertFrom)
  86. {
  87. m_regionLocX = ConvertFrom.RegionLocX;
  88. m_regionLocY = ConvertFrom.RegionLocY;
  89. m_internalEndPoint = ConvertFrom.InternalEndPoint;
  90. m_externalHostName = ConvertFrom.ExternalHostName;
  91. m_remotingPort = ConvertFrom.RemotingPort;
  92. m_httpPort = ConvertFrom.HttpPort;
  93. m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
  94. RemotingAddress = ConvertFrom.RemotingAddress;
  95. RegionID = UUID.Zero;
  96. ServerURI = ConvertFrom.ServerURI;
  97. }
  98. public uint RemotingPort
  99. {
  100. get { return m_remotingPort; }
  101. set { m_remotingPort = value; }
  102. }
  103. /// <value>
  104. /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
  105. ///
  106. /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
  107. /// </value>
  108. public IPEndPoint ExternalEndPoint
  109. {
  110. get
  111. {
  112. // Old one defaults to IPv6
  113. //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
  114. IPAddress ia = null;
  115. // If it is already an IP, don't resolve it - just return directly
  116. if (IPAddress.TryParse(m_externalHostName, out ia))
  117. return new IPEndPoint(ia, m_internalEndPoint.Port);
  118. // Reset for next check
  119. ia = null;
  120. foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
  121. {
  122. if (ia == null)
  123. ia = Adr;
  124. if (Adr.AddressFamily == AddressFamily.InterNetwork)
  125. {
  126. ia = Adr;
  127. break;
  128. }
  129. }
  130. return new IPEndPoint(ia, m_internalEndPoint.Port);
  131. }
  132. set { m_externalHostName = value.ToString(); }
  133. }
  134. public string ExternalHostName
  135. {
  136. get { return m_externalHostName; }
  137. set { m_externalHostName = value; }
  138. }
  139. public IPEndPoint InternalEndPoint
  140. {
  141. get { return m_internalEndPoint; }
  142. set { m_internalEndPoint = value; }
  143. }
  144. public uint RegionLocX
  145. {
  146. get { return m_regionLocX.Value; }
  147. set { m_regionLocX = value; }
  148. }
  149. public uint RegionLocY
  150. {
  151. get { return m_regionLocY.Value; }
  152. set { m_regionLocY = value; }
  153. }
  154. public ulong RegionHandle
  155. {
  156. get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); }
  157. }
  158. public int getInternalEndPointPort()
  159. {
  160. return m_internalEndPoint.Port;
  161. }
  162. }
  163. public class RegionInfo : SimpleRegionInfo
  164. {
  165. // private static readonly log4net.ILog m_log
  166. // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  167. public bool commFailTF = false;
  168. public ConfigurationMember configMember;
  169. public string DataStore = String.Empty;
  170. public string RegionFile = String.Empty;
  171. public bool isSandbox = false;
  172. private EstateSettings m_estateSettings;
  173. private RegionSettings m_regionSettings;
  174. //private IConfigSource m_configSource = null;
  175. public UUID MasterAvatarAssignedUUID = UUID.Zero;
  176. public string MasterAvatarFirstName = String.Empty;
  177. public string MasterAvatarLastName = String.Empty;
  178. public string MasterAvatarSandboxPassword = String.Empty;
  179. public UUID originRegionID = UUID.Zero;
  180. public string proxyUrl = "";
  181. public int ProxyOffset = 0;
  182. public string RegionName = String.Empty;
  183. public string regionSecret = UUID.Random().ToString();
  184. public UUID lastMapUUID = UUID.Zero;
  185. public string lastMapRefresh = "0";
  186. private int m_nonphysPrimMax = 0;
  187. private int m_physPrimMax = 0;
  188. private bool m_clampPrimSize = false;
  189. private int m_objectCapacity = 0;
  190. // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
  191. // MT: Yes. Estates can't span trust boundaries. Therefore, it can be
  192. // assumed that all instances belonging to one estate are able to
  193. // access the same database server. Since estate settings are lodaed
  194. // from there, that should be sufficient for full remote administration
  195. public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource)
  196. {
  197. //m_configSource = configSource;
  198. configMember =
  199. new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
  200. configMember.performConfigurationRetrieve();
  201. RegionFile = filename;
  202. }
  203. public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource)
  204. {
  205. //m_configSource = configSource;
  206. configMember =
  207. new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
  208. configMember.performConfigurationRetrieve();
  209. }
  210. public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) :
  211. base(regionLocX, regionLocY, internalEndPoint, externalUri)
  212. {
  213. }
  214. public RegionInfo()
  215. {
  216. }
  217. public RegionInfo(SerializableRegionInfo ConvertFrom)
  218. {
  219. m_regionLocX = ConvertFrom.RegionLocX;
  220. m_regionLocY = ConvertFrom.RegionLocY;
  221. m_internalEndPoint = ConvertFrom.InternalEndPoint;
  222. m_externalHostName = ConvertFrom.ExternalHostName;
  223. m_remotingPort = ConvertFrom.RemotingPort;
  224. m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
  225. RemotingAddress = ConvertFrom.RemotingAddress;
  226. RegionID = UUID.Zero;
  227. proxyUrl = ConvertFrom.ProxyUrl;
  228. originRegionID = ConvertFrom.OriginRegionID;
  229. RegionName = ConvertFrom.RegionName;
  230. ServerURI = ConvertFrom.ServerURI;
  231. }
  232. public RegionInfo(SimpleRegionInfo ConvertFrom)
  233. {
  234. m_regionLocX = ConvertFrom.RegionLocX;
  235. m_regionLocY = ConvertFrom.RegionLocY;
  236. m_internalEndPoint = ConvertFrom.InternalEndPoint;
  237. m_externalHostName = ConvertFrom.ExternalHostName;
  238. m_remotingPort = ConvertFrom.RemotingPort;
  239. m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
  240. RemotingAddress = ConvertFrom.RemotingAddress;
  241. RegionID = UUID.Zero;
  242. ServerURI = ConvertFrom.ServerURI;
  243. }
  244. public EstateSettings EstateSettings
  245. {
  246. get
  247. {
  248. if (m_estateSettings == null)
  249. {
  250. m_estateSettings = new EstateSettings();
  251. }
  252. return m_estateSettings;
  253. }
  254. set { m_estateSettings = value; }
  255. }
  256. public RegionSettings RegionSettings
  257. {
  258. get
  259. {
  260. if (m_regionSettings == null)
  261. {
  262. m_regionSettings = new RegionSettings();
  263. }
  264. return m_regionSettings;
  265. }
  266. set { m_regionSettings = value; }
  267. }
  268. public int NonphysPrimMax
  269. {
  270. get { return m_nonphysPrimMax; }
  271. }
  272. public int PhysPrimMax
  273. {
  274. get { return m_physPrimMax; }
  275. }
  276. public bool ClampPrimSize
  277. {
  278. get { return m_clampPrimSize; }
  279. }
  280. public int ObjectCapacity
  281. {
  282. get { return m_objectCapacity; }
  283. }
  284. public void SetEndPoint(string ipaddr, int port)
  285. {
  286. IPAddress tmpIP = IPAddress.Parse(ipaddr);
  287. IPEndPoint tmpEPE = new IPEndPoint(tmpIP, port);
  288. m_internalEndPoint = tmpEPE;
  289. }
  290. //not in use, should swap to nini though.
  291. public void LoadFromNiniSource(IConfigSource source)
  292. {
  293. LoadFromNiniSource(source, "RegionInfo");
  294. }
  295. //not in use, should swap to nini though.
  296. public void LoadFromNiniSource(IConfigSource source, string sectionName)
  297. {
  298. string errorMessage = String.Empty;
  299. RegionID = new UUID(source.Configs[sectionName].GetString("Region_ID", UUID.Random().ToString()));
  300. RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test");
  301. m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000"));
  302. m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000"));
  303. // this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db");
  304. string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0");
  305. IPAddress ipAddressResult;
  306. if (IPAddress.TryParse(ipAddress, out ipAddressResult))
  307. {
  308. m_internalEndPoint = new IPEndPoint(ipAddressResult, 0);
  309. }
  310. else
  311. {
  312. errorMessage = "needs an IP Address (IPAddress)";
  313. }
  314. m_internalEndPoint.Port =
  315. source.Configs[sectionName].GetInt("internal_ip_port", (int) NetworkServersInfo.DefaultHttpListenerPort);
  316. string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1");
  317. if (externalHost != "SYSTEMIP")
  318. {
  319. m_externalHostName = externalHost;
  320. }
  321. else
  322. {
  323. m_externalHostName = Util.GetLocalHost().ToString();
  324. }
  325. MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test");
  326. MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User");
  327. MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test");
  328. if (errorMessage != String.Empty)
  329. {
  330. // a error
  331. }
  332. }
  333. public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result)
  334. {
  335. return true;
  336. }
  337. public void SaveRegionToFile(string description, string filename)
  338. {
  339. configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe,
  340. ignoreIncomingConfiguration, false);
  341. configMember.performConfigurationRetrieve();
  342. RegionFile = filename;
  343. }
  344. public void loadConfigurationOptionsFromMe()
  345. {
  346. configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE,
  347. "UUID of Region (Default is recommended, random UUID)",
  348. RegionID.ToString(), true);
  349. configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  350. "Region Name", RegionName, true);
  351. configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  352. "Grid Location (X Axis)", m_regionLocX.ToString(), true);
  353. configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  354. "Grid Location (Y Axis)", m_regionLocY.ToString(), true);
  355. //configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
  356. configMember.addConfigurationOption("internal_ip_address",
  357. ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
  358. "Internal IP Address for incoming UDP client connections",
  359. m_internalEndPoint.Address.ToString(),
  360. true);
  361. configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  362. "Internal IP Port for incoming UDP client connections",
  363. m_internalEndPoint.Port.ToString(), true);
  364. configMember.addConfigurationOption("allow_alternate_ports",
  365. ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  366. "Allow sim to find alternate UDP ports when ports are in use?",
  367. m_allow_alternate_ports.ToString(), true);
  368. configMember.addConfigurationOption("external_host_name",
  369. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  370. "External Host Name", m_externalHostName, true);
  371. configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  372. "Master Avatar UUID", MasterAvatarAssignedUUID.ToString(), true);
  373. configMember.addConfigurationOption("master_avatar_first",
  374. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  375. "First Name of Master Avatar", MasterAvatarFirstName, true);
  376. configMember.addConfigurationOption("master_avatar_last",
  377. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  378. "Last Name of Master Avatar", MasterAvatarLastName, true);
  379. configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  380. "(Sandbox Mode Only)Password for Master Avatar account",
  381. MasterAvatarSandboxPassword, true);
  382. configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  383. "Last Map UUID", lastMapUUID.ToString(), true);
  384. configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  385. "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
  386. configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  387. "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true);
  388. configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  389. "Maximum size for physical prims", m_physPrimMax.ToString(), true);
  390. configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  391. "Clamp prims to max size", m_clampPrimSize.ToString(), true);
  392. configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  393. "Max objects this sim will hold", m_objectCapacity.ToString(), true);
  394. }
  395. public void loadConfigurationOptions()
  396. {
  397. configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  398. "UUID of Region (Default is recommended, random UUID)",
  399. UUID.Random().ToString(), true);
  400. configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  401. "Region Name", "OpenSim Test", false);
  402. configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  403. "Grid Location (X Axis)", "1000", false);
  404. configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  405. "Grid Location (Y Axis)", "1000", false);
  406. //configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
  407. configMember.addConfigurationOption("internal_ip_address",
  408. ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
  409. "Internal IP Address for incoming UDP client connections", "0.0.0.0",
  410. false);
  411. configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  412. "Internal IP Port for incoming UDP client connections",
  413. NetworkServersInfo.DefaultHttpListenerPort.ToString(), false);
  414. configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  415. "Allow sim to find alternate UDP ports when ports are in use?",
  416. "false", true);
  417. configMember.addConfigurationOption("external_host_name",
  418. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  419. "External Host Name", "127.0.0.1", false);
  420. configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  421. "Master Avatar UUID", UUID.Zero.ToString(), true);
  422. configMember.addConfigurationOption("master_avatar_first",
  423. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  424. "First Name of Master Avatar", "Test", false,
  425. (ConfigurationOption.ConfigurationOptionShouldBeAsked)
  426. shouldMasterAvatarDetailsBeAsked);
  427. configMember.addConfigurationOption("master_avatar_last",
  428. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  429. "Last Name of Master Avatar", "User", false,
  430. (ConfigurationOption.ConfigurationOptionShouldBeAsked)
  431. shouldMasterAvatarDetailsBeAsked);
  432. configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  433. "(Sandbox Mode Only)Password for Master Avatar account", "test", false,
  434. (ConfigurationOption.ConfigurationOptionShouldBeAsked)
  435. shouldMasterAvatarDetailsBeAsked);
  436. configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  437. "Last Map UUID", lastMapUUID.ToString(), true);
  438. configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  439. "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
  440. configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  441. "Maximum size for nonphysical prims", "0", true);
  442. configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  443. "Maximum size for physical prims", "0", true);
  444. configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  445. "Clamp prims to max size", "false", true);
  446. configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  447. "Max objects this sim will hold", "0", true);
  448. }
  449. public bool shouldMasterAvatarDetailsBeAsked(string configuration_key)
  450. {
  451. return MasterAvatarAssignedUUID == UUID.Zero;
  452. }
  453. public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
  454. {
  455. switch (configuration_key)
  456. {
  457. case "sim_UUID":
  458. RegionID = (UUID) configuration_result;
  459. originRegionID = (UUID) configuration_result;
  460. break;
  461. case "sim_name":
  462. RegionName = (string) configuration_result;
  463. break;
  464. case "sim_location_x":
  465. m_regionLocX = (uint) configuration_result;
  466. break;
  467. case "sim_location_y":
  468. m_regionLocY = (uint) configuration_result;
  469. break;
  470. case "datastore":
  471. DataStore = (string) configuration_result;
  472. break;
  473. case "internal_ip_address":
  474. IPAddress address = (IPAddress) configuration_result;
  475. m_internalEndPoint = new IPEndPoint(address, 0);
  476. break;
  477. case "internal_ip_port":
  478. m_internalEndPoint.Port = (int) configuration_result;
  479. break;
  480. case "allow_alternate_ports":
  481. m_allow_alternate_ports = (bool) configuration_result;
  482. break;
  483. case "external_host_name":
  484. if ((string) configuration_result != "SYSTEMIP")
  485. {
  486. m_externalHostName = (string) configuration_result;
  487. }
  488. else
  489. {
  490. m_externalHostName = Util.GetLocalHost().ToString();
  491. }
  492. break;
  493. case "master_avatar_uuid":
  494. MasterAvatarAssignedUUID = (UUID) configuration_result;
  495. break;
  496. case "master_avatar_first":
  497. MasterAvatarFirstName = (string) configuration_result;
  498. break;
  499. case "master_avatar_last":
  500. MasterAvatarLastName = (string) configuration_result;
  501. break;
  502. case "master_avatar_pass":
  503. MasterAvatarSandboxPassword = (string)configuration_result;
  504. break;
  505. case "lastmap_uuid":
  506. lastMapUUID = (UUID)configuration_result;
  507. break;
  508. case "lastmap_refresh":
  509. lastMapRefresh = (string)configuration_result;
  510. break;
  511. case "nonphysical_prim_max":
  512. m_nonphysPrimMax = (int)configuration_result;
  513. break;
  514. case "physical_prim_max":
  515. m_physPrimMax = (int)configuration_result;
  516. break;
  517. case "clamp_prim_size":
  518. m_clampPrimSize = (bool)configuration_result;
  519. break;
  520. case "object_capacity":
  521. m_objectCapacity = (int)configuration_result;
  522. break;
  523. }
  524. return true;
  525. }
  526. public void SaveLastMapUUID(UUID mapUUID)
  527. {
  528. if (null == configMember) return;
  529. lastMapUUID = mapUUID;
  530. lastMapRefresh = Util.UnixTimeSinceEpoch().ToString();
  531. configMember.forceSetConfigurationOption("lastmap_uuid", mapUUID.ToString());
  532. configMember.forceSetConfigurationOption("lastmap_refresh", lastMapRefresh);
  533. }
  534. public OSDMap PackRegionInfoData()
  535. {
  536. OSDMap args = new OSDMap();
  537. args["region_id"] = OSD.FromUUID(RegionID);
  538. if ((RegionName != null) && !RegionName.Equals(""))
  539. args["region_name"] = OSD.FromString(RegionName);
  540. args["external_host_name"] = OSD.FromString(ExternalHostName);
  541. args["http_port"] = OSD.FromString(HttpPort.ToString());
  542. args["server_uri"] = OSD.FromString(ServerURI);
  543. args["region_xloc"] = OSD.FromString(RegionLocX.ToString());
  544. args["region_yloc"] = OSD.FromString(RegionLocY.ToString());
  545. args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString());
  546. args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString());
  547. if ((RemotingAddress != null) && !RemotingAddress.Equals(""))
  548. args["remoting_address"] = OSD.FromString(RemotingAddress);
  549. args["remoting_port"] = OSD.FromString(RemotingPort.ToString());
  550. args["allow_alt_ports"] = OSD.FromBoolean(m_allow_alternate_ports);
  551. if ((proxyUrl != null) && !proxyUrl.Equals(""))
  552. args["proxy_url"] = OSD.FromString(proxyUrl);
  553. return args;
  554. }
  555. public void UnpackRegionInfoData(OSDMap args)
  556. {
  557. if (args["region_id"] != null)
  558. RegionID = args["region_id"].AsUUID();
  559. if (args["region_name"] != null)
  560. RegionName = args["region_name"].AsString();
  561. if (args["external_host_name"] != null)
  562. ExternalHostName = args["external_host_name"].AsString();
  563. if (args["http_port"] != null)
  564. UInt32.TryParse(args["http_port"].AsString(), out m_httpPort);
  565. if (args["server_uri"] != null)
  566. ServerURI = args["server_uri"].AsString();
  567. if (args["region_xloc"] != null)
  568. {
  569. uint locx;
  570. UInt32.TryParse(args["region_xloc"].AsString(), out locx);
  571. RegionLocX = locx;
  572. }
  573. if (args["region_yloc"] != null)
  574. {
  575. uint locy;
  576. UInt32.TryParse(args["region_yloc"].AsString(), out locy);
  577. RegionLocY = locy;
  578. }
  579. IPAddress ip_addr = null;
  580. if (args["internal_ep_address"] != null)
  581. {
  582. IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr);
  583. }
  584. int port = 0;
  585. if (args["internal_ep_port"] != null)
  586. {
  587. Int32.TryParse(args["internal_ep_port"].AsString(), out port);
  588. }
  589. InternalEndPoint = new IPEndPoint(ip_addr, port);
  590. if (args["remoting_address"] != null)
  591. RemotingAddress = args["remoting_address"].AsString();
  592. if (args["remoting_port"] != null)
  593. UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort);
  594. if (args["allow_alt_ports"] != null)
  595. m_allow_alternate_ports = args["allow_alt_ports"].AsBoolean();
  596. if (args["proxy_url"] != null)
  597. proxyUrl = args["proxy_url"].AsString();
  598. }
  599. }
  600. }