From 97f4226666b5d3525999550e1362180be182cc87 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 13 Oct 2008 20:35:45 +0000 Subject: [PATCH] * Apply a modified version of the part of http://opensimulator.org/mantis/view.php?id=2361 that allows region registration to be enabled/disabled on the grid server * Region registration is enabled by default in the configuration unless the user chooses otherwise * On the console * show status - shows grid status * enable-reg - enables region registration to the grid * disable-reg - disables region registration * Enabling or disabling region registration will not affect any other grid functions or regions already on the grid --- OpenSim/Framework/EstateSettings.cs | 2 +- OpenSim/Framework/GridConfig.cs | 12 ++++++++- OpenSim/Framework/PacketPool.cs | 2 +- OpenSim/Framework/RegionSettings.cs | 2 +- OpenSim/Grid/GridServer/GridManager.cs | 23 ++++++++++++++++ OpenSim/Grid/GridServer/GridServerBase.cs | 33 ++++++++++++++++++++--- 6 files changed, 67 insertions(+), 7 deletions(-) diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index b7dccdb5f4..f8595e0b9b 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -290,7 +290,7 @@ namespace OpenSim.Framework l_EstateManagers.Clear(); configMember.performConfigurationRetrieve(); } - catch (Exception e) + catch (Exception) { } } diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs index 889f345f52..52bc3d6ae5 100644 --- a/OpenSim/Framework/GridConfig.cs +++ b/OpenSim/Framework/GridConfig.cs @@ -34,6 +34,7 @@ namespace OpenSim.Framework public static uint DefaultHttpPort = 8001; public string AllowForcefulBanlines = "TRUE"; + public bool AllowRegionRegistration = true; public string AssetRecvKey = String.Empty; public string AssetSendKey = String.Empty; @@ -90,7 +91,13 @@ namespace OpenSim.Framework configMember.addConfigurationOption("allow_forceful_banlines", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "Allow Forceful Banlines", "TRUE", true); + "Allow Forceful Banlines", "TRUE", true); + + configMember.addConfigurationOption("allow_region_registration", + ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, + "Allow regions to register immediately upon grid server startup? true/false", + "True", + false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -133,6 +140,9 @@ namespace OpenSim.Framework case "allow_forceful_banlines": AllowForcefulBanlines = (string) configuration_result; break; + case "allow_region_registration": + AllowRegionRegistration = (bool)configuration_result; + break; } return true; diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs index 807403e780..e24da428b7 100644 --- a/OpenSim/Framework/PacketPool.cs +++ b/OpenSim/Framework/PacketPool.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework { private static readonly PacketPool instance = new PacketPool(); - private const bool packetPoolEnabled = false; + private bool packetPoolEnabled = false; private readonly Dictionary> pool = new Dictionary>(); diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 6281d6cfa5..ba04513bcb 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -50,7 +50,7 @@ namespace OpenSim.Framework configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", LoadConfigurationOptions, HandleIncomingConfiguration, true); configMember.performConfigurationRetrieve(); } - catch (Exception e) + catch (Exception) { } } diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index 1e8ac000a2..7739a55ba7 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -377,6 +377,15 @@ namespace OpenSim.Grid.GridServer m_log.Warn("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); return ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString()); } + + if (!Config.AllowRegionRegistration) + { + m_log.InfoFormat( + "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}", + sim.regionName); + + return ErrorResponse("The grid is currently not accepting region registrations."); + } m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); @@ -1206,6 +1215,20 @@ namespace OpenSim.Grid.GridServer } return response; } + + /// + /// Construct an XMLRPC registration disabled response + /// + /// + /// + public static XmlRpcResponse XmlRPCRegionRegistrationDisabledResponse(string error) + { + XmlRpcResponse errorResponse = new XmlRpcResponse(); + Hashtable errorResponseData = new Hashtable(); + errorResponse.Value = errorResponseData; + errorResponseData["restricted"] = error; + return errorResponse; + } } /// diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 2ffeb576c7..36ea238bc8 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs @@ -63,15 +63,42 @@ namespace OpenSim.Grid.GridServer MainConsole.Instance = m_console; } - public void managercallback(string cmd) + public override void RunCmd(string cmd, string[] cmdparams) { + base.RunCmd(cmd, cmdparams); + switch (cmd) { - case "shutdown": - RunCmd("shutdown", new string[0]); + case "disable-reg": + m_config.AllowRegionRegistration = false; + m_log.Info("Region registration disabled"); + break; + case "enable-reg": + m_config.AllowRegionRegistration = true; + m_log.Info("Region registration enabled"); + break; + } + } + + public override void Show(string[] showParams) + { + base.Show(showParams); + + switch (showParams[0]) + { + case "status": + if (m_config.AllowRegionRegistration) + { + m_log.Info("Region registration enabled."); + } + else + { + m_log.Info("Region registration disabled."); + } break; } } + protected override void StartupSpecific() {