RegionInfo.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using OpenSim.Framework.Interfaces;
  5. using OpenSim.Framework.Utilities;
  6. using libsecondlife;
  7. namespace OpenSim
  8. {
  9. public class RegionInfo // could inherit from SimProfileBase
  10. {
  11. public LLUUID SimUUID;
  12. public string RegionName;
  13. public uint RegionLocX;
  14. public uint RegionLocY;
  15. public ulong RegionHandle;
  16. public int IPListenPort;
  17. public string IPListenAddr;
  18. //following should be removed and the GenericConfig object passed around,
  19. //so each class (AssetServer, GridServer etc) can access what config data they want
  20. public string AssetURL = "";
  21. public string AssetSendKey = "";
  22. public string GridURL = "";
  23. public string GridSendKey = "";
  24. public string GridRecvKey = "";
  25. public string UserURL = "";
  26. public string UserSendKey = "";
  27. public string UserRecvKey = "";
  28. private bool isSandbox;
  29. public RegionInfo()
  30. {
  31. }
  32. public void InitConfig(bool sandboxMode, IGenericConfig configData)
  33. {
  34. this.isSandbox = sandboxMode;
  35. try
  36. {
  37. // Sim UUID
  38. string attri = "";
  39. attri = configData.GetAttribute("SimUUID");
  40. if (attri == "")
  41. {
  42. this.SimUUID = LLUUID.Random();
  43. configData.SetAttribute("SimUUID", this.SimUUID.ToString());
  44. }
  45. else
  46. {
  47. this.SimUUID = new LLUUID(attri);
  48. }
  49. // Sim name
  50. attri = "";
  51. attri = configData.GetAttribute("SimName");
  52. if (attri == "")
  53. {
  54. this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ", "OpenSim test");
  55. configData.SetAttribute("SimName", this.RegionName);
  56. }
  57. else
  58. {
  59. this.RegionName = attri;
  60. }
  61. // Sim/Grid location X
  62. attri = "";
  63. attri = configData.GetAttribute("SimLocationX");
  64. if (attri == "")
  65. {
  66. string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ", "997");
  67. configData.SetAttribute("SimLocationX", location);
  68. this.RegionLocX = (uint)Convert.ToUInt32(location);
  69. }
  70. else
  71. {
  72. this.RegionLocX = (uint)Convert.ToUInt32(attri);
  73. }
  74. // Sim/Grid location Y
  75. attri = "";
  76. attri = configData.GetAttribute("SimLocationY");
  77. if (attri == "")
  78. {
  79. string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ", "996");
  80. configData.SetAttribute("SimLocationY", location);
  81. this.RegionLocY = (uint)Convert.ToUInt32(location);
  82. }
  83. else
  84. {
  85. this.RegionLocY = (uint)Convert.ToUInt32(attri);
  86. }
  87. //Sim Listen Port
  88. attri = "";
  89. attri = configData.GetAttribute("SimListenPort");
  90. if (attri == "")
  91. {
  92. string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ", "9000");
  93. configData.SetAttribute("SimListenPort", port);
  94. this.IPListenPort = Convert.ToInt32(port);
  95. }
  96. else
  97. {
  98. this.IPListenPort = Convert.ToInt32(attri);
  99. }
  100. //Sim Listen Address
  101. attri = "";
  102. attri = configData.GetAttribute("SimListenAddress");
  103. if (attri == "")
  104. {
  105. this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1");
  106. configData.SetAttribute("SimListenAddress", this.IPListenAddr);
  107. }
  108. else
  109. {
  110. this.IPListenAddr = attri;
  111. }
  112. if (!isSandbox)
  113. {
  114. //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object
  115. // Asset Server URL
  116. attri = "";
  117. attri = configData.GetAttribute("AssetServerURL");
  118. if (attri == "")
  119. {
  120. this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL: ");
  121. configData.SetAttribute("AssetServerURL", this.AssetURL);
  122. }
  123. else
  124. {
  125. this.AssetURL = attri;
  126. }
  127. //Asset Server key
  128. attri = "";
  129. attri = configData.GetAttribute("AssetServerKey");
  130. if (attri == "")
  131. {
  132. this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server key: ");
  133. configData.SetAttribute("AssetServerKey", this.AssetSendKey);
  134. }
  135. else
  136. {
  137. this.AssetSendKey = attri;
  138. }
  139. //Grid Sever URL
  140. attri = "";
  141. attri = configData.GetAttribute("GridServerURL");
  142. if (attri == "")
  143. {
  144. this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: ");
  145. configData.SetAttribute("GridServerURL", this.GridURL);
  146. }
  147. else
  148. {
  149. this.GridURL = attri;
  150. }
  151. //Grid Send Key
  152. attri = "";
  153. attri = configData.GetAttribute("GridSendKey");
  154. if (attri == "")
  155. {
  156. this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: ");
  157. configData.SetAttribute("GridSendKey", this.GridSendKey);
  158. }
  159. else
  160. {
  161. this.GridSendKey = attri;
  162. }
  163. //Grid Receive Key
  164. attri = "";
  165. attri = configData.GetAttribute("GridRecvKey");
  166. if (attri == "")
  167. {
  168. this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: ");
  169. configData.SetAttribute("GridRecvKey", this.GridRecvKey);
  170. }
  171. else
  172. {
  173. this.GridRecvKey = attri;
  174. }
  175. //User Server URL
  176. attri = "";
  177. attri = configData.GetAttribute("UserServerURL");
  178. if (attri == "")
  179. {
  180. this.UserURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("User server URL: ");
  181. configData.SetAttribute("UserServerURL", this.UserURL);
  182. }
  183. else
  184. {
  185. this.UserURL = attri;
  186. }
  187. //User Send Key
  188. attri = "";
  189. attri = configData.GetAttribute("UserSendKey");
  190. if (attri == "")
  191. {
  192. this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
  193. configData.SetAttribute("UserSendKey", this.UserSendKey);
  194. }
  195. else
  196. {
  197. this.UserSendKey = attri;
  198. }
  199. //User Receive Key
  200. attri = "";
  201. attri = configData.GetAttribute("UserRecvKey");
  202. if (attri == "")
  203. {
  204. this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
  205. configData.SetAttribute("UserRecvKey", this.UserRecvKey);
  206. }
  207. else
  208. {
  209. this.UserRecvKey = attri;
  210. }
  211. }
  212. this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
  213. configData.Commit();
  214. }
  215. catch (Exception e)
  216. {
  217. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured");
  218. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString());
  219. }
  220. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:");
  221. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("UUID: " + this.SimUUID.ToStringHyphenated());
  222. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName);
  223. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
  224. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString());
  225. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
  226. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString());
  227. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL);
  228. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey);
  229. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL);
  230. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey);
  231. }
  232. }
  233. }