diff options
Diffstat (limited to 'OpenSim/Grid/GridServer/GridManager.cs')
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 2bb26cf..84a515c 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -28,6 +28,7 @@ | |||
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.Reflection; | 32 | using System.Reflection; |
32 | using System.Xml; | 33 | using System.Xml; |
33 | using libsecondlife; | 34 | using libsecondlife; |
@@ -36,6 +37,7 @@ using Nwc.XmlRpc; | |||
36 | using OpenSim.Data; | 37 | using OpenSim.Data; |
37 | using OpenSim.Data.MySQL; | 38 | using OpenSim.Data.MySQL; |
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
40 | 42 | ||
41 | namespace OpenSim.Grid.GridServer | 43 | namespace OpenSim.Grid.GridServer |
@@ -248,7 +250,7 @@ namespace OpenSim.Grid.GridServer | |||
248 | /// </summary> | 250 | /// </summary> |
249 | /// <param name="sim"></param> | 251 | /// <param name="sim"></param> |
250 | /// <returns></returns> | 252 | /// <returns></returns> |
251 | protected virtual void ValidateOverwrite(RegionProfileData sim, RegionProfileData existingSim) | 253 | protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim) |
252 | { | 254 | { |
253 | if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) | 255 | if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) |
254 | { | 256 | { |
@@ -271,7 +273,7 @@ namespace OpenSim.Grid.GridServer | |||
271 | /// | 273 | /// |
272 | /// <param name="sim"></param> | 274 | /// <param name="sim"></param> |
273 | /// <exception cref="LoginException">Thrown if region login failed</exception> | 275 | /// <exception cref="LoginException">Thrown if region login failed</exception> |
274 | protected virtual void ValidateNewRegion(RegionProfileData sim) | 276 | protected virtual void ValidateNewRegionKeys(RegionProfileData sim) |
275 | { | 277 | { |
276 | if (!(sim.regionRecvKey == Config.SimSendKey && sim.regionSendKey == Config.SimRecvKey)) | 278 | if (!(sim.regionRecvKey == Config.SimSendKey && sim.regionSendKey == Config.SimRecvKey)) |
277 | { | 279 | { |
@@ -282,8 +284,51 @@ namespace OpenSim.Grid.GridServer | |||
282 | sim.regionName, sim.regionLocX, sim.regionLocY, | 284 | sim.regionName, sim.regionLocX, sim.regionLocY, |
283 | sim.regionSendKey, Config.SimRecvKey, sim.regionRecvKey, Config.SimSendKey), | 285 | sim.regionSendKey, Config.SimRecvKey, sim.regionRecvKey, Config.SimSendKey), |
284 | "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); | 286 | "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); |
287 | } | ||
288 | } | ||
289 | |||
290 | /// <summary> | ||
291 | /// Check that a region's http uri is externally contactable. | ||
292 | /// </summary> | ||
293 | /// <param name="sim"></param> | ||
294 | /// <exception cref="LoginException">Thrown if the region is not contactable</exception> | ||
295 | protected virtual void ValidateRegionContactable(RegionProfileData sim) | ||
296 | { | ||
297 | string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/"); | ||
298 | string regionStatusResponse; | ||
299 | |||
300 | RestClient rc = new RestClient(regionStatusUrl); | ||
301 | rc.RequestMethod = "GET"; | ||
302 | |||
303 | m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName); | ||
304 | |||
305 | try | ||
306 | { | ||
307 | Stream rs = rc.Request(); | ||
308 | StreamReader sr = new StreamReader(rs); | ||
309 | regionStatusResponse = sr.ReadToEnd(); | ||
310 | sr.Close(); | ||
285 | } | 311 | } |
286 | 312 | catch (Exception e) | |
313 | { | ||
314 | throw new LoginException( | ||
315 | String.Format("Region status request to {0} failed", regionStatusUrl), | ||
316 | String.Format( | ||
317 | "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service", | ||
318 | regionStatusUrl), | ||
319 | e); | ||
320 | } | ||
321 | |||
322 | if (!regionStatusResponse.Equals("OK")) | ||
323 | { | ||
324 | throw new LoginException( | ||
325 | String.Format( | ||
326 | "Region {0} at {1} returned status response {2} rather than {3}", | ||
327 | sim.regionName, regionStatusUrl, regionStatusResponse, "OK"), | ||
328 | String.Format( | ||
329 | "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status", | ||
330 | regionStatusResponse, "OK")); | ||
331 | } | ||
287 | } | 332 | } |
288 | 333 | ||
289 | /// <summary> | 334 | /// <summary> |
@@ -332,7 +377,6 @@ namespace OpenSim.Grid.GridServer | |||
332 | m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); | 377 | m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); |
333 | 378 | ||
334 | existingSim = GetRegion(sim.regionHandle); | 379 | existingSim = GetRegion(sim.regionHandle); |
335 | |||
336 | 380 | ||
337 | if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) | 381 | if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) |
338 | { | 382 | { |
@@ -340,12 +384,14 @@ namespace OpenSim.Grid.GridServer | |||
340 | { | 384 | { |
341 | if (existingSim == null) | 385 | if (existingSim == null) |
342 | { | 386 | { |
343 | ValidateNewRegion(sim); | 387 | ValidateNewRegionKeys(sim); |
344 | } | 388 | } |
345 | else | 389 | else |
346 | { | 390 | { |
347 | ValidateOverwrite(sim, existingSim); | 391 | ValidateOverwriteKeys(sim, existingSim); |
348 | } | 392 | } |
393 | |||
394 | ValidateRegionContactable(sim); | ||
349 | } | 395 | } |
350 | catch (LoginException e) | 396 | catch (LoginException e) |
351 | { | 397 | { |