RegionProfileData.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.Collections;
  29. using libsecondlife;
  30. using Nwc.XmlRpc;
  31. using OpenSim.Framework;
  32. namespace OpenSim.Data
  33. {
  34. /// <summary>
  35. /// A class which contains information known to the grid server about a region
  36. /// </summary>
  37. public class RegionProfileData
  38. {
  39. /// <summary>
  40. /// The name of the region
  41. /// </summary>
  42. public string regionName = String.Empty;
  43. /// <summary>
  44. /// A 64-bit number combining map position into a (mostly) unique ID
  45. /// </summary>
  46. public ulong regionHandle;
  47. /// <summary>
  48. /// OGS/OpenSim Specific ID for a region
  49. /// </summary>
  50. public LLUUID UUID;
  51. /// <summary>
  52. /// Coordinates of the region
  53. /// </summary>
  54. public uint regionLocX;
  55. public uint regionLocY;
  56. public uint regionLocZ; // Reserved (round-robin, layers, etc)
  57. /// <summary>
  58. /// Authentication secrets
  59. /// </summary>
  60. /// <remarks>Not very secure, needs improvement.</remarks>
  61. public string regionSendKey = String.Empty;
  62. public string regionRecvKey = String.Empty;
  63. public string regionSecret = String.Empty;
  64. /// <summary>
  65. /// Whether the region is online
  66. /// </summary>
  67. public bool regionOnline;
  68. /// <summary>
  69. /// Information about the server that the region is currently hosted on
  70. /// </summary>
  71. public string serverIP = String.Empty;
  72. public uint serverPort;
  73. public string serverURI = String.Empty;
  74. public uint httpPort;
  75. public uint remotingPort;
  76. public string httpServerURI = String.Empty;
  77. /// <summary>
  78. /// Set of optional overrides. Can be used to create non-eulicidean spaces.
  79. /// </summary>
  80. public ulong regionNorthOverrideHandle;
  81. public ulong regionSouthOverrideHandle;
  82. public ulong regionEastOverrideHandle;
  83. public ulong regionWestOverrideHandle;
  84. /// <summary>
  85. /// Optional: URI Location of the region database
  86. /// </summary>
  87. /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
  88. public string regionDataURI = String.Empty;
  89. /// <summary>
  90. /// Region Asset Details
  91. /// </summary>
  92. public string regionAssetURI = String.Empty;
  93. public string regionAssetSendKey = String.Empty;
  94. public string regionAssetRecvKey = String.Empty;
  95. /// <summary>
  96. /// Region Userserver Details
  97. /// </summary>
  98. public string regionUserURI = String.Empty;
  99. public string regionUserSendKey = String.Empty;
  100. public string regionUserRecvKey = String.Empty;
  101. /// <summary>
  102. /// Region Map Texture Asset
  103. /// </summary>
  104. public LLUUID regionMapTextureID = new LLUUID("00000000-0000-1111-9999-000000000006");
  105. /// <summary>
  106. /// this particular mod to the file provides support within the spec for RegionProfileData for the
  107. /// owner_uuid for the region
  108. /// </summary>
  109. public LLUUID owner_uuid = LLUUID.Zero;
  110. /// <summary>
  111. /// OGS/OpenSim Specific original ID for a region after move/split
  112. /// </summary>
  113. public LLUUID originUUID;
  114. /// <summary>
  115. /// Get Sim profile data from grid server when in grid mode
  116. /// </summary>
  117. /// <param name="region_uuid"></param>
  118. /// <param name="gridserver_url"></param>
  119. /// <param name="?"></param>
  120. /// <returns></returns>
  121. public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url,
  122. string gridserver_sendkey, string gridserver_recvkey)
  123. {
  124. Hashtable requestData = new Hashtable();
  125. requestData["region_uuid"] = region_uuid.UUID.ToString();
  126. requestData["authkey"] = gridserver_sendkey;
  127. ArrayList SendParams = new ArrayList();
  128. SendParams.Add(requestData);
  129. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  130. XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
  131. Hashtable responseData = (Hashtable) GridResp.Value;
  132. if (responseData.ContainsKey("error"))
  133. {
  134. return null;
  135. }
  136. RegionProfileData simData = new RegionProfileData();
  137. simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]);
  138. simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]);
  139. simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize));
  140. simData.serverIP = (string) responseData["sim_ip"];
  141. simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
  142. simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
  143. simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
  144. simData.serverURI = (string)responseData["server_uri"];
  145. simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
  146. simData.UUID = new LLUUID((string) responseData["region_UUID"]);
  147. simData.regionName = (string) responseData["region_name"];
  148. return simData;
  149. }
  150. /// <summary>
  151. /// Request sim profile information from a grid server
  152. /// </summary>
  153. /// <param name="region_handle"></param>
  154. /// <param name="gridserver_url"></param>
  155. /// <param name="gridserver_sendkey"></param>
  156. /// <param name="gridserver_recvkey"></param>
  157. /// <returns>The sim profile. Null if there was a request failure</returns>
  158. public static RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url,
  159. string gridserver_sendkey, string gridserver_recvkey)
  160. {
  161. Hashtable requestData = new Hashtable();
  162. requestData["region_handle"] = region_handle.ToString();
  163. requestData["authkey"] = gridserver_sendkey;
  164. ArrayList SendParams = new ArrayList();
  165. SendParams.Add(requestData);
  166. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  167. XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
  168. Hashtable responseData = (Hashtable) GridResp.Value;
  169. if (responseData.ContainsKey("error"))
  170. {
  171. return null;
  172. }
  173. RegionProfileData simData = new RegionProfileData();
  174. simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]);
  175. simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]);
  176. simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize));
  177. simData.serverIP = (string) responseData["sim_ip"];
  178. simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]);
  179. simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]);
  180. simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]);
  181. simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
  182. simData.serverURI = (string)responseData["server_uri"];
  183. simData.UUID = new LLUUID((string) responseData["region_UUID"]);
  184. simData.regionName = (string) responseData["region_name"];
  185. return simData;
  186. }
  187. /// <summary>
  188. /// Request sim profile information from a grid server
  189. /// </summary>
  190. /// <param name="region_handle"></param>
  191. /// <param name="gridserver_url"></param>
  192. /// <param name="gridserver_sendkey"></param>
  193. /// <param name="gridserver_recvkey"></param>
  194. /// <returns>The sim profile. Null if there was a request failure</returns>
  195. public static RegionProfileData RequestSimProfileData(string regionName, string gridserver_url,
  196. string gridserver_sendkey, string gridserver_recvkey)
  197. {
  198. Hashtable requestData = new Hashtable();
  199. requestData["region_name_search"] = regionName;
  200. requestData["authkey"] = gridserver_sendkey;
  201. ArrayList SendParams = new ArrayList();
  202. SendParams.Add(requestData);
  203. XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
  204. XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000);
  205. Hashtable responseData = (Hashtable)GridResp.Value;
  206. if (responseData.ContainsKey("error"))
  207. {
  208. return null;
  209. }
  210. RegionProfileData simData = new RegionProfileData();
  211. simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]);
  212. simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]);
  213. simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize));
  214. simData.serverIP = (string)responseData["sim_ip"];
  215. simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]);
  216. simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]);
  217. simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
  218. simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/";
  219. simData.serverURI = (string)responseData["server_uri"];
  220. simData.UUID = new LLUUID((string)responseData["region_UUID"]);
  221. simData.regionName = (string)responseData["region_name"];
  222. return simData;
  223. }
  224. }
  225. }