RegionInfo.cs 29 KB

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