diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs index b68896cec0..19275b3b68 100644 --- a/OpenSim/Framework/ConfigurationMember.cs +++ b/OpenSim/Framework/ConfigurationMember.cs @@ -27,49 +27,57 @@ */ using System; -using System.Collections.Generic; -using System.Globalization; -using System.Net; using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.Xml; + using libsecondlife; + using OpenSim.Framework.Console; +using OpenSim.Framework; +using System.Globalization; namespace OpenSim.Framework { public class ConfigurationMember { public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); - public delegate void ConfigurationOptionsLoad(); private List configurationOptions = new List(); private string configurationFilename = ""; private string configurationDescription = ""; - + private XmlNode configurationFromXMLNode = null; private ConfigurationOptionsLoad loadFunction; private ConfigurationOptionResult resultFunction; private IGenericConfig configurationPlugin = null; - /// /// This is the default configuration DLL loaded /// private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll"; - - public ConfigurationMember(string configuration_filename, string configuration_description, - ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) + public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) { - configurationFilename = configuration_filename; - configurationDescription = configuration_description; - loadFunction = load_function; - resultFunction = result_function; + this.configurationFilename = configuration_filename; + this.configurationDescription = configuration_description; + this.loadFunction = load_function; + this.resultFunction = result_function; + } + public ConfigurationMember(XmlNode configuration_xml, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) + { + this.configurationFilename = ""; + this.configurationFromXMLNode = configuration_xml; + this.configurationDescription = configuration_description; + this.loadFunction = load_function; + this.resultFunction = result_function; } - public void setConfigurationFilename(string filename) { configurationFilename = filename; } - public void setConfigurationDescription(string desc) { configurationDescription = desc; @@ -84,11 +92,7 @@ namespace OpenSim.Framework { configurationPluginFilename = dll_filename; } - - public void addConfigurationOption(string configuration_key, - ConfigurationOption.ConfigurationTypes configuration_type, - string configuration_question, string configuration_default, - bool use_default_no_prompt) + public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt) { ConfigurationOption configOption = new ConfigurationOption(); configOption.configurationKey = configuration_key; @@ -97,8 +101,7 @@ namespace OpenSim.Framework configOption.configurationType = configuration_type; configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; - if ((configuration_key != "" && configuration_question != "") || - (configuration_key != "" && use_default_no_prompt)) + if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt)) { if (!configurationOptions.Contains(configOption)) { @@ -107,37 +110,32 @@ namespace OpenSim.Framework } else { - MainLog.Instance.Notice( - "Required fields for adding a configuration option is invalid. Will not add this option (" + - configuration_key + ")"); + MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")"); } } public void performConfigurationRetrieve() { - configurationPlugin = LoadConfigDll(configurationPluginFilename); + configurationPlugin = this.LoadConfigDll(configurationPluginFilename); configurationOptions.Clear(); - if (loadFunction == null) + if(loadFunction == null) { - MainLog.Instance.Error("Load Function for '" + configurationDescription + - "' is null. Refusing to run configuration."); + MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); return; } - if (resultFunction == null) + if(resultFunction == null) { - MainLog.Instance.Error("Result Function for '" + configurationDescription + - "' is null. Refusing to run configuration."); + MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); return; } MainLog.Instance.Verbose("Calling Configuration Load Function..."); - loadFunction(); + this.loadFunction(); - if (configurationOptions.Count <= 0) + if(configurationOptions.Count <= 0) { - MainLog.Instance.Error("No configuration options were specified for '" + configurationOptions + - "'. Refusing to continue configuration."); + MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration."); return; } @@ -156,6 +154,12 @@ namespace OpenSim.Framework } else { + if (this.configurationFromXMLNode != null) + { + MainLog.Instance.Notice("Loading from XML Node, will not save to the file"); + configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); + } + MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); useFile = false; } @@ -168,9 +172,10 @@ namespace OpenSim.Framework bool ignoreNextFromConfig = false; while (convertSuccess == false) { + string console_result = ""; string attribute = null; - if (useFile) + if (useFile || (!useFile && configurationFromXMLNode != null)) { if (!ignoreNextFromConfig) { @@ -190,20 +195,16 @@ namespace OpenSim.Framework } else { + if (configurationDescription.Trim() != "") { - console_result = - MainLog.Instance.CmdPrompt( - configurationDescription + ": " + configOption.configurationQuestion, - configOption.configurationDefault); + console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); } else { - console_result = - MainLog.Instance.CmdPrompt(configOption.configurationQuestion, - configOption.configurationDefault); + console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); } - } + } } else { @@ -266,6 +267,7 @@ namespace OpenSim.Framework { convertSuccess = true; return_result = intResult; + } errorMessage = "a signed 32 bit integer (int)"; break; @@ -320,6 +322,7 @@ namespace OpenSim.Framework { convertSuccess = true; return_result = uintResult; + } errorMessage = "an unsigned 32 bit integer (uint)"; break; @@ -334,9 +337,7 @@ namespace OpenSim.Framework break; case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: float floatResult; - if ( - float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, - out floatResult)) + if (float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out floatResult)) { convertSuccess = true; return_result = floatResult; @@ -345,9 +346,7 @@ namespace OpenSim.Framework break; case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: double doubleResult; - if ( - Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, - out doubleResult)) + if (Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out doubleResult)) { convertSuccess = true; return_result = doubleResult; @@ -364,10 +363,9 @@ namespace OpenSim.Framework } - if (!resultFunction(configOption.configurationKey, return_result)) + if (!this.resultFunction(configOption.configurationKey, return_result)) { - MainLog.Instance.Notice( - "The handler for the last configuration option denied that input, please try again."); + Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again."); convertSuccess = false; ignoreNextFromConfig = true; } @@ -376,27 +374,19 @@ namespace OpenSim.Framework { if (configOption.configurationUseDefaultNoPrompt) { - MainLog.Instance.Error("CONFIG", - string.Format( - "[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", - configOption.configurationKey, console_result, errorMessage, - configurationFilename)); + MainLog.Instance.Error("CONFIG", string.Format("[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); convertSuccess = true; } else { - MainLog.Instance.Warn("CONFIG", - string.Format( - "[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", - configOption.configurationKey, console_result, errorMessage, - configurationFilename)); + MainLog.Instance.Warn("CONFIG", string.Format("[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); ignoreNextFromConfig = true; } } } } - if (useFile) + if(useFile) { configurationPlugin.Commit(); configurationPlugin.Close(); @@ -418,8 +408,7 @@ namespace OpenSim.Framework if (typeInterface != null) { - plug = - (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); } } } @@ -431,10 +420,10 @@ namespace OpenSim.Framework public void forceSetConfigurationOption(string configuration_key, string configuration_value) { - configurationPlugin.LoadData(); - configurationPlugin.SetAttribute(configuration_key, configuration_value); - configurationPlugin.Commit(); - configurationPlugin.Close(); + this.configurationPlugin.LoadData(); + this.configurationPlugin.SetAttribute(configuration_key, configuration_value); + this.configurationPlugin.Commit(); + this.configurationPlugin.Close(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/IRegionLoader.cs b/OpenSim/Framework/IRegionLoader.cs new file mode 100644 index 0000000000..516a88680d --- /dev/null +++ b/OpenSim/Framework/IRegionLoader.cs @@ -0,0 +1,41 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework; +using Nini.Config; +namespace OpenSim.Framework +{ + public interface IRegionLoader + { + void SetIniConfigSource(IniConfigSource configSource); + RegionInfo[] LoadRegions(); + } +} diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 125784960e..a32b43c9e7 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -26,10 +26,16 @@ * */ using System; +using System.Globalization; using System.Net; +using System.Xml; using System.Net.Sockets; -using libsecondlife; using Nini.Config; +using libsecondlife; +using OpenSim.Framework.Console; +using OpenSim.Framework; + + namespace OpenSim.Framework { @@ -41,6 +47,7 @@ namespace OpenSim.Framework public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) { + m_regionLocX = regionLocX; m_regionLocY = regionLocY; @@ -50,6 +57,7 @@ namespace OpenSim.Framework public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, int port) { + m_regionLocX = regionLocX; m_regionLocY = regionLocY; @@ -61,11 +69,16 @@ namespace OpenSim.Framework public LLUUID RegionID = new LLUUID(); private uint m_remotingPort; - public uint RemotingPort { - get { return m_remotingPort; } - set { m_remotingPort = value; } + get + { + return m_remotingPort; + } + set + { + m_remotingPort = value; + } } public string RemotingAddress; @@ -98,49 +111,76 @@ namespace OpenSim.Framework ia = Adr; break; } + } return new IPEndPoint(ia, m_internalEndPoint.Port); } - set { m_externalHostName = value.ToString(); } + set + { + m_externalHostName = value.ToString(); + } } protected string m_externalHostName; - public string ExternalHostName { - get { return m_externalHostName; } - set { m_externalHostName = value; } + get + { + return m_externalHostName; + } + set + { + m_externalHostName = value; + } } protected IPEndPoint m_internalEndPoint; - public IPEndPoint InternalEndPoint { - get { return m_internalEndPoint; } - set { m_internalEndPoint = value; } + get + { + return m_internalEndPoint; + } + set + { + m_internalEndPoint = value; + } } protected uint? m_regionLocX; - public uint RegionLocX { - get { return m_regionLocX.Value; } - set { m_regionLocX = value; } + get + { + return m_regionLocX.Value; + } + set + { + m_regionLocX = value; + } } protected uint? m_regionLocY; - public uint RegionLocY { - get { return m_regionLocY.Value; } - set { m_regionLocY = value; } + get + { + return m_regionLocY.Value; + } + set + { + m_regionLocY = value; + } } public ulong RegionHandle { - get { return Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } + get + { + return Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); + } } } @@ -158,81 +198,84 @@ namespace OpenSim.Framework // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. private static EstateSettings m_estateSettings; - public EstateSettings EstateSettings { get { - if (m_estateSettings == null) + if( m_estateSettings == null ) { m_estateSettings = new EstateSettings(); } return m_estateSettings; } + } public ConfigurationMember configMember; - public RegionInfo(string description, string filename) { - configMember = - new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); + configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); + configMember.performConfigurationRetrieve(); + } + public RegionInfo(string description, XmlNode xmlNode) + { + configMember = new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } - public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) : base(regionLocX, regionLocY, internalEndPoint, externalUri) { + + } public RegionInfo() { + } //not in use, should swap to nini though. public void LoadFromNiniSource(IConfigSource source) { - LoadFromNiniSource(source, "RegionInfo"); + this.LoadFromNiniSource(source, "RegionInfo"); } //not in use, should swap to nini though. public void LoadFromNiniSource(IConfigSource source, string sectionName) { string errorMessage = ""; - RegionID = - new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToStringHyphenated())); - RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test"); - m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000")); - m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000")); - DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db"); + this.RegionID = new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToStringHyphenated())); + this.RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test"); + this.m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000")); + this.m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000")); + this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db"); string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0"); IPAddress ipAddressResult; if (IPAddress.TryParse(ipAddress, out ipAddressResult)) { - m_internalEndPoint = new IPEndPoint(ipAddressResult, 0); + this.m_internalEndPoint = new IPEndPoint(ipAddressResult, 0); } else { errorMessage = "needs an IP Address (IPAddress)"; } - m_internalEndPoint.Port = - source.Configs[sectionName].GetInt("internal_ip_port", NetworkServersInfo.DefaultHttpListenerPort); + this.m_internalEndPoint.Port = source.Configs[sectionName].GetInt("internal_ip_port", NetworkServersInfo.DefaultHttpListenerPort); string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1"); if (externalHost != "SYSTEMIP") { - m_externalHostName = externalHost; + this.m_externalHostName = externalHost; } else { - m_externalHostName = Util.GetLocalHost().ToString(); + this.m_externalHostName = Util.GetLocalHost().ToString(); } - MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test"); - MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User"); - MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); + this.MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test"); + this.MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User"); + this.MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); if (errorMessage != "") { @@ -242,36 +285,17 @@ namespace OpenSim.Framework public void loadConfigurationOptions() { - configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - "UUID of Region (Default is recommended, random UUID)", - LLUUID.Random().ToString(), true); - configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "Region Name", "OpenSim Test", false); - configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Grid Location (X Axis)", "1000", false); - configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - "Grid Location (Y Axis)", "1000", false); - configMember.addConfigurationOption("datastore", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "Filename for local storage", "OpenSim.db", false); - configMember.addConfigurationOption("internal_ip_address", - ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, - "Internal IP Address for incoming UDP client connections", "0.0.0.0", - false); - configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, - "Internal IP Port for incoming UDP client connections", - NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); - configMember.addConfigurationOption("external_host_name", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "External Host Name", "127.0.0.1", false); - configMember.addConfigurationOption("master_avatar_first", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "First Name of Master Avatar", "Test", false); - configMember.addConfigurationOption("master_avatar_last", - ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, - "Last Name of Master Avatar", "User", false); - configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - "(Sandbox Mode Only)Password for Master Avatar account", "test", false); + configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Region (Default is recommended, random UUID)", LLUUID.Random().ToString(), true); + configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Region Name", "OpenSim Test", false); + configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000", false); + configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false); + configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); + configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0", false); + configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); + configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false); + configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false); + configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Name of Master Avatar", "User", false); + configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test", false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -279,50 +303,51 @@ namespace OpenSim.Framework switch (configuration_key) { case "sim_UUID": - RegionID = (LLUUID) configuration_result; + this.RegionID = (LLUUID)configuration_result; break; case "sim_name": - RegionName = (string) configuration_result; + this.RegionName = (string)configuration_result; break; case "sim_location_x": - m_regionLocX = (uint) configuration_result; + this.m_regionLocX = (uint)configuration_result; break; case "sim_location_y": - m_regionLocY = (uint) configuration_result; + this.m_regionLocY = (uint)configuration_result; break; case "datastore": - DataStore = (string) configuration_result; + this.DataStore = (string)configuration_result; break; case "internal_ip_address": - IPAddress address = (IPAddress) configuration_result; - m_internalEndPoint = new IPEndPoint(address, 0); + IPAddress address = (IPAddress)configuration_result; + this.m_internalEndPoint = new IPEndPoint(address, 0); break; case "internal_ip_port": - m_internalEndPoint.Port = (int) configuration_result; + this.m_internalEndPoint.Port = (int)configuration_result; break; case "external_host_name": - if ((string) configuration_result != "SYSTEMIP") + if ((string)configuration_result != "SYSTEMIP") { - m_externalHostName = (string) configuration_result; + this.m_externalHostName = (string)configuration_result; } else { - m_externalHostName = Util.GetLocalHost().ToString(); + this.m_externalHostName = Util.GetLocalHost().ToString(); } break; case "master_avatar_first": - MasterAvatarFirstName = (string) configuration_result; + this.MasterAvatarFirstName = (string)configuration_result; break; case "master_avatar_last": - MasterAvatarLastName = (string) configuration_result; + this.MasterAvatarLastName = (string)configuration_result; break; case "master_avatar_pass": - string tempMD5Passwd = (string) configuration_result; - MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); + string tempMD5Passwd = (string)configuration_result; + this.MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); break; } return true; } + } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/RegionLoader/Filesystem/OpenSim.Framework.RegionLoader.Filesystem.csproj b/OpenSim/Framework/RegionLoader/Filesystem/OpenSim.Framework.RegionLoader.Filesystem.csproj new file mode 100644 index 0000000000..d353d1bef1 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Filesystem/OpenSim.Framework.RegionLoader.Filesystem.csproj @@ -0,0 +1,112 @@ + + + Local + 8.0.50727 + 2.0 + {9A0DA098-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Framework.RegionLoader.Filesystem + JScript + Grid + IE50 + false + Library + + OpenSim.Framework.RegionLoader.Filesystem + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\..\..\bin\ + False + False + False + 4 + + + + + ..\..\..\..\bin\Db4objects.Db4o.dll + False + + + ..\..\..\..\bin\libsecondlife.dll + False + + + ..\..\..\..\bin\Nini.dll + False + + + System.dll + False + + + System.Xml.dll + False + + + ..\..\..\..\bin\XMLRPC.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + + + + + + + + diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs new file mode 100644 index 0000000000..5ebcb64926 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs @@ -0,0 +1,72 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using Nini.Config; +using OpenSim.Framework; +using System.IO; + +namespace OpenSim.Framework.RegionLoader.Filesystem +{ + public class RegionLoaderFileSystem : IRegionLoader + { + public void SetIniConfigSource(IniConfigSource configSource) + { + } + public RegionInfo[] LoadRegions() + { + string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); + + if (!Directory.Exists(regionConfigPath)) + { + Directory.CreateDirectory(regionConfigPath); + } + + string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); + + if (configFiles.Length == 0) + { + new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml")); + configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); + } + + RegionInfo[] regionInfos = new RegionInfo[configFiles.Length]; + for (int i = 0; i < configFiles.Length; i++) + { + + RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); + regionInfos[i] = regionInfo; + } + + + return regionInfos; + } + + } +} diff --git a/OpenSim/Framework/RegionLoader/Web/OpenSim.Framework.RegionLoader.Web.csproj b/OpenSim/Framework/RegionLoader/Web/OpenSim.Framework.RegionLoader.Web.csproj new file mode 100644 index 0000000000..18dcebf983 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Web/OpenSim.Framework.RegionLoader.Web.csproj @@ -0,0 +1,112 @@ + + + Local + 8.0.50727 + 2.0 + {CA806165-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Framework.RegionLoader.Web + JScript + Grid + IE50 + false + Library + + OpenSim.Framework.RegionLoader.Web + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\..\..\bin\ + False + False + False + 4 + + + + + ..\..\..\..\bin\Db4objects.Db4o.dll + False + + + ..\..\..\..\bin\libsecondlife.dll + False + + + ..\..\..\..\bin\Nini.dll + False + + + System.dll + False + + + System.Xml.dll + False + + + ..\..\..\..\bin\XMLRPC.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + + + + + + + + diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs new file mode 100644 index 0000000000..6a52a43646 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs @@ -0,0 +1,98 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Net; +using System.IO; +using System.Xml; +using System.Collections.Generic; +using System.Text; +using Nini.Config; +using OpenSim.Framework; + +namespace OpenSim.Framework.RegionLoader.Web +{ + public class RegionLoaderWebServer : IRegionLoader + { + private IniConfigSource m_configSouce; + public void SetIniConfigSource(IniConfigSource configSource) + { + m_configSouce = configSource; + } + public RegionInfo[] LoadRegions() + { + if (m_configSouce == null) + { + Console.MainLog.Instance.Error("Unable to load configuration source! (WebServer Region Loader)"); + return null; + } + else + { + IniConfig startupConfig = (IniConfig)m_configSouce.Configs["Startup"]; + string url = startupConfig.GetString("regionload_webserver_url","").Trim(); + if (url == "") + { + Console.MainLog.Instance.Error("Unable to load webserver URL - URL was empty (WebServer Region Loader"); + return null; + } + else + { + + HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); + webRequest.Timeout = 30000; //30 Second Timeout + Console.MainLog.Instance.Debug("Sending Download Request..."); + HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); + Console.MainLog.Instance.Debug("Downloading Region Information From Remote Server..."); + StreamReader reader = new StreamReader(webResponse.GetResponseStream()); + string xmlSource = ""; + string tempStr = reader.ReadLine(); + while (tempStr != null) + { + xmlSource = xmlSource + tempStr; + tempStr = reader.ReadLine(); + } + Console.MainLog.Instance.Debug("Done downloading region information from server. Total Bytes: " + xmlSource.Length); + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(xmlSource); + if (xmlDoc.FirstChild.Name == "Regions") + { + RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; + int i; + for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) + { + Console.MainLog.Instance.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); + regionInfos[i] = new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i]); + } + + return regionInfos; + } + return null; + } + } + } + } +} diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 16bb69e884..e9151b5183 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -35,6 +35,8 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; +using OpenSim.Framework.RegionLoader.Filesystem; +using OpenSim.Framework.RegionLoader.Web; using OpenSim.Region.ClientStack; using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.OGS1; @@ -43,6 +45,7 @@ using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; + namespace OpenSim { public delegate void ConsoleCommand(string[] comParams); @@ -272,20 +275,20 @@ namespace OpenSim m_httpServer.AddStreamHandler(new SimStatusHandler()); } - string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); - - if (!Directory.Exists(regionConfigPath)) + IRegionLoader regionLoader; + if (m_config.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem") { - Directory.CreateDirectory(regionConfigPath); + MainLog.Instance.Notice("Loading Region Info from filesystem"); + regionLoader = new RegionLoaderFileSystem(); + } + else + { + MainLog.Instance.Notice("Loading Region Info from web"); + regionLoader = new RegionLoaderWebServer(); } - string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); - - if (configFiles.Length == 0) - { - CreateDefaultRegionInfoXml(Path.Combine(regionConfigPath, "default.xml")); - configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); - } + regionLoader.SetIniConfigSource(m_config); + RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); m_moduleLoader = new ModuleLoader(m_log, m_config); MainLog.Instance.Verbose("Loading Shared Modules"); @@ -294,12 +297,10 @@ namespace OpenSim // Load all script engines found (scripting engine is now a IRegionModule so loaded in the module loader // OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader ScriptEngineLoader = new OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineLoader(m_log); - for (int i = 0; i < configFiles.Length; i++) + for (int i = 0; i < regionsToLoad.Length; i++) { - //Console.WriteLine("Loading region config file"); - RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); - - CreateRegion(regionInfo); + MainLog.Instance.Debug("Creating Region: " + regionsToLoad[i].RegionName); + CreateRegion(regionsToLoad[i]); } m_moduleLoader.PostInitialise(); diff --git a/prebuild.xml b/prebuild.xml index 5d83c5a6ec..648ebe0ebe 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -155,6 +155,56 @@ + + + + ../../../../bin/ + + + + + ../../../../bin/ + + + + ../../../../bin/ + + + + + + + + + + + + + + + + ../../../../bin/ + + + + + ../../../../bin/ + + + + ../../../../bin/ + + + + + + + + + + + + diff --git a/share/RegionLoading/HOWTO_REMOTE_REGION_LOADING.txt b/share/RegionLoading/HOWTO_REMOTE_REGION_LOADING.txt new file mode 100644 index 0000000000..f3afd43f0c --- /dev/null +++ b/share/RegionLoading/HOWTO_REMOTE_REGION_LOADING.txt @@ -0,0 +1,9 @@ +The remote region loading ability allows easier management of what regions a simulator run s from a webserver. +In OpenSim.ini, change the 'region_info_source = filesystem' under [Startup] to 'region_info_source = web'. +Then change the line 'regionload_webserver_url = ' to 'regionload_webserver_url = http://127.0.0.1/default.xml' +replacing 'http://127.0.0.1/default.xml' with the URL of the region XML file. + +The XML file of a remote region is similar to the filesystem version, except it is in one file instead of multiple +region_xxx.xml files. + +See example_web.xml for an example on how to make a web version for region loading. \ No newline at end of file diff --git a/share/RegionLoading/example_web.xml b/share/RegionLoading/example_web.xml new file mode 100644 index 0000000000..837c68c36f --- /dev/null +++ b/share/RegionLoading/example_web.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file