diff options
author | Jeff Ames | 2009-02-22 01:18:49 +0000 |
---|---|---|
committer | Jeff Ames | 2009-02-22 01:18:49 +0000 |
commit | 551bebdc84515d77bc3d7a564100efd0525a1949 (patch) | |
tree | 1e3300c3a60d51a5607b69ee357f1d08936014f3 /OpenSim/Grid/GridServer/GridXmlRpcModule.cs | |
parent | Applied patch from mantis #3217, which allows Dynamic Images of type RGB (so ... (diff) | |
download | opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.zip opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.tar.gz opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.tar.bz2 opensim-SC_OLD-551bebdc84515d77bc3d7a564100efd0525a1949.tar.xz |
Update svn properties, add copyright headers, minor formatting cleanup.
Diffstat (limited to 'OpenSim/Grid/GridServer/GridXmlRpcModule.cs')
-rw-r--r-- | OpenSim/Grid/GridServer/GridXmlRpcModule.cs | 1754 |
1 files changed, 877 insertions, 877 deletions
diff --git a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs b/OpenSim/Grid/GridServer/GridXmlRpcModule.cs index 86df81c..f320ccc 100644 --- a/OpenSim/Grid/GridServer/GridXmlRpcModule.cs +++ b/OpenSim/Grid/GridServer/GridXmlRpcModule.cs | |||
@@ -1,877 +1,877 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Xml; | 33 | using System.Xml; |
34 | using log4net; | 34 | using log4net; |
35 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Data; | 37 | using OpenSim.Data; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Framework.Servers; | 40 | using OpenSim.Framework.Servers; |
41 | 41 | ||
42 | namespace OpenSim.Grid.GridServer | 42 | namespace OpenSim.Grid.GridServer |
43 | { | 43 | { |
44 | public class GridXmlRpcModule | 44 | public class GridXmlRpcModule |
45 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private GridDBService m_gridDBService; | 48 | private GridDBService m_gridDBService; |
49 | private IUGAIMCore m_gridCore; | 49 | private IUGAIMCore m_gridCore; |
50 | 50 | ||
51 | protected GridConfig m_config; | 51 | protected GridConfig m_config; |
52 | 52 | ||
53 | /// <value> | 53 | /// <value> |
54 | /// Used to notify old regions as to which OpenSim version to upgrade to | 54 | /// Used to notify old regions as to which OpenSim version to upgrade to |
55 | /// </value> | 55 | /// </value> |
56 | private string m_opensimVersion; | 56 | private string m_opensimVersion; |
57 | 57 | ||
58 | protected BaseHttpServer m_httpServer; | 58 | protected BaseHttpServer m_httpServer; |
59 | 59 | ||
60 | /// <summary> | 60 | /// <summary> |
61 | /// Constructor | 61 | /// Constructor |
62 | /// </summary> | 62 | /// </summary> |
63 | /// <param name="opensimVersion"> | 63 | /// <param name="opensimVersion"> |
64 | /// Used to notify old regions as to which OpenSim version to upgrade to | 64 | /// Used to notify old regions as to which OpenSim version to upgrade to |
65 | /// </param> | 65 | /// </param> |
66 | public GridXmlRpcModule() | 66 | public GridXmlRpcModule() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config) | 70 | public void Initialise(string opensimVersion, GridDBService gridDBService, IUGAIMCore gridCore, GridConfig config) |
71 | { | 71 | { |
72 | m_opensimVersion = opensimVersion; | 72 | m_opensimVersion = opensimVersion; |
73 | m_gridDBService = gridDBService; | 73 | m_gridDBService = gridDBService; |
74 | m_gridCore = gridCore; | 74 | m_gridCore = gridCore; |
75 | m_config = config; | 75 | m_config = config; |
76 | RegisterHandlers(); | 76 | RegisterHandlers(); |
77 | } | 77 | } |
78 | 78 | ||
79 | public void PostInitialise() | 79 | public void PostInitialise() |
80 | { | 80 | { |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | public void RegisterHandlers() | 84 | public void RegisterHandlers() |
85 | { | 85 | { |
86 | //have these in separate method as some servers restart the http server and reregister all the handlers. | 86 | //have these in separate method as some servers restart the http server and reregister all the handlers. |
87 | m_httpServer = m_gridCore.GetHttpServer(); | 87 | m_httpServer = m_gridCore.GetHttpServer(); |
88 | 88 | ||
89 | m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod); | 89 | m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod); |
90 | m_httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod); | 90 | m_httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod); |
91 | m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", XmlRpcDeleteRegionMethod); | 91 | m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", XmlRpcDeleteRegionMethod); |
92 | m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod); | 92 | m_httpServer.AddXmlRPCHandler("map_block", XmlRpcMapBlockMethod); |
93 | m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod); | 93 | m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod); |
94 | } | 94 | } |
95 | 95 | ||
96 | /// <summary> | 96 | /// <summary> |
97 | /// Returns a XML String containing a list of the neighbouring regions | 97 | /// Returns a XML String containing a list of the neighbouring regions |
98 | /// </summary> | 98 | /// </summary> |
99 | /// <param name="reqhandle">The regionhandle for the center sim</param> | 99 | /// <param name="reqhandle">The regionhandle for the center sim</param> |
100 | /// <returns>An XML string containing neighbour entities</returns> | 100 | /// <returns>An XML string containing neighbour entities</returns> |
101 | public string GetXMLNeighbours(ulong reqhandle) | 101 | public string GetXMLNeighbours(ulong reqhandle) |
102 | { | 102 | { |
103 | string response = String.Empty; | 103 | string response = String.Empty; |
104 | RegionProfileData central_region = m_gridDBService.GetRegion(reqhandle); | 104 | RegionProfileData central_region = m_gridDBService.GetRegion(reqhandle); |
105 | RegionProfileData neighbour; | 105 | RegionProfileData neighbour; |
106 | for (int x = -1; x < 2; x++) | 106 | for (int x = -1; x < 2; x++) |
107 | { | 107 | { |
108 | for (int y = -1; y < 2; y++) | 108 | for (int y = -1; y < 2; y++) |
109 | { | 109 | { |
110 | if ( | 110 | if ( |
111 | m_gridDBService.GetRegion( | 111 | m_gridDBService.GetRegion( |
112 | Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), | 112 | Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), |
113 | (uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null) | 113 | (uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null) |
114 | { | 114 | { |
115 | neighbour = | 115 | neighbour = |
116 | m_gridDBService.GetRegion( | 116 | m_gridDBService.GetRegion( |
117 | Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), | 117 | Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize), |
118 | (uint)(central_region.regionLocY + y) * Constants.RegionSize)); | 118 | (uint)(central_region.regionLocY + y) * Constants.RegionSize)); |
119 | 119 | ||
120 | response += "<neighbour>"; | 120 | response += "<neighbour>"; |
121 | response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>"; | 121 | response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>"; |
122 | response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>"; | 122 | response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>"; |
123 | response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>"; | 123 | response += "<locx>" + neighbour.regionLocX.ToString() + "</locx>"; |
124 | response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>"; | 124 | response += "<locy>" + neighbour.regionLocY.ToString() + "</locy>"; |
125 | response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>"; | 125 | response += "<regionhandle>" + neighbour.regionHandle.ToString() + "</regionhandle>"; |
126 | response += "</neighbour>"; | 126 | response += "</neighbour>"; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | return response; | 130 | return response; |
131 | } | 131 | } |
132 | 132 | ||
133 | /// <summary> | 133 | /// <summary> |
134 | /// Checks that it's valid to replace the existing region data with new data | 134 | /// Checks that it's valid to replace the existing region data with new data |
135 | /// | 135 | /// |
136 | /// Currently, this means ensure that the keys passed in by the new region | 136 | /// Currently, this means ensure that the keys passed in by the new region |
137 | /// match those in the original region. (XXX Is this correct? Shouldn't we simply check | 137 | /// match those in the original region. (XXX Is this correct? Shouldn't we simply check |
138 | /// against the keys in the current configuration?) | 138 | /// against the keys in the current configuration?) |
139 | /// </summary> | 139 | /// </summary> |
140 | /// <param name="sim"></param> | 140 | /// <param name="sim"></param> |
141 | /// <returns></returns> | 141 | /// <returns></returns> |
142 | protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim) | 142 | protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim) |
143 | { | 143 | { |
144 | if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) | 144 | if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) |
145 | { | 145 | { |
146 | throw new LoginException( | 146 | throw new LoginException( |
147 | String.Format( | 147 | String.Format( |
148 | "Authentication failed when trying to login existing region {0} at location {1} {2} currently occupied by {3}" | 148 | "Authentication failed when trying to login existing region {0} at location {1} {2} currently occupied by {3}" |
149 | + " with the region's send key {4} (expected {5}) and the region's receive key {6} (expected {7})", | 149 | + " with the region's send key {4} (expected {5}) and the region's receive key {6} (expected {7})", |
150 | sim.regionName, sim.regionLocX, sim.regionLocY, existingSim.regionName, | 150 | sim.regionName, sim.regionLocX, sim.regionLocY, existingSim.regionName, |
151 | sim.regionSendKey, existingSim.regionSendKey, sim.regionRecvKey, existingSim.regionRecvKey), | 151 | sim.regionSendKey, existingSim.regionSendKey, sim.regionRecvKey, existingSim.regionRecvKey), |
152 | "The keys required to login your region did not match the grid server keys. Please check your grid send and receive keys."); | 152 | "The keys required to login your region did not match the grid server keys. Please check your grid send and receive keys."); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | /// <summary> | 156 | /// <summary> |
157 | /// Checks that the new region data is valid. | 157 | /// Checks that the new region data is valid. |
158 | /// | 158 | /// |
159 | /// Currently, this means checking that the keys passed in by the new region | 159 | /// Currently, this means checking that the keys passed in by the new region |
160 | /// match those in the grid server's configuration. | 160 | /// match those in the grid server's configuration. |
161 | /// </summary> | 161 | /// </summary> |
162 | /// | 162 | /// |
163 | /// <param name="sim"></param> | 163 | /// <param name="sim"></param> |
164 | /// <exception cref="LoginException">Thrown if region login failed</exception> | 164 | /// <exception cref="LoginException">Thrown if region login failed</exception> |
165 | protected virtual void ValidateNewRegionKeys(RegionProfileData sim) | 165 | protected virtual void ValidateNewRegionKeys(RegionProfileData sim) |
166 | { | 166 | { |
167 | if (!(sim.regionRecvKey == m_config.SimSendKey && sim.regionSendKey == m_config.SimRecvKey)) | 167 | if (!(sim.regionRecvKey == m_config.SimSendKey && sim.regionSendKey == m_config.SimRecvKey)) |
168 | { | 168 | { |
169 | throw new LoginException( | 169 | throw new LoginException( |
170 | String.Format( | 170 | String.Format( |
171 | "Authentication failed when trying to login new region {0} at location {1} {2}" | 171 | "Authentication failed when trying to login new region {0} at location {1} {2}" |
172 | + " with the region's send key {3} (expected {4}) and the region's receive key {5} (expected {6})", | 172 | + " with the region's send key {3} (expected {4}) and the region's receive key {5} (expected {6})", |
173 | sim.regionName, sim.regionLocX, sim.regionLocY, | 173 | sim.regionName, sim.regionLocX, sim.regionLocY, |
174 | sim.regionSendKey, m_config.SimRecvKey, sim.regionRecvKey, m_config.SimSendKey), | 174 | sim.regionSendKey, m_config.SimRecvKey, sim.regionRecvKey, m_config.SimSendKey), |
175 | "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); | 175 | "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | /// <summary> | 179 | /// <summary> |
180 | /// Check that a region's http uri is externally contactable. | 180 | /// Check that a region's http uri is externally contactable. |
181 | /// </summary> | 181 | /// </summary> |
182 | /// <param name="sim"></param> | 182 | /// <param name="sim"></param> |
183 | /// <exception cref="LoginException">Thrown if the region is not contactable</exception> | 183 | /// <exception cref="LoginException">Thrown if the region is not contactable</exception> |
184 | protected virtual void ValidateRegionContactable(RegionProfileData sim) | 184 | protected virtual void ValidateRegionContactable(RegionProfileData sim) |
185 | { | 185 | { |
186 | string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/"); | 186 | string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/"); |
187 | string regionStatusResponse; | 187 | string regionStatusResponse; |
188 | 188 | ||
189 | RestClient rc = new RestClient(regionStatusUrl); | 189 | RestClient rc = new RestClient(regionStatusUrl); |
190 | rc.RequestMethod = "GET"; | 190 | rc.RequestMethod = "GET"; |
191 | 191 | ||
192 | m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName); | 192 | m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName); |
193 | 193 | ||
194 | try | 194 | try |
195 | { | 195 | { |
196 | Stream rs = rc.Request(); | 196 | Stream rs = rc.Request(); |
197 | StreamReader sr = new StreamReader(rs); | 197 | StreamReader sr = new StreamReader(rs); |
198 | regionStatusResponse = sr.ReadToEnd(); | 198 | regionStatusResponse = sr.ReadToEnd(); |
199 | sr.Close(); | 199 | sr.Close(); |
200 | } | 200 | } |
201 | catch (Exception e) | 201 | catch (Exception e) |
202 | { | 202 | { |
203 | throw new LoginException( | 203 | throw new LoginException( |
204 | String.Format("Region status request to {0} failed", regionStatusUrl), | 204 | String.Format("Region status request to {0} failed", regionStatusUrl), |
205 | String.Format( | 205 | String.Format( |
206 | "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service", | 206 | "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service", |
207 | regionStatusUrl), | 207 | regionStatusUrl), |
208 | e); | 208 | e); |
209 | } | 209 | } |
210 | 210 | ||
211 | if (!regionStatusResponse.Equals("OK")) | 211 | if (!regionStatusResponse.Equals("OK")) |
212 | { | 212 | { |
213 | throw new LoginException( | 213 | throw new LoginException( |
214 | String.Format( | 214 | String.Format( |
215 | "Region {0} at {1} returned status response {2} rather than {3}", | 215 | "Region {0} at {1} returned status response {2} rather than {3}", |
216 | sim.regionName, regionStatusUrl, regionStatusResponse, "OK"), | 216 | sim.regionName, regionStatusUrl, regionStatusResponse, "OK"), |
217 | String.Format( | 217 | String.Format( |
218 | "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status", | 218 | "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status", |
219 | regionStatusResponse, "OK")); | 219 | regionStatusResponse, "OK")); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | /// <summary> | 223 | /// <summary> |
224 | /// Construct an XMLRPC error response | 224 | /// Construct an XMLRPC error response |
225 | /// </summary> | 225 | /// </summary> |
226 | /// <param name="error"></param> | 226 | /// <param name="error"></param> |
227 | /// <returns></returns> | 227 | /// <returns></returns> |
228 | public static XmlRpcResponse ErrorResponse(string error) | 228 | public static XmlRpcResponse ErrorResponse(string error) |
229 | { | 229 | { |
230 | XmlRpcResponse errorResponse = new XmlRpcResponse(); | 230 | XmlRpcResponse errorResponse = new XmlRpcResponse(); |
231 | Hashtable errorResponseData = new Hashtable(); | 231 | Hashtable errorResponseData = new Hashtable(); |
232 | errorResponse.Value = errorResponseData; | 232 | errorResponse.Value = errorResponseData; |
233 | errorResponseData["error"] = error; | 233 | errorResponseData["error"] = error; |
234 | return errorResponse; | 234 | return errorResponse; |
235 | } | 235 | } |
236 | 236 | ||
237 | /// <summary> | 237 | /// <summary> |
238 | /// Performed when a region connects to the grid server initially. | 238 | /// Performed when a region connects to the grid server initially. |
239 | /// </summary> | 239 | /// </summary> |
240 | /// <param name="request">The XML RPC Request</param> | 240 | /// <param name="request">The XML RPC Request</param> |
241 | /// <returns>Startup parameters</returns> | 241 | /// <returns>Startup parameters</returns> |
242 | public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) | 242 | public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) |
243 | { | 243 | { |
244 | RegionProfileData sim; | 244 | RegionProfileData sim; |
245 | RegionProfileData existingSim; | 245 | RegionProfileData existingSim; |
246 | 246 | ||
247 | Hashtable requestData = (Hashtable)request.Params[0]; | 247 | Hashtable requestData = (Hashtable)request.Params[0]; |
248 | UUID uuid; | 248 | UUID uuid; |
249 | 249 | ||
250 | if (!requestData.ContainsKey("UUID") || !UUID.TryParse((string)requestData["UUID"], out uuid)) | 250 | if (!requestData.ContainsKey("UUID") || !UUID.TryParse((string)requestData["UUID"], out uuid)) |
251 | { | 251 | { |
252 | m_log.Debug("[LOGIN PRELUDE]: Region connected without a UUID, sending back error response."); | 252 | m_log.Debug("[LOGIN PRELUDE]: Region connected without a UUID, sending back error response."); |
253 | return ErrorResponse("No UUID passed to grid server - unable to connect you"); | 253 | return ErrorResponse("No UUID passed to grid server - unable to connect you"); |
254 | } | 254 | } |
255 | 255 | ||
256 | try | 256 | try |
257 | { | 257 | { |
258 | sim = RegionFromRequest(requestData); | 258 | sim = RegionFromRequest(requestData); |
259 | } | 259 | } |
260 | catch (FormatException e) | 260 | catch (FormatException e) |
261 | { | 261 | { |
262 | m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); | 262 | m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); |
263 | return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString()); | 263 | return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString()); |
264 | } | 264 | } |
265 | 265 | ||
266 | m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); | 266 | m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); |
267 | 267 | ||
268 | if (!m_config.AllowRegionRegistration) | 268 | if (!m_config.AllowRegionRegistration) |
269 | { | 269 | { |
270 | m_log.DebugFormat( | 270 | m_log.DebugFormat( |
271 | "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}", | 271 | "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}", |
272 | sim.regionName); | 272 | sim.regionName); |
273 | 273 | ||
274 | return ErrorResponse("This grid is currently not accepting region registrations."); | 274 | return ErrorResponse("This grid is currently not accepting region registrations."); |
275 | } | 275 | } |
276 | 276 | ||
277 | int majorInterfaceVersion = 0; | 277 | int majorInterfaceVersion = 0; |
278 | if (requestData.ContainsKey("major_interface_version")) | 278 | if (requestData.ContainsKey("major_interface_version")) |
279 | int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion); | 279 | int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion); |
280 | 280 | ||
281 | if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion) | 281 | if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion) |
282 | { | 282 | { |
283 | return ErrorResponse( | 283 | return ErrorResponse( |
284 | String.Format( | 284 | String.Format( |
285 | "Your region service implements OGS1 interface version {0}" | 285 | "Your region service implements OGS1 interface version {0}" |
286 | + " but this grid requires that the region implement OGS1 interface version {1} to connect." | 286 | + " but this grid requires that the region implement OGS1 interface version {1} to connect." |
287 | + " Try changing to OpenSimulator {2}", | 287 | + " Try changing to OpenSimulator {2}", |
288 | majorInterfaceVersion, VersionInfo.MajorInterfaceVersion, m_opensimVersion)); | 288 | majorInterfaceVersion, VersionInfo.MajorInterfaceVersion, m_opensimVersion)); |
289 | } | 289 | } |
290 | 290 | ||
291 | existingSim = m_gridDBService.GetRegion(sim.regionHandle); | 291 | existingSim = m_gridDBService.GetRegion(sim.regionHandle); |
292 | 292 | ||
293 | if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) | 293 | if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) |
294 | { | 294 | { |
295 | try | 295 | try |
296 | { | 296 | { |
297 | if (existingSim == null) | 297 | if (existingSim == null) |
298 | { | 298 | { |
299 | ValidateNewRegionKeys(sim); | 299 | ValidateNewRegionKeys(sim); |
300 | } | 300 | } |
301 | else | 301 | else |
302 | { | 302 | { |
303 | ValidateOverwriteKeys(sim, existingSim); | 303 | ValidateOverwriteKeys(sim, existingSim); |
304 | } | 304 | } |
305 | 305 | ||
306 | ValidateRegionContactable(sim); | 306 | ValidateRegionContactable(sim); |
307 | } | 307 | } |
308 | catch (LoginException e) | 308 | catch (LoginException e) |
309 | { | 309 | { |
310 | string logMsg = e.Message; | 310 | string logMsg = e.Message; |
311 | if (e.InnerException != null) | 311 | if (e.InnerException != null) |
312 | logMsg += ", " + e.InnerException.Message; | 312 | logMsg += ", " + e.InnerException.Message; |
313 | 313 | ||
314 | m_log.WarnFormat("[LOGIN END]: {0}", logMsg); | 314 | m_log.WarnFormat("[LOGIN END]: {0}", logMsg); |
315 | 315 | ||
316 | return e.XmlRpcErrorResponse; | 316 | return e.XmlRpcErrorResponse; |
317 | } | 317 | } |
318 | 318 | ||
319 | DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim); | 319 | DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim); |
320 | 320 | ||
321 | switch (insertResponse) | 321 | switch (insertResponse) |
322 | { | 322 | { |
323 | case DataResponse.RESPONSE_OK: | 323 | case DataResponse.RESPONSE_OK: |
324 | m_log.Info("[LOGIN END]: " + (existingSim == null ? "New" : "Existing") + " sim login successful: " + sim.regionName); | 324 | m_log.Info("[LOGIN END]: " + (existingSim == null ? "New" : "Existing") + " sim login successful: " + sim.regionName); |
325 | break; | 325 | break; |
326 | case DataResponse.RESPONSE_ERROR: | 326 | case DataResponse.RESPONSE_ERROR: |
327 | m_log.Warn("[LOGIN END]: Sim login failed (Error): " + sim.regionName); | 327 | m_log.Warn("[LOGIN END]: Sim login failed (Error): " + sim.regionName); |
328 | break; | 328 | break; |
329 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: | 329 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: |
330 | m_log.Warn("[LOGIN END]: " + | 330 | m_log.Warn("[LOGIN END]: " + |
331 | "Sim login failed (Invalid Credentials): " + sim.regionName); | 331 | "Sim login failed (Invalid Credentials): " + sim.regionName); |
332 | break; | 332 | break; |
333 | case DataResponse.RESPONSE_AUTHREQUIRED: | 333 | case DataResponse.RESPONSE_AUTHREQUIRED: |
334 | m_log.Warn("[LOGIN END]: " + | 334 | m_log.Warn("[LOGIN END]: " + |
335 | "Sim login failed (Authentication Required): " + | 335 | "Sim login failed (Authentication Required): " + |
336 | sim.regionName); | 336 | sim.regionName); |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | 339 | ||
340 | XmlRpcResponse response = CreateLoginResponse(sim); | 340 | XmlRpcResponse response = CreateLoginResponse(sim); |
341 | 341 | ||
342 | return response; | 342 | return response; |
343 | } | 343 | } |
344 | else | 344 | else |
345 | { | 345 | { |
346 | m_log.Warn("[LOGIN END]: Failed to login region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); | 346 | m_log.Warn("[LOGIN END]: Failed to login region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); |
347 | return ErrorResponse("Another region already exists at that location. Please try another."); | 347 | return ErrorResponse("Another region already exists at that location. Please try another."); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | /// <summary> | 351 | /// <summary> |
352 | /// Construct a successful response to a simulator's login attempt. | 352 | /// Construct a successful response to a simulator's login attempt. |
353 | /// </summary> | 353 | /// </summary> |
354 | /// <param name="sim"></param> | 354 | /// <param name="sim"></param> |
355 | /// <returns></returns> | 355 | /// <returns></returns> |
356 | private XmlRpcResponse CreateLoginResponse(RegionProfileData sim) | 356 | private XmlRpcResponse CreateLoginResponse(RegionProfileData sim) |
357 | { | 357 | { |
358 | XmlRpcResponse response = new XmlRpcResponse(); | 358 | XmlRpcResponse response = new XmlRpcResponse(); |
359 | Hashtable responseData = new Hashtable(); | 359 | Hashtable responseData = new Hashtable(); |
360 | response.Value = responseData; | 360 | response.Value = responseData; |
361 | 361 | ||
362 | ArrayList SimNeighboursData = GetSimNeighboursData(sim); | 362 | ArrayList SimNeighboursData = GetSimNeighboursData(sim); |
363 | 363 | ||
364 | responseData["UUID"] = sim.UUID.ToString(); | 364 | responseData["UUID"] = sim.UUID.ToString(); |
365 | responseData["region_locx"] = sim.regionLocX.ToString(); | 365 | responseData["region_locx"] = sim.regionLocX.ToString(); |
366 | responseData["region_locy"] = sim.regionLocY.ToString(); | 366 | responseData["region_locy"] = sim.regionLocY.ToString(); |
367 | responseData["regionname"] = sim.regionName; | 367 | responseData["regionname"] = sim.regionName; |
368 | responseData["estate_id"] = "1"; | 368 | responseData["estate_id"] = "1"; |
369 | responseData["neighbours"] = SimNeighboursData; | 369 | responseData["neighbours"] = SimNeighboursData; |
370 | 370 | ||
371 | responseData["sim_ip"] = sim.serverIP; | 371 | responseData["sim_ip"] = sim.serverIP; |
372 | responseData["sim_port"] = sim.serverPort.ToString(); | 372 | responseData["sim_port"] = sim.serverPort.ToString(); |
373 | responseData["asset_url"] = sim.regionAssetURI; | 373 | responseData["asset_url"] = sim.regionAssetURI; |
374 | responseData["asset_sendkey"] = sim.regionAssetSendKey; | 374 | responseData["asset_sendkey"] = sim.regionAssetSendKey; |
375 | responseData["asset_recvkey"] = sim.regionAssetRecvKey; | 375 | responseData["asset_recvkey"] = sim.regionAssetRecvKey; |
376 | responseData["user_url"] = sim.regionUserURI; | 376 | responseData["user_url"] = sim.regionUserURI; |
377 | responseData["user_sendkey"] = sim.regionUserSendKey; | 377 | responseData["user_sendkey"] = sim.regionUserSendKey; |
378 | responseData["user_recvkey"] = sim.regionUserRecvKey; | 378 | responseData["user_recvkey"] = sim.regionUserRecvKey; |
379 | responseData["authkey"] = sim.regionSecret; | 379 | responseData["authkey"] = sim.regionSecret; |
380 | 380 | ||
381 | // New! If set, use as URL to local sim storage (ie http://remotehost/region.Yap) | 381 | // New! If set, use as URL to local sim storage (ie http://remotehost/region.Yap) |
382 | responseData["data_uri"] = sim.regionDataURI; | 382 | responseData["data_uri"] = sim.regionDataURI; |
383 | 383 | ||
384 | responseData["allow_forceful_banlines"] = m_config.AllowForcefulBanlines; | 384 | responseData["allow_forceful_banlines"] = m_config.AllowForcefulBanlines; |
385 | 385 | ||
386 | // Instead of sending a multitude of message servers to the registering sim | 386 | // Instead of sending a multitude of message servers to the registering sim |
387 | // we should probably be sending a single one and parhaps it's backup | 387 | // we should probably be sending a single one and parhaps it's backup |
388 | // that has responsibility over routing it's messages. | 388 | // that has responsibility over routing it's messages. |
389 | 389 | ||
390 | // The Sim won't be contacting us again about any of the message server stuff during it's time up. | 390 | // The Sim won't be contacting us again about any of the message server stuff during it's time up. |
391 | 391 | ||
392 | responseData["messageserver_count"] = 0; | 392 | responseData["messageserver_count"] = 0; |
393 | 393 | ||
394 | IGridMessagingModule messagingModule; | 394 | IGridMessagingModule messagingModule; |
395 | if (m_gridCore.TryGet<IGridMessagingModule>(out messagingModule)) | 395 | if (m_gridCore.TryGet<IGridMessagingModule>(out messagingModule)) |
396 | { | 396 | { |
397 | List<MessageServerInfo> messageServers = messagingModule.MessageServers; | 397 | List<MessageServerInfo> messageServers = messagingModule.MessageServers; |
398 | responseData["messageserver_count"] = messageServers.Count; | 398 | responseData["messageserver_count"] = messageServers.Count; |
399 | 399 | ||
400 | for (int i = 0; i < messageServers.Count; i++) | 400 | for (int i = 0; i < messageServers.Count; i++) |
401 | { | 401 | { |
402 | responseData["messageserver_uri" + i] = messageServers[i].URI; | 402 | responseData["messageserver_uri" + i] = messageServers[i].URI; |
403 | responseData["messageserver_sendkey" + i] = messageServers[i].sendkey; | 403 | responseData["messageserver_sendkey" + i] = messageServers[i].sendkey; |
404 | responseData["messageserver_recvkey" + i] = messageServers[i].recvkey; | 404 | responseData["messageserver_recvkey" + i] = messageServers[i].recvkey; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return response; | 407 | return response; |
408 | } | 408 | } |
409 | 409 | ||
410 | private ArrayList GetSimNeighboursData(RegionProfileData sim) | 410 | private ArrayList GetSimNeighboursData(RegionProfileData sim) |
411 | { | 411 | { |
412 | ArrayList SimNeighboursData = new ArrayList(); | 412 | ArrayList SimNeighboursData = new ArrayList(); |
413 | 413 | ||
414 | RegionProfileData neighbour; | 414 | RegionProfileData neighbour; |
415 | Hashtable NeighbourBlock; | 415 | Hashtable NeighbourBlock; |
416 | 416 | ||
417 | //First use the fast method. (not implemented in SQLLite) | 417 | //First use the fast method. (not implemented in SQLLite) |
418 | List<RegionProfileData> neighbours = m_gridDBService.GetRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1, sim.regionLocY + 1); | 418 | List<RegionProfileData> neighbours = m_gridDBService.GetRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1, sim.regionLocY + 1); |
419 | 419 | ||
420 | if (neighbours.Count > 0) | 420 | if (neighbours.Count > 0) |
421 | { | 421 | { |
422 | foreach (RegionProfileData aSim in neighbours) | 422 | foreach (RegionProfileData aSim in neighbours) |
423 | { | 423 | { |
424 | NeighbourBlock = new Hashtable(); | 424 | NeighbourBlock = new Hashtable(); |
425 | NeighbourBlock["sim_ip"] = aSim.serverIP; | 425 | NeighbourBlock["sim_ip"] = aSim.serverIP; |
426 | NeighbourBlock["sim_port"] = aSim.serverPort.ToString(); | 426 | NeighbourBlock["sim_port"] = aSim.serverPort.ToString(); |
427 | NeighbourBlock["region_locx"] = aSim.regionLocX.ToString(); | 427 | NeighbourBlock["region_locx"] = aSim.regionLocX.ToString(); |
428 | NeighbourBlock["region_locy"] = aSim.regionLocY.ToString(); | 428 | NeighbourBlock["region_locy"] = aSim.regionLocY.ToString(); |
429 | NeighbourBlock["UUID"] = aSim.ToString(); | 429 | NeighbourBlock["UUID"] = aSim.ToString(); |
430 | NeighbourBlock["regionHandle"] = aSim.regionHandle.ToString(); | 430 | NeighbourBlock["regionHandle"] = aSim.regionHandle.ToString(); |
431 | 431 | ||
432 | if (aSim.UUID != sim.UUID) | 432 | if (aSim.UUID != sim.UUID) |
433 | { | 433 | { |
434 | SimNeighboursData.Add(NeighbourBlock); | 434 | SimNeighboursData.Add(NeighbourBlock); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | } | 437 | } |
438 | else | 438 | else |
439 | { | 439 | { |
440 | for (int x = -1; x < 2; x++) | 440 | for (int x = -1; x < 2; x++) |
441 | { | 441 | { |
442 | for (int y = -1; y < 2; y++) | 442 | for (int y = -1; y < 2; y++) |
443 | { | 443 | { |
444 | if ( | 444 | if ( |
445 | m_gridDBService.GetRegion( | 445 | m_gridDBService.GetRegion( |
446 | Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize), | 446 | Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize), |
447 | (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null) | 447 | (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null) |
448 | { | 448 | { |
449 | neighbour = | 449 | neighbour = |
450 | m_gridDBService.GetRegion( | 450 | m_gridDBService.GetRegion( |
451 | Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize), | 451 | Utils.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize), |
452 | (uint)(sim.regionLocY + y) * Constants.RegionSize)); | 452 | (uint)(sim.regionLocY + y) * Constants.RegionSize)); |
453 | 453 | ||
454 | NeighbourBlock = new Hashtable(); | 454 | NeighbourBlock = new Hashtable(); |
455 | NeighbourBlock["sim_ip"] = neighbour.serverIP; | 455 | NeighbourBlock["sim_ip"] = neighbour.serverIP; |
456 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | 456 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); |
457 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); | 457 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); |
458 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | 458 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); |
459 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | 459 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); |
460 | NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); | 460 | NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); |
461 | 461 | ||
462 | if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock); | 462 | if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | return SimNeighboursData; | 467 | return SimNeighboursData; |
468 | } | 468 | } |
469 | 469 | ||
470 | /// <summary> | 470 | /// <summary> |
471 | /// Loads the grid's own RegionProfileData object with data from the XMLRPC simulator_login request from a region | 471 | /// Loads the grid's own RegionProfileData object with data from the XMLRPC simulator_login request from a region |
472 | /// </summary> | 472 | /// </summary> |
473 | /// <param name="requestData"></param> | 473 | /// <param name="requestData"></param> |
474 | /// <returns></returns> | 474 | /// <returns></returns> |
475 | private RegionProfileData RegionFromRequest(Hashtable requestData) | 475 | private RegionProfileData RegionFromRequest(Hashtable requestData) |
476 | { | 476 | { |
477 | RegionProfileData sim; | 477 | RegionProfileData sim; |
478 | sim = new RegionProfileData(); | 478 | sim = new RegionProfileData(); |
479 | 479 | ||
480 | sim.UUID = new UUID((string)requestData["UUID"]); | 480 | sim.UUID = new UUID((string)requestData["UUID"]); |
481 | sim.originUUID = new UUID((string)requestData["originUUID"]); | 481 | sim.originUUID = new UUID((string)requestData["originUUID"]); |
482 | 482 | ||
483 | sim.regionRecvKey = String.Empty; | 483 | sim.regionRecvKey = String.Empty; |
484 | sim.regionSendKey = String.Empty; | 484 | sim.regionSendKey = String.Empty; |
485 | 485 | ||
486 | if (requestData.ContainsKey("region_secret")) | 486 | if (requestData.ContainsKey("region_secret")) |
487 | { | 487 | { |
488 | string regionsecret = (string)requestData["region_secret"]; | 488 | string regionsecret = (string)requestData["region_secret"]; |
489 | if (regionsecret.Length > 0) | 489 | if (regionsecret.Length > 0) |
490 | sim.regionSecret = regionsecret; | 490 | sim.regionSecret = regionsecret; |
491 | else | 491 | else |
492 | sim.regionSecret = m_config.SimRecvKey; | 492 | sim.regionSecret = m_config.SimRecvKey; |
493 | 493 | ||
494 | } | 494 | } |
495 | else | 495 | else |
496 | { | 496 | { |
497 | sim.regionSecret = m_config.SimRecvKey; | 497 | sim.regionSecret = m_config.SimRecvKey; |
498 | } | 498 | } |
499 | 499 | ||
500 | sim.regionDataURI = String.Empty; | 500 | sim.regionDataURI = String.Empty; |
501 | sim.regionAssetURI = m_config.DefaultAssetServer; | 501 | sim.regionAssetURI = m_config.DefaultAssetServer; |
502 | sim.regionAssetRecvKey = m_config.AssetRecvKey; | 502 | sim.regionAssetRecvKey = m_config.AssetRecvKey; |
503 | sim.regionAssetSendKey = m_config.AssetSendKey; | 503 | sim.regionAssetSendKey = m_config.AssetSendKey; |
504 | sim.regionUserURI = m_config.DefaultUserServer; | 504 | sim.regionUserURI = m_config.DefaultUserServer; |
505 | sim.regionUserSendKey = m_config.UserSendKey; | 505 | sim.regionUserSendKey = m_config.UserSendKey; |
506 | sim.regionUserRecvKey = m_config.UserRecvKey; | 506 | sim.regionUserRecvKey = m_config.UserRecvKey; |
507 | 507 | ||
508 | sim.serverIP = (string)requestData["sim_ip"]; | 508 | sim.serverIP = (string)requestData["sim_ip"]; |
509 | sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); | 509 | sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); |
510 | sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); | 510 | sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); |
511 | sim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]); | 511 | sim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]); |
512 | sim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]); | 512 | sim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]); |
513 | sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); | 513 | sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); |
514 | sim.regionLocZ = 0; | 514 | sim.regionLocZ = 0; |
515 | 515 | ||
516 | UUID textureID; | 516 | UUID textureID; |
517 | if (UUID.TryParse((string)requestData["map-image-id"], out textureID)) | 517 | if (UUID.TryParse((string)requestData["map-image-id"], out textureID)) |
518 | { | 518 | { |
519 | sim.regionMapTextureID = textureID; | 519 | sim.regionMapTextureID = textureID; |
520 | } | 520 | } |
521 | 521 | ||
522 | // part of an initial brutish effort to provide accurate information (as per the xml region spec) | 522 | // part of an initial brutish effort to provide accurate information (as per the xml region spec) |
523 | // wrt the ownership of a given region | 523 | // wrt the ownership of a given region |
524 | // the (very bad) assumption is that this value is being read and handled inconsistently or | 524 | // the (very bad) assumption is that this value is being read and handled inconsistently or |
525 | // not at all. Current strategy is to put the code in place to support the validity of this information | 525 | // not at all. Current strategy is to put the code in place to support the validity of this information |
526 | // and to roll forward debugging any issues from that point | 526 | // and to roll forward debugging any issues from that point |
527 | // | 527 | // |
528 | // this particular section of the mod attempts to receive a value from the region's xml file by way of | 528 | // this particular section of the mod attempts to receive a value from the region's xml file by way of |
529 | // OSG1GridServices for the region's owner | 529 | // OSG1GridServices for the region's owner |
530 | sim.owner_uuid = (UUID)(string)requestData["master_avatar_uuid"]; | 530 | sim.owner_uuid = (UUID)(string)requestData["master_avatar_uuid"]; |
531 | 531 | ||
532 | try | 532 | try |
533 | { | 533 | { |
534 | sim.regionRecvKey = (string)requestData["recvkey"]; | 534 | sim.regionRecvKey = (string)requestData["recvkey"]; |
535 | sim.regionSendKey = (string)requestData["authkey"]; | 535 | sim.regionSendKey = (string)requestData["authkey"]; |
536 | } | 536 | } |
537 | catch (KeyNotFoundException) { } | 537 | catch (KeyNotFoundException) { } |
538 | 538 | ||
539 | sim.regionHandle = Utils.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize)); | 539 | sim.regionHandle = Utils.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize)); |
540 | sim.serverURI = (string)requestData["server_uri"]; | 540 | sim.serverURI = (string)requestData["server_uri"]; |
541 | 541 | ||
542 | sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/"; | 542 | sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/"; |
543 | 543 | ||
544 | sim.regionName = (string)requestData["sim_name"]; | 544 | sim.regionName = (string)requestData["sim_name"]; |
545 | return sim; | 545 | return sim; |
546 | } | 546 | } |
547 | 547 | ||
548 | /// <summary> | 548 | /// <summary> |
549 | /// Returns an XML RPC response to a simulator profile request | 549 | /// Returns an XML RPC response to a simulator profile request |
550 | /// Performed after moving a region. | 550 | /// Performed after moving a region. |
551 | /// </summary> | 551 | /// </summary> |
552 | /// <param name="request"></param> | 552 | /// <param name="request"></param> |
553 | /// <returns></returns> | 553 | /// <returns></returns> |
554 | /// <param name="request">The XMLRPC Request</param> | 554 | /// <param name="request">The XMLRPC Request</param> |
555 | /// <returns>Processing parameters</returns> | 555 | /// <returns>Processing parameters</returns> |
556 | public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request) | 556 | public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request) |
557 | { | 557 | { |
558 | XmlRpcResponse response = new XmlRpcResponse(); | 558 | XmlRpcResponse response = new XmlRpcResponse(); |
559 | Hashtable responseData = new Hashtable(); | 559 | Hashtable responseData = new Hashtable(); |
560 | response.Value = responseData; | 560 | response.Value = responseData; |
561 | 561 | ||
562 | //RegionProfileData TheSim = null; | 562 | //RegionProfileData TheSim = null; |
563 | string uuid; | 563 | string uuid; |
564 | Hashtable requestData = (Hashtable)request.Params[0]; | 564 | Hashtable requestData = (Hashtable)request.Params[0]; |
565 | 565 | ||
566 | if (requestData.ContainsKey("UUID")) | 566 | if (requestData.ContainsKey("UUID")) |
567 | { | 567 | { |
568 | //TheSim = GetRegion(new UUID((string) requestData["UUID"])); | 568 | //TheSim = GetRegion(new UUID((string) requestData["UUID"])); |
569 | uuid = requestData["UUID"].ToString(); | 569 | uuid = requestData["UUID"].ToString(); |
570 | m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid); | 570 | m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid); |
571 | // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID."); | 571 | // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID."); |
572 | } | 572 | } |
573 | else | 573 | else |
574 | { | 574 | { |
575 | responseData["error"] = "No UUID or region_handle passed to grid server - unable to delete"; | 575 | responseData["error"] = "No UUID or region_handle passed to grid server - unable to delete"; |
576 | return response; | 576 | return response; |
577 | } | 577 | } |
578 | 578 | ||
579 | DataResponse insertResponse = m_gridDBService.DeleteRegion(uuid); | 579 | DataResponse insertResponse = m_gridDBService.DeleteRegion(uuid); |
580 | 580 | ||
581 | string insertResp = ""; | 581 | string insertResp = ""; |
582 | switch (insertResponse) | 582 | switch (insertResponse) |
583 | { | 583 | { |
584 | case DataResponse.RESPONSE_OK: | 584 | case DataResponse.RESPONSE_OK: |
585 | //MainLog.Instance.Verbose("grid", "Deleting region successful: " + uuid); | 585 | //MainLog.Instance.Verbose("grid", "Deleting region successful: " + uuid); |
586 | insertResp = "Deleting region successful: " + uuid; | 586 | insertResp = "Deleting region successful: " + uuid; |
587 | break; | 587 | break; |
588 | case DataResponse.RESPONSE_ERROR: | 588 | case DataResponse.RESPONSE_ERROR: |
589 | //MainLog.Instance.Warn("storage", "Deleting region failed (Error): " + uuid); | 589 | //MainLog.Instance.Warn("storage", "Deleting region failed (Error): " + uuid); |
590 | insertResp = "Deleting region failed (Error): " + uuid; | 590 | insertResp = "Deleting region failed (Error): " + uuid; |
591 | break; | 591 | break; |
592 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: | 592 | case DataResponse.RESPONSE_INVALIDCREDENTIALS: |
593 | //MainLog.Instance.Warn("storage", "Deleting region failed (Invalid Credentials): " + uuid); | 593 | //MainLog.Instance.Warn("storage", "Deleting region failed (Invalid Credentials): " + uuid); |
594 | insertResp = "Deleting region (Invalid Credentials): " + uuid; | 594 | insertResp = "Deleting region (Invalid Credentials): " + uuid; |
595 | break; | 595 | break; |
596 | case DataResponse.RESPONSE_AUTHREQUIRED: | 596 | case DataResponse.RESPONSE_AUTHREQUIRED: |
597 | //MainLog.Instance.Warn("storage", "Deleting region failed (Authentication Required): " + uuid); | 597 | //MainLog.Instance.Warn("storage", "Deleting region failed (Authentication Required): " + uuid); |
598 | insertResp = "Deleting region (Authentication Required): " + uuid; | 598 | insertResp = "Deleting region (Authentication Required): " + uuid; |
599 | break; | 599 | break; |
600 | } | 600 | } |
601 | 601 | ||
602 | responseData["status"] = insertResp; | 602 | responseData["status"] = insertResp; |
603 | 603 | ||
604 | return response; | 604 | return response; |
605 | } | 605 | } |
606 | 606 | ||
607 | /// <summary> | 607 | /// <summary> |
608 | /// Returns an XML RPC response to a simulator profile request | 608 | /// Returns an XML RPC response to a simulator profile request |
609 | /// </summary> | 609 | /// </summary> |
610 | /// <param name="request"></param> | 610 | /// <param name="request"></param> |
611 | /// <returns></returns> | 611 | /// <returns></returns> |
612 | public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) | 612 | public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) |
613 | { | 613 | { |
614 | Hashtable requestData = (Hashtable)request.Params[0]; | 614 | Hashtable requestData = (Hashtable)request.Params[0]; |
615 | Hashtable responseData = new Hashtable(); | 615 | Hashtable responseData = new Hashtable(); |
616 | RegionProfileData simData = null; | 616 | RegionProfileData simData = null; |
617 | if (requestData.ContainsKey("region_UUID")) | 617 | if (requestData.ContainsKey("region_UUID")) |
618 | { | 618 | { |
619 | UUID regionID = new UUID((string)requestData["region_UUID"]); | 619 | UUID regionID = new UUID((string)requestData["region_UUID"]); |
620 | simData = m_gridDBService.GetRegion(regionID); | 620 | simData = m_gridDBService.GetRegion(regionID); |
621 | if (simData == null) | 621 | if (simData == null) |
622 | { | 622 | { |
623 | m_log.WarnFormat("[DATA] didn't find region for regionID {0} from {1}", | 623 | m_log.WarnFormat("[DATA] didn't find region for regionID {0} from {1}", |
624 | regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); | 624 | regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); |
625 | } | 625 | } |
626 | } | 626 | } |
627 | else if (requestData.ContainsKey("region_handle")) | 627 | else if (requestData.ContainsKey("region_handle")) |
628 | { | 628 | { |
629 | //CFK: The if/else below this makes this message redundant. | 629 | //CFK: The if/else below this makes this message redundant. |
630 | //CFK: Console.WriteLine("requesting data for region " + (string) requestData["region_handle"]); | 630 | //CFK: Console.WriteLine("requesting data for region " + (string) requestData["region_handle"]); |
631 | ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); | 631 | ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); |
632 | simData = m_gridDBService.GetRegion(regionHandle); | 632 | simData = m_gridDBService.GetRegion(regionHandle); |
633 | if (simData == null) | 633 | if (simData == null) |
634 | { | 634 | { |
635 | m_log.WarnFormat("[DATA] didn't find region for regionHandle {0} from {1}", | 635 | m_log.WarnFormat("[DATA] didn't find region for regionHandle {0} from {1}", |
636 | regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); | 636 | regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | else if (requestData.ContainsKey("region_name_search")) | 639 | else if (requestData.ContainsKey("region_name_search")) |
640 | { | 640 | { |
641 | string regionName = (string)requestData["region_name_search"]; | 641 | string regionName = (string)requestData["region_name_search"]; |
642 | simData = m_gridDBService.GetRegion(regionName); | 642 | simData = m_gridDBService.GetRegion(regionName); |
643 | if (simData == null) | 643 | if (simData == null) |
644 | { | 644 | { |
645 | m_log.WarnFormat("[DATA] didn't find region for regionName {0} from {1}", | 645 | m_log.WarnFormat("[DATA] didn't find region for regionName {0} from {1}", |
646 | regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); | 646 | regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); |
647 | } | 647 | } |
648 | } | 648 | } |
649 | else m_log.Warn("[DATA] regionlookup without regionID, regionHandle or regionHame"); | 649 | else m_log.Warn("[DATA] regionlookup without regionID, regionHandle or regionHame"); |
650 | 650 | ||
651 | if (simData == null) | 651 | if (simData == null) |
652 | { | 652 | { |
653 | //Sim does not exist | 653 | //Sim does not exist |
654 | responseData["error"] = "Sim does not exist"; | 654 | responseData["error"] = "Sim does not exist"; |
655 | } | 655 | } |
656 | else | 656 | else |
657 | { | 657 | { |
658 | m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + | 658 | m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + |
659 | (string)requestData["region_handle"]); | 659 | (string)requestData["region_handle"]); |
660 | responseData["sim_ip"] = simData.serverIP; | 660 | responseData["sim_ip"] = simData.serverIP; |
661 | responseData["sim_port"] = simData.serverPort.ToString(); | 661 | responseData["sim_port"] = simData.serverPort.ToString(); |
662 | responseData["server_uri"] = simData.serverURI; | 662 | responseData["server_uri"] = simData.serverURI; |
663 | responseData["http_port"] = simData.httpPort.ToString(); | 663 | responseData["http_port"] = simData.httpPort.ToString(); |
664 | responseData["remoting_port"] = simData.remotingPort.ToString(); | 664 | responseData["remoting_port"] = simData.remotingPort.ToString(); |
665 | responseData["region_locx"] = simData.regionLocX.ToString(); | 665 | responseData["region_locx"] = simData.regionLocX.ToString(); |
666 | responseData["region_locy"] = simData.regionLocY.ToString(); | 666 | responseData["region_locy"] = simData.regionLocY.ToString(); |
667 | responseData["region_UUID"] = simData.UUID.Guid.ToString(); | 667 | responseData["region_UUID"] = simData.UUID.Guid.ToString(); |
668 | responseData["region_name"] = simData.regionName; | 668 | responseData["region_name"] = simData.regionName; |
669 | responseData["regionHandle"] = simData.regionHandle.ToString(); | 669 | responseData["regionHandle"] = simData.regionHandle.ToString(); |
670 | } | 670 | } |
671 | 671 | ||
672 | XmlRpcResponse response = new XmlRpcResponse(); | 672 | XmlRpcResponse response = new XmlRpcResponse(); |
673 | response.Value = responseData; | 673 | response.Value = responseData; |
674 | return response; | 674 | return response; |
675 | } | 675 | } |
676 | 676 | ||
677 | public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request) | 677 | public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request) |
678 | { | 678 | { |
679 | int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; | 679 | int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; |
680 | 680 | ||
681 | Hashtable requestData = (Hashtable)request.Params[0]; | 681 | Hashtable requestData = (Hashtable)request.Params[0]; |
682 | if (requestData.ContainsKey("xmin")) | 682 | if (requestData.ContainsKey("xmin")) |
683 | { | 683 | { |
684 | xmin = (Int32)requestData["xmin"]; | 684 | xmin = (Int32)requestData["xmin"]; |
685 | } | 685 | } |
686 | if (requestData.ContainsKey("ymin")) | 686 | if (requestData.ContainsKey("ymin")) |
687 | { | 687 | { |
688 | ymin = (Int32)requestData["ymin"]; | 688 | ymin = (Int32)requestData["ymin"]; |
689 | } | 689 | } |
690 | if (requestData.ContainsKey("xmax")) | 690 | if (requestData.ContainsKey("xmax")) |
691 | { | 691 | { |
692 | xmax = (Int32)requestData["xmax"]; | 692 | xmax = (Int32)requestData["xmax"]; |
693 | } | 693 | } |
694 | if (requestData.ContainsKey("ymax")) | 694 | if (requestData.ContainsKey("ymax")) |
695 | { | 695 | { |
696 | ymax = (Int32)requestData["ymax"]; | 696 | ymax = (Int32)requestData["ymax"]; |
697 | } | 697 | } |
698 | //CFK: The second log is more meaningful and either standard or fast generally occurs. | 698 | //CFK: The second log is more meaningful and either standard or fast generally occurs. |
699 | //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); | 699 | //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); |
700 | 700 | ||
701 | XmlRpcResponse response = new XmlRpcResponse(); | 701 | XmlRpcResponse response = new XmlRpcResponse(); |
702 | Hashtable responseData = new Hashtable(); | 702 | Hashtable responseData = new Hashtable(); |
703 | response.Value = responseData; | 703 | response.Value = responseData; |
704 | IList simProfileList = new ArrayList(); | 704 | IList simProfileList = new ArrayList(); |
705 | 705 | ||
706 | bool fastMode = (m_config.DatabaseProvider == "OpenSim.Data.MySQL.dll" || m_config.DatabaseProvider == "OpenSim.Data.MSSQL.dll"); | 706 | bool fastMode = (m_config.DatabaseProvider == "OpenSim.Data.MySQL.dll" || m_config.DatabaseProvider == "OpenSim.Data.MSSQL.dll"); |
707 | 707 | ||
708 | if (fastMode) | 708 | if (fastMode) |
709 | { | 709 | { |
710 | List<RegionProfileData> neighbours = m_gridDBService.GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax); | 710 | List<RegionProfileData> neighbours = m_gridDBService.GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax); |
711 | 711 | ||
712 | foreach (RegionProfileData aSim in neighbours) | 712 | foreach (RegionProfileData aSim in neighbours) |
713 | { | 713 | { |
714 | Hashtable simProfileBlock = new Hashtable(); | 714 | Hashtable simProfileBlock = new Hashtable(); |
715 | simProfileBlock["x"] = aSim.regionLocX.ToString(); | 715 | simProfileBlock["x"] = aSim.regionLocX.ToString(); |
716 | simProfileBlock["y"] = aSim.regionLocY.ToString(); | 716 | simProfileBlock["y"] = aSim.regionLocY.ToString(); |
717 | //m_log.DebugFormat("[MAP]: Sending neighbour info for {0},{1}", aSim.regionLocX, aSim.regionLocY); | 717 | //m_log.DebugFormat("[MAP]: Sending neighbour info for {0},{1}", aSim.regionLocX, aSim.regionLocY); |
718 | simProfileBlock["name"] = aSim.regionName; | 718 | simProfileBlock["name"] = aSim.regionName; |
719 | simProfileBlock["access"] = 21; | 719 | simProfileBlock["access"] = 21; |
720 | simProfileBlock["region-flags"] = 512; | 720 | simProfileBlock["region-flags"] = 512; |
721 | simProfileBlock["water-height"] = 0; | 721 | simProfileBlock["water-height"] = 0; |
722 | simProfileBlock["agents"] = 1; | 722 | simProfileBlock["agents"] = 1; |
723 | simProfileBlock["map-image-id"] = aSim.regionMapTextureID.ToString(); | 723 | simProfileBlock["map-image-id"] = aSim.regionMapTextureID.ToString(); |
724 | 724 | ||
725 | // For Sugilite compatibility | 725 | // For Sugilite compatibility |
726 | simProfileBlock["regionhandle"] = aSim.regionHandle.ToString(); | 726 | simProfileBlock["regionhandle"] = aSim.regionHandle.ToString(); |
727 | simProfileBlock["sim_ip"] = aSim.serverIP; | 727 | simProfileBlock["sim_ip"] = aSim.serverIP; |
728 | simProfileBlock["sim_port"] = aSim.serverPort.ToString(); | 728 | simProfileBlock["sim_port"] = aSim.serverPort.ToString(); |
729 | simProfileBlock["sim_uri"] = aSim.serverURI.ToString(); | 729 | simProfileBlock["sim_uri"] = aSim.serverURI.ToString(); |
730 | simProfileBlock["uuid"] = aSim.UUID.ToString(); | 730 | simProfileBlock["uuid"] = aSim.UUID.ToString(); |
731 | simProfileBlock["remoting_port"] = aSim.remotingPort.ToString(); | 731 | simProfileBlock["remoting_port"] = aSim.remotingPort.ToString(); |
732 | simProfileBlock["http_port"] = aSim.httpPort.ToString(); | 732 | simProfileBlock["http_port"] = aSim.httpPort.ToString(); |
733 | 733 | ||
734 | simProfileList.Add(simProfileBlock); | 734 | simProfileList.Add(simProfileBlock); |
735 | } | 735 | } |
736 | m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + | 736 | m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + |
737 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); | 737 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); |
738 | } | 738 | } |
739 | else | 739 | else |
740 | { | 740 | { |
741 | RegionProfileData simProfile; | 741 | RegionProfileData simProfile; |
742 | for (int x = xmin; x < xmax + 1; x++) | 742 | for (int x = xmin; x < xmax + 1; x++) |
743 | { | 743 | { |
744 | for (int y = ymin; y < ymax + 1; y++) | 744 | for (int y = ymin; y < ymax + 1; y++) |
745 | { | 745 | { |
746 | ulong regHandle = Utils.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize)); | 746 | ulong regHandle = Utils.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize)); |
747 | simProfile = m_gridDBService.GetRegion(regHandle); | 747 | simProfile = m_gridDBService.GetRegion(regHandle); |
748 | if (simProfile != null) | 748 | if (simProfile != null) |
749 | { | 749 | { |
750 | Hashtable simProfileBlock = new Hashtable(); | 750 | Hashtable simProfileBlock = new Hashtable(); |
751 | simProfileBlock["x"] = x; | 751 | simProfileBlock["x"] = x; |
752 | simProfileBlock["y"] = y; | 752 | simProfileBlock["y"] = y; |
753 | simProfileBlock["name"] = simProfile.regionName; | 753 | simProfileBlock["name"] = simProfile.regionName; |
754 | simProfileBlock["access"] = 0; | 754 | simProfileBlock["access"] = 0; |
755 | simProfileBlock["region-flags"] = 0; | 755 | simProfileBlock["region-flags"] = 0; |
756 | simProfileBlock["water-height"] = 20; | 756 | simProfileBlock["water-height"] = 20; |
757 | simProfileBlock["agents"] = 1; | 757 | simProfileBlock["agents"] = 1; |
758 | simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToString(); | 758 | simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToString(); |
759 | 759 | ||
760 | // For Sugilite compatibility | 760 | // For Sugilite compatibility |
761 | simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString(); | 761 | simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString(); |
762 | simProfileBlock["sim_ip"] = simProfile.serverIP.ToString(); | 762 | simProfileBlock["sim_ip"] = simProfile.serverIP.ToString(); |
763 | simProfileBlock["sim_port"] = simProfile.serverPort.ToString(); | 763 | simProfileBlock["sim_port"] = simProfile.serverPort.ToString(); |
764 | simProfileBlock["sim_uri"] = simProfile.serverURI.ToString(); | 764 | simProfileBlock["sim_uri"] = simProfile.serverURI.ToString(); |
765 | simProfileBlock["uuid"] = simProfile.UUID.ToString(); | 765 | simProfileBlock["uuid"] = simProfile.UUID.ToString(); |
766 | simProfileBlock["remoting_port"] = simProfile.remotingPort.ToString(); | 766 | simProfileBlock["remoting_port"] = simProfile.remotingPort.ToString(); |
767 | simProfileBlock["http_port"] = simProfile.httpPort; | 767 | simProfileBlock["http_port"] = simProfile.httpPort; |
768 | 768 | ||
769 | simProfileList.Add(simProfileBlock); | 769 | simProfileList.Add(simProfileBlock); |
770 | } | 770 | } |
771 | } | 771 | } |
772 | } | 772 | } |
773 | m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + | 773 | m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + |
774 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); | 774 | " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); |
775 | } | 775 | } |
776 | 776 | ||
777 | responseData["sim-profiles"] = simProfileList; | 777 | responseData["sim-profiles"] = simProfileList; |
778 | 778 | ||
779 | return response; | 779 | return response; |
780 | } | 780 | } |
781 | 781 | ||
782 | /// <summary> | 782 | /// <summary> |
783 | /// Returns up to <code>maxNumber</code> profiles of regions that have a name starting with <code>name</code> | 783 | /// Returns up to <code>maxNumber</code> profiles of regions that have a name starting with <code>name</code> |
784 | /// </summary> | 784 | /// </summary> |
785 | /// <param name="request"></param> | 785 | /// <param name="request"></param> |
786 | /// <returns></returns> | 786 | /// <returns></returns> |
787 | public XmlRpcResponse XmlRpcSearchForRegionMethod(XmlRpcRequest request) | 787 | public XmlRpcResponse XmlRpcSearchForRegionMethod(XmlRpcRequest request) |
788 | { | 788 | { |
789 | Hashtable requestData = (Hashtable)request.Params[0]; | 789 | Hashtable requestData = (Hashtable)request.Params[0]; |
790 | 790 | ||
791 | if (!requestData.ContainsKey("name") || !requestData.Contains("maxNumber")) | 791 | if (!requestData.ContainsKey("name") || !requestData.Contains("maxNumber")) |
792 | { | 792 | { |
793 | m_log.Warn("[DATA] Invalid region-search request; missing name or maxNumber"); | 793 | m_log.Warn("[DATA] Invalid region-search request; missing name or maxNumber"); |
794 | return new XmlRpcResponse(500, "Missing name or maxNumber in region search request"); | 794 | return new XmlRpcResponse(500, "Missing name or maxNumber in region search request"); |
795 | } | 795 | } |
796 | 796 | ||
797 | Hashtable responseData = new Hashtable(); | 797 | Hashtable responseData = new Hashtable(); |
798 | 798 | ||
799 | string name = (string)requestData["name"]; | 799 | string name = (string)requestData["name"]; |
800 | int maxNumber = Convert.ToInt32((string)requestData["maxNumber"]); | 800 | int maxNumber = Convert.ToInt32((string)requestData["maxNumber"]); |
801 | if (maxNumber == 0 || name.Length < 3) | 801 | if (maxNumber == 0 || name.Length < 3) |
802 | { | 802 | { |
803 | // either we didn't want any, or we were too unspecific | 803 | // either we didn't want any, or we were too unspecific |
804 | responseData["numFound"] = 0; | 804 | responseData["numFound"] = 0; |
805 | } | 805 | } |
806 | else | 806 | else |
807 | { | 807 | { |
808 | List<RegionProfileData> sims = m_gridDBService.GetRegions(name, maxNumber); | 808 | List<RegionProfileData> sims = m_gridDBService.GetRegions(name, maxNumber); |
809 | 809 | ||
810 | responseData["numFound"] = sims.Count; | 810 | responseData["numFound"] = sims.Count; |
811 | for (int i = 0; i < sims.Count; ++i) | 811 | for (int i = 0; i < sims.Count; ++i) |
812 | { | 812 | { |
813 | RegionProfileData sim = sims[i]; | 813 | RegionProfileData sim = sims[i]; |
814 | string prefix = "region" + i + "."; | 814 | string prefix = "region" + i + "."; |
815 | responseData[prefix + "region_name"] = sim.regionName; | 815 | responseData[prefix + "region_name"] = sim.regionName; |
816 | responseData[prefix + "region_UUID"] = sim.UUID.ToString(); | 816 | responseData[prefix + "region_UUID"] = sim.UUID.ToString(); |
817 | responseData[prefix + "region_locx"] = sim.regionLocX.ToString(); | 817 | responseData[prefix + "region_locx"] = sim.regionLocX.ToString(); |
818 | responseData[prefix + "region_locy"] = sim.regionLocY.ToString(); | 818 | responseData[prefix + "region_locy"] = sim.regionLocY.ToString(); |
819 | responseData[prefix + "sim_ip"] = sim.serverIP.ToString(); | 819 | responseData[prefix + "sim_ip"] = sim.serverIP.ToString(); |
820 | responseData[prefix + "sim_port"] = sim.serverPort.ToString(); | 820 | responseData[prefix + "sim_port"] = sim.serverPort.ToString(); |
821 | responseData[prefix + "remoting_port"] = sim.remotingPort.ToString(); | 821 | responseData[prefix + "remoting_port"] = sim.remotingPort.ToString(); |
822 | responseData[prefix + "http_port"] = sim.httpPort.ToString(); | 822 | responseData[prefix + "http_port"] = sim.httpPort.ToString(); |
823 | responseData[prefix + "map_UUID"] = sim.regionMapTextureID.ToString(); | 823 | responseData[prefix + "map_UUID"] = sim.regionMapTextureID.ToString(); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | 826 | ||
827 | XmlRpcResponse response = new XmlRpcResponse(); | 827 | XmlRpcResponse response = new XmlRpcResponse(); |
828 | response.Value = responseData; | 828 | response.Value = responseData; |
829 | return response; | 829 | return response; |
830 | } | 830 | } |
831 | 831 | ||
832 | /// <summary> | 832 | /// <summary> |
833 | /// Construct an XMLRPC registration disabled response | 833 | /// Construct an XMLRPC registration disabled response |
834 | /// </summary> | 834 | /// </summary> |
835 | /// <param name="error"></param> | 835 | /// <param name="error"></param> |
836 | /// <returns></returns> | 836 | /// <returns></returns> |
837 | public static XmlRpcResponse XmlRPCRegionRegistrationDisabledResponse(string error) | 837 | public static XmlRpcResponse XmlRPCRegionRegistrationDisabledResponse(string error) |
838 | { | 838 | { |
839 | XmlRpcResponse errorResponse = new XmlRpcResponse(); | 839 | XmlRpcResponse errorResponse = new XmlRpcResponse(); |
840 | Hashtable errorResponseData = new Hashtable(); | 840 | Hashtable errorResponseData = new Hashtable(); |
841 | errorResponse.Value = errorResponseData; | 841 | errorResponse.Value = errorResponseData; |
842 | errorResponseData["restricted"] = error; | 842 | errorResponseData["restricted"] = error; |
843 | return errorResponse; | 843 | return errorResponse; |
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | /// <summary> | 847 | /// <summary> |
848 | /// Exception generated when a simulator fails to login to the grid | 848 | /// Exception generated when a simulator fails to login to the grid |
849 | /// </summary> | 849 | /// </summary> |
850 | public class LoginException : Exception | 850 | public class LoginException : Exception |
851 | { | 851 | { |
852 | /// <summary> | 852 | /// <summary> |
853 | /// Return an XmlRpcResponse version of the exception message suitable for sending to a client | 853 | /// Return an XmlRpcResponse version of the exception message suitable for sending to a client |
854 | /// </summary> | 854 | /// </summary> |
855 | /// <param name="message"></param> | 855 | /// <param name="message"></param> |
856 | /// <param name="xmlRpcMessage"></param> | 856 | /// <param name="xmlRpcMessage"></param> |
857 | public XmlRpcResponse XmlRpcErrorResponse | 857 | public XmlRpcResponse XmlRpcErrorResponse |
858 | { | 858 | { |
859 | get { return m_xmlRpcErrorResponse; } | 859 | get { return m_xmlRpcErrorResponse; } |
860 | } | 860 | } |
861 | private XmlRpcResponse m_xmlRpcErrorResponse; | 861 | private XmlRpcResponse m_xmlRpcErrorResponse; |
862 | 862 | ||
863 | public LoginException(string message, string xmlRpcMessage) | 863 | public LoginException(string message, string xmlRpcMessage) |
864 | : base(message) | 864 | : base(message) |
865 | { | 865 | { |
866 | // FIXME: Might be neater to refactor and put the method inside here | 866 | // FIXME: Might be neater to refactor and put the method inside here |
867 | m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); | 867 | m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); |
868 | } | 868 | } |
869 | 869 | ||
870 | public LoginException(string message, string xmlRpcMessage, Exception e) | 870 | public LoginException(string message, string xmlRpcMessage, Exception e) |
871 | : base(message, e) | 871 | : base(message, e) |
872 | { | 872 | { |
873 | // FIXME: Might be neater to refactor and put the method inside here | 873 | // FIXME: Might be neater to refactor and put the method inside here |
874 | m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); | 874 | m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); |
875 | } | 875 | } |
876 | } | 876 | } |
877 | } | 877 | } |