RegionInfo.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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 string RegionName = String.Empty;
  182. public string regionSecret = UUID.Random().ToString();
  183. public UUID lastMapUUID = UUID.Zero;
  184. public string lastMapRefresh = "0";
  185. private int m_nonphysPrimMax = 0;
  186. private int m_physPrimMax = 0;
  187. private bool m_clampPrimSize = false;
  188. private int m_objectCapacity = 0;
  189. // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
  190. // MT: Yes. Estates can't span trust boundaries. Therefore, it can be
  191. // assumed that all instances belonging to one estate are able to
  192. // access the same database server. Since estate settings are lodaed
  193. // from there, that should be sufficient for full remote administration
  194. public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource)
  195. {
  196. //m_configSource = configSource;
  197. configMember =
  198. new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
  199. configMember.performConfigurationRetrieve();
  200. RegionFile = filename;
  201. }
  202. public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource)
  203. {
  204. //m_configSource = configSource;
  205. configMember =
  206. new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig);
  207. configMember.performConfigurationRetrieve();
  208. }
  209. public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) :
  210. base(regionLocX, regionLocY, internalEndPoint, externalUri)
  211. {
  212. }
  213. public RegionInfo()
  214. {
  215. }
  216. public RegionInfo(SerializableRegionInfo ConvertFrom)
  217. {
  218. m_regionLocX = ConvertFrom.RegionLocX;
  219. m_regionLocY = ConvertFrom.RegionLocY;
  220. m_internalEndPoint = ConvertFrom.InternalEndPoint;
  221. m_externalHostName = ConvertFrom.ExternalHostName;
  222. m_remotingPort = ConvertFrom.RemotingPort;
  223. m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
  224. RemotingAddress = ConvertFrom.RemotingAddress;
  225. RegionID = UUID.Zero;
  226. proxyUrl = ConvertFrom.ProxyUrl;
  227. originRegionID = ConvertFrom.OriginRegionID;
  228. RegionName = ConvertFrom.RegionName;
  229. ServerURI = ConvertFrom.ServerURI;
  230. }
  231. public RegionInfo(SimpleRegionInfo ConvertFrom)
  232. {
  233. m_regionLocX = ConvertFrom.RegionLocX;
  234. m_regionLocY = ConvertFrom.RegionLocY;
  235. m_internalEndPoint = ConvertFrom.InternalEndPoint;
  236. m_externalHostName = ConvertFrom.ExternalHostName;
  237. m_remotingPort = ConvertFrom.RemotingPort;
  238. m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
  239. RemotingAddress = ConvertFrom.RemotingAddress;
  240. RegionID = UUID.Zero;
  241. ServerURI = ConvertFrom.ServerURI;
  242. }
  243. public EstateSettings EstateSettings
  244. {
  245. get
  246. {
  247. if (m_estateSettings == null)
  248. {
  249. m_estateSettings = new EstateSettings();
  250. }
  251. return m_estateSettings;
  252. }
  253. set { m_estateSettings = value; }
  254. }
  255. public RegionSettings RegionSettings
  256. {
  257. get
  258. {
  259. if (m_regionSettings == null)
  260. {
  261. m_regionSettings = new RegionSettings();
  262. }
  263. return m_regionSettings;
  264. }
  265. set { m_regionSettings = value; }
  266. }
  267. public int NonphysPrimMax
  268. {
  269. get { return m_nonphysPrimMax; }
  270. }
  271. public int PhysPrimMax
  272. {
  273. get { return m_physPrimMax; }
  274. }
  275. public bool ClampPrimSize
  276. {
  277. get { return m_clampPrimSize; }
  278. }
  279. public int ObjectCapacity
  280. {
  281. get { return m_objectCapacity; }
  282. }
  283. public void SetEndPoint(string ipaddr, int port)
  284. {
  285. IPAddress tmpIP = IPAddress.Parse(ipaddr);
  286. IPEndPoint tmpEPE = new IPEndPoint(tmpIP, port);
  287. m_internalEndPoint = tmpEPE;
  288. }
  289. //not in use, should swap to nini though.
  290. public void LoadFromNiniSource(IConfigSource source)
  291. {
  292. LoadFromNiniSource(source, "RegionInfo");
  293. }
  294. //not in use, should swap to nini though.
  295. public void LoadFromNiniSource(IConfigSource source, string sectionName)
  296. {
  297. string errorMessage = String.Empty;
  298. RegionID = new UUID(source.Configs[sectionName].GetString("Region_ID", UUID.Random().ToString()));
  299. RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test");
  300. m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000"));
  301. m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000"));
  302. // this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db");
  303. string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0");
  304. IPAddress ipAddressResult;
  305. if (IPAddress.TryParse(ipAddress, out ipAddressResult))
  306. {
  307. m_internalEndPoint = new IPEndPoint(ipAddressResult, 0);
  308. }
  309. else
  310. {
  311. errorMessage = "needs an IP Address (IPAddress)";
  312. }
  313. m_internalEndPoint.Port =
  314. source.Configs[sectionName].GetInt("internal_ip_port", (int) NetworkServersInfo.DefaultHttpListenerPort);
  315. string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1");
  316. if (externalHost != "SYSTEMIP")
  317. {
  318. m_externalHostName = externalHost;
  319. }
  320. else
  321. {
  322. m_externalHostName = Util.GetLocalHost().ToString();
  323. }
  324. MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test");
  325. MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User");
  326. MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test");
  327. if (errorMessage != String.Empty)
  328. {
  329. // a error
  330. }
  331. }
  332. public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result)
  333. {
  334. return true;
  335. }
  336. public void SaveRegionToFile(string description, string filename)
  337. {
  338. configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe,
  339. ignoreIncomingConfiguration, false);
  340. configMember.performConfigurationRetrieve();
  341. RegionFile = filename;
  342. }
  343. public void loadConfigurationOptionsFromMe()
  344. {
  345. configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE,
  346. "UUID of Region (Default is recommended, random UUID)",
  347. RegionID.ToString(), true);
  348. configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  349. "Region Name", RegionName, true);
  350. configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  351. "Grid Location (X Axis)", m_regionLocX.ToString(), true);
  352. configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  353. "Grid Location (Y Axis)", m_regionLocY.ToString(), true);
  354. //configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
  355. configMember.addConfigurationOption("internal_ip_address",
  356. ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
  357. "Internal IP Address for incoming UDP client connections",
  358. m_internalEndPoint.Address.ToString(),
  359. true);
  360. configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  361. "Internal IP Port for incoming UDP client connections",
  362. m_internalEndPoint.Port.ToString(), true);
  363. configMember.addConfigurationOption("allow_alternate_ports",
  364. ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  365. "Allow sim to find alternate UDP ports when ports are in use?",
  366. m_allow_alternate_ports.ToString(), true);
  367. configMember.addConfigurationOption("external_host_name",
  368. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  369. "External Host Name", m_externalHostName, true);
  370. configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  371. "Master Avatar UUID", MasterAvatarAssignedUUID.ToString(), true);
  372. configMember.addConfigurationOption("master_avatar_first",
  373. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  374. "First Name of Master Avatar", MasterAvatarFirstName, true);
  375. configMember.addConfigurationOption("master_avatar_last",
  376. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  377. "Last Name of Master Avatar", MasterAvatarLastName, true);
  378. configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  379. "(Sandbox Mode Only)Password for Master Avatar account",
  380. MasterAvatarSandboxPassword, true);
  381. configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  382. "Last Map UUID", lastMapUUID.ToString(), true);
  383. configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  384. "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
  385. configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  386. "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true);
  387. configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  388. "Maximum size for physical prims", m_physPrimMax.ToString(), true);
  389. configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  390. "Clamp prims to max size", m_clampPrimSize.ToString(), true);
  391. configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  392. "Max objects this sim will hold", m_objectCapacity.ToString(), true);
  393. }
  394. public void loadConfigurationOptions()
  395. {
  396. configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  397. "UUID of Region (Default is recommended, random UUID)",
  398. UUID.Random().ToString(), true);
  399. configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  400. "Region Name", "OpenSim Test", false);
  401. configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  402. "Grid Location (X Axis)", "1000", false);
  403. configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  404. "Grid Location (Y Axis)", "1000", false);
  405. //configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
  406. configMember.addConfigurationOption("internal_ip_address",
  407. ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
  408. "Internal IP Address for incoming UDP client connections", "0.0.0.0",
  409. false);
  410. configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  411. "Internal IP Port for incoming UDP client connections",
  412. NetworkServersInfo.DefaultHttpListenerPort.ToString(), false);
  413. configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  414. "Allow sim to find alternate UDP ports when ports are in use?",
  415. "false", true);
  416. configMember.addConfigurationOption("external_host_name",
  417. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  418. "External Host Name", "127.0.0.1", false);
  419. configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  420. "Master Avatar UUID", UUID.Zero.ToString(), true);
  421. configMember.addConfigurationOption("master_avatar_first",
  422. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  423. "First Name of Master Avatar", "Test", false,
  424. (ConfigurationOption.ConfigurationOptionShouldBeAsked)
  425. shouldMasterAvatarDetailsBeAsked);
  426. configMember.addConfigurationOption("master_avatar_last",
  427. ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  428. "Last Name of Master Avatar", "User", false,
  429. (ConfigurationOption.ConfigurationOptionShouldBeAsked)
  430. shouldMasterAvatarDetailsBeAsked);
  431. configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  432. "(Sandbox Mode Only)Password for Master Avatar account", "test", false,
  433. (ConfigurationOption.ConfigurationOptionShouldBeAsked)
  434. shouldMasterAvatarDetailsBeAsked);
  435. configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  436. "Last Map UUID", lastMapUUID.ToString(), true);
  437. configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
  438. "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
  439. configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  440. "Maximum size for nonphysical prims", "0", true);
  441. configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  442. "Maximum size for physical prims", "0", true);
  443. configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
  444. "Clamp prims to max size", "false", true);
  445. configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  446. "Max objects this sim will hold", "0", true);
  447. }
  448. public bool shouldMasterAvatarDetailsBeAsked(string configuration_key)
  449. {
  450. return MasterAvatarAssignedUUID == UUID.Zero;
  451. }
  452. public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
  453. {
  454. switch (configuration_key)
  455. {
  456. case "sim_UUID":
  457. RegionID = (UUID) configuration_result;
  458. originRegionID = (UUID) configuration_result;
  459. break;
  460. case "sim_name":
  461. RegionName = (string) configuration_result;
  462. break;
  463. case "sim_location_x":
  464. m_regionLocX = (uint) configuration_result;
  465. break;
  466. case "sim_location_y":
  467. m_regionLocY = (uint) configuration_result;
  468. break;
  469. case "datastore":
  470. DataStore = (string) configuration_result;
  471. break;
  472. case "internal_ip_address":
  473. IPAddress address = (IPAddress) configuration_result;
  474. m_internalEndPoint = new IPEndPoint(address, 0);
  475. break;
  476. case "internal_ip_port":
  477. m_internalEndPoint.Port = (int) configuration_result;
  478. break;
  479. case "allow_alternate_ports":
  480. m_allow_alternate_ports = (bool) configuration_result;
  481. break;
  482. case "external_host_name":
  483. if ((string) configuration_result != "SYSTEMIP")
  484. {
  485. m_externalHostName = (string) configuration_result;
  486. }
  487. else
  488. {
  489. m_externalHostName = Util.GetLocalHost().ToString();
  490. }
  491. break;
  492. case "master_avatar_uuid":
  493. MasterAvatarAssignedUUID = (UUID) configuration_result;
  494. break;
  495. case "master_avatar_first":
  496. MasterAvatarFirstName = (string) configuration_result;
  497. break;
  498. case "master_avatar_last":
  499. MasterAvatarLastName = (string) configuration_result;
  500. break;
  501. case "master_avatar_pass":
  502. MasterAvatarSandboxPassword = (string)configuration_result;
  503. break;
  504. case "lastmap_uuid":
  505. lastMapUUID = (UUID)configuration_result;
  506. break;
  507. case "lastmap_refresh":
  508. lastMapRefresh = (string)configuration_result;
  509. break;
  510. case "nonphysical_prim_max":
  511. m_nonphysPrimMax = (int)configuration_result;
  512. break;
  513. case "physical_prim_max":
  514. m_physPrimMax = (int)configuration_result;
  515. break;
  516. case "clamp_prim_size":
  517. m_clampPrimSize = (bool)configuration_result;
  518. break;
  519. case "object_capacity":
  520. m_objectCapacity = (int)configuration_result;
  521. break;
  522. }
  523. return true;
  524. }
  525. public void SaveLastMapUUID(UUID mapUUID)
  526. {
  527. if (null == configMember) return;
  528. lastMapUUID = mapUUID;
  529. lastMapRefresh = Util.UnixTimeSinceEpoch().ToString();
  530. configMember.forceSetConfigurationOption("lastmap_uuid", mapUUID.ToString());
  531. configMember.forceSetConfigurationOption("lastmap_refresh", lastMapRefresh);
  532. }
  533. public OSDMap PackRegionInfoData()
  534. {
  535. OSDMap args = new OSDMap();
  536. args["region_id"] = OSD.FromUUID(RegionID);
  537. if ((RegionName != null) && !RegionName.Equals(""))
  538. args["region_name"] = OSD.FromString(RegionName);
  539. args["external_host_name"] = OSD.FromString(ExternalHostName);
  540. args["http_port"] = OSD.FromString(HttpPort.ToString());
  541. args["server_uri"] = OSD.FromString(ServerURI);
  542. args["region_xloc"] = OSD.FromString(RegionLocX.ToString());
  543. args["region_yloc"] = OSD.FromString(RegionLocY.ToString());
  544. args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString());
  545. args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString());
  546. if ((RemotingAddress != null) && !RemotingAddress.Equals(""))
  547. args["remoting_address"] = OSD.FromString(RemotingAddress);
  548. args["remoting_port"] = OSD.FromString(RemotingPort.ToString());
  549. args["allow_alt_ports"] = OSD.FromBoolean(m_allow_alternate_ports);
  550. if ((proxyUrl != null) && !proxyUrl.Equals(""))
  551. args["proxy_url"] = OSD.FromString(proxyUrl);
  552. return args;
  553. }
  554. public void UnpackRegionInfoData(OSDMap args)
  555. {
  556. if (args["region_id"] != null)
  557. RegionID = args["region_id"].AsUUID();
  558. if (args["region_name"] != null)
  559. RegionName = args["region_name"].AsString();
  560. if (args["external_host_name"] != null)
  561. ExternalHostName = args["external_host_name"].AsString();
  562. if (args["http_port"] != null)
  563. UInt32.TryParse(args["http_port"].AsString(), out m_httpPort);
  564. if (args["server_uri"] != null)
  565. ServerURI = args["server_uri"].AsString();
  566. if (args["region_xloc"] != null)
  567. {
  568. uint locx;
  569. UInt32.TryParse(args["region_xloc"].AsString(), out locx);
  570. RegionLocX = locx;
  571. }
  572. if (args["region_yloc"] != null)
  573. {
  574. uint locy;
  575. UInt32.TryParse(args["region_yloc"].AsString(), out locy);
  576. RegionLocY = locy;
  577. }
  578. IPAddress ip_addr = null;
  579. if (args["internal_ep_address"] != null)
  580. {
  581. IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr);
  582. }
  583. int port = 0;
  584. if (args["internal_ep_port"] != null)
  585. {
  586. Int32.TryParse(args["internal_ep_port"].AsString(), out port);
  587. }
  588. InternalEndPoint = new IPEndPoint(ip_addr, port);
  589. if (args["remoting_address"] != null)
  590. RemotingAddress = args["remoting_address"].AsString();
  591. if (args["remoting_port"] != null)
  592. UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort);
  593. if (args["allow_alt_ports"] != null)
  594. m_allow_alternate_ports = args["allow_alt_ports"].AsBoolean();
  595. if (args["proxy_url"] != null)
  596. proxyUrl = args["proxy_url"].AsString();
  597. }
  598. }
  599. }