From 550018f02dbe9d725ff9cdd69f3cf17fac727220 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 13 May 2008 13:36:21 +0000 Subject: * As part of the region registration process, the grid service now requests the status of the region using the region http uri just passed in * If the status cannot be retrieved, then the region startup will terminate. * The aim of this is for earlier detection of situations where the region can send messages out but cannot accept incoming requests (often due to firewall issues) * This is currently an extremely simplistic check which completely trusts whatever http uri is given by the region * This contact may be problematic, though since the user service needs to be able to contact the region http uri, it doesn't seem unreasonable for the grid to have to be able to do so too at this stage * This change will require a prebuild --- OpenSim/Grid/GridServer/GridManager.cs | 58 ++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'OpenSim/Grid/GridServer/GridManager.cs') 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 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Reflection; using System.Xml; using libsecondlife; @@ -36,6 +37,7 @@ using Nwc.XmlRpc; using OpenSim.Data; using OpenSim.Data.MySQL; using OpenSim.Framework; +using OpenSim.Framework.Communications; using OpenSim.Framework.Servers; namespace OpenSim.Grid.GridServer @@ -248,7 +250,7 @@ namespace OpenSim.Grid.GridServer /// /// /// - protected virtual void ValidateOverwrite(RegionProfileData sim, RegionProfileData existingSim) + protected virtual void ValidateOverwriteKeys(RegionProfileData sim, RegionProfileData existingSim) { if (!(existingSim.regionRecvKey == sim.regionRecvKey && existingSim.regionSendKey == sim.regionSendKey)) { @@ -271,7 +273,7 @@ namespace OpenSim.Grid.GridServer /// /// /// Thrown if region login failed - protected virtual void ValidateNewRegion(RegionProfileData sim) + protected virtual void ValidateNewRegionKeys(RegionProfileData sim) { if (!(sim.regionRecvKey == Config.SimSendKey && sim.regionSendKey == Config.SimRecvKey)) { @@ -282,8 +284,51 @@ namespace OpenSim.Grid.GridServer sim.regionName, sim.regionLocX, sim.regionLocY, sim.regionSendKey, Config.SimRecvKey, sim.regionRecvKey, Config.SimSendKey), "The keys required to login your region did not match your existing region keys. Please check your grid send and receive keys."); + } + } + + /// + /// Check that a region's http uri is externally contactable. + /// + /// + /// Thrown if the region is not contactable + protected virtual void ValidateRegionContactable(RegionProfileData sim) + { + string regionStatusUrl = String.Format("{0}{1}", sim.httpServerURI, "simstatus/"); + string regionStatusResponse; + + RestClient rc = new RestClient(regionStatusUrl); + rc.RequestMethod = "GET"; + + m_log.DebugFormat("[LOGIN]: Contacting {0} for status of region {1}", regionStatusUrl, sim.regionName); + + try + { + Stream rs = rc.Request(); + StreamReader sr = new StreamReader(rs); + regionStatusResponse = sr.ReadToEnd(); + sr.Close(); } - + catch (Exception e) + { + throw new LoginException( + String.Format("Region status request to {0} failed", regionStatusUrl), + String.Format( + "The grid service could not contact the http url {0} at your region. Please make sure this url is reachable by the grid service", + regionStatusUrl), + e); + } + + if (!regionStatusResponse.Equals("OK")) + { + throw new LoginException( + String.Format( + "Region {0} at {1} returned status response {2} rather than {3}", + sim.regionName, regionStatusUrl, regionStatusResponse, "OK"), + String.Format( + "When the grid service asked for the status of your region, it received the response {0} rather than {1}. Please check your status", + regionStatusResponse, "OK")); + } } /// @@ -332,7 +377,6 @@ namespace OpenSim.Grid.GridServer m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); existingSim = GetRegion(sim.regionHandle); - if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) { @@ -340,12 +384,14 @@ namespace OpenSim.Grid.GridServer { if (existingSim == null) { - ValidateNewRegion(sim); + ValidateNewRegionKeys(sim); } else { - ValidateOverwrite(sim, existingSim); + ValidateOverwriteKeys(sim, existingSim); } + + ValidateRegionContactable(sim); } catch (LoginException e) { -- cgit v1.1