From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Server/Base/CommandManager.cs | 90 +++++------ OpenSim/Server/Base/HttpServerBase.cs | 35 +++-- OpenSim/Server/Base/Properties/AssemblyInfo.cs | 10 +- OpenSim/Server/Base/ProtocolVersions.cs | 14 +- OpenSim/Server/Base/ServerUtils.cs | 179 ++++++++++++++-------- OpenSim/Server/Base/ServicesServerBase.cs | 202 +++++++++++++++++++++---- 6 files changed, 367 insertions(+), 163 deletions(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/CommandManager.cs b/OpenSim/Server/Base/CommandManager.cs index bd18485..b6e2903 100644 --- a/OpenSim/Server/Base/CommandManager.cs +++ b/OpenSim/Server/Base/CommandManager.cs @@ -41,117 +41,117 @@ namespace OpenSim.Server.Base { /// /// Command manager - - /// Wrapper for OpenSim.Framework.PluginManager to allow + /// Wrapper for OpenSim.Framework.PluginManager to allow /// us to add commands to the console to perform operations /// on our repos and plugins /// - public class CommandManager - { - public AddinRegistry PluginRegistry; - protected PluginManager PluginManager; + public class CommandManager + { + public AddinRegistry PluginRegistry; + protected PluginManager PluginManager; - public CommandManager(AddinRegistry registry) + public CommandManager(AddinRegistry registry) { - PluginRegistry = registry; - PluginManager = new PluginManager(PluginRegistry); - AddManagementCommands(); - } - - private void AddManagementCommands() - { - // add plugin - MainConsole.Instance.Commands.AddCommand("Plugin", true, + PluginRegistry = registry; + PluginManager = new PluginManager(PluginRegistry); + AddManagementCommands(); + } + + private void AddManagementCommands() + { + // add plugin + MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin add", "plugin add \"plugin index\"", - "Install plugin from repository.", + "Install plugin from repository.", HandleConsoleInstallPlugin); - // remove plugin + // remove plugin MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin remove", "plugin remove \"plugin index\"", - "Remove plugin from repository", + "Remove plugin from repository", HandleConsoleUnInstallPlugin); - // list installed plugins + // list installed plugins MainConsole.Instance.Commands.AddCommand("Plugin", true, - "plugin list installed", - "plugin list installed","List install plugins", + "plugin list installed", + "plugin list installed","List install plugins", HandleConsoleListInstalledPlugin); - // list plugins available from registered repositories + // list plugins available from registered repositories MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin list available", - "plugin list available","List available plugins", + "plugin list available","List available plugins", HandleConsoleListAvailablePlugin); - // List available updates + // List available updates MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin updates", "plugin updates","List availble updates", HandleConsoleListUpdates); - // Update plugin + // Update plugin MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin update", "plugin update \"plugin index\"","Update the plugin", HandleConsoleUpdatePlugin); - // Add repository + // Add repository MainConsole.Instance.Commands.AddCommand("Repository", true, "repo add", "repo add \"url\"","Add repository", HandleConsoleAddRepo); - // Refresh repo + // Refresh repo MainConsole.Instance.Commands.AddCommand("Repository", true, "repo refresh", "repo refresh \"url\"", "Sync with a registered repository", HandleConsoleGetRepo); - // Remove repository from registry + // Remove repository from registry MainConsole.Instance.Commands.AddCommand("Repository", true, "repo remove", - "repo remove \"[url | index]\"", - "Remove repository from registry", + "repo remove \"[url | index]\"", + "Remove repository from registry", HandleConsoleRemoveRepo); - // Enable repo + // Enable repo MainConsole.Instance.Commands.AddCommand("Repository", true, "repo enable", "repo enable \"[url | index]\"", - "Enable registered repository", + "Enable registered repository", HandleConsoleEnableRepo); - // Disable repo + // Disable repo MainConsole.Instance.Commands.AddCommand("Repository", true, "repo disable", "repo disable\"[url | index]\"", - "Disable registered repository", + "Disable registered repository", HandleConsoleDisableRepo); - // List registered repositories + // List registered repositories MainConsole.Instance.Commands.AddCommand("Repository", true, "repo list", "repo list", - "List registered repositories", + "List registered repositories", HandleConsoleListRepos); - // * + // * MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin info", "plugin info \"plugin index\"","Show detailed information for plugin", HandleConsoleShowAddinInfo); - // Plugin disable + // Plugin disable MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin disable", "plugin disable \"plugin index\"", - "Disable a plugin", + "Disable a plugin", HandleConsoleDisablePlugin); - // Enable plugin + // Enable plugin MainConsole.Instance.Commands.AddCommand("Plugin", true, "plugin enable", "plugin enable \"plugin index\"", - "Enable the selected plugin plugin", + "Enable the selected plugin plugin", HandleConsoleEnablePlugin); } - + #region console handlers // Handle our console commands // // Install plugin from registered repository /// /// Handles the console install plugin command. Attempts to install the selected plugin - /// and + /// and /// /// /// Module. @@ -323,7 +323,7 @@ namespace OpenSim.Server.Base { if (cmd.Length >= 3) { - + Dictionary result = new Dictionary(); int ndx = Convert.ToInt16(cmd[2]); @@ -355,5 +355,5 @@ namespace OpenSim.Server.Base return; } #endregion - } + } } \ No newline at end of file diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index 44ef124..3357250 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs @@ -40,7 +40,7 @@ namespace OpenSim.Server.Base { public class HttpServerBase : ServicesServerBase { -// private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private uint m_consolePort; @@ -70,6 +70,7 @@ namespace OpenSim.Server.Base bool ssl_main = networkConfig.GetBoolean("https_main",false); bool ssl_listener = networkConfig.GetBoolean("https_listener",false); + bool ssl_external = networkConfig.GetBoolean("https_external",false); m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); @@ -111,25 +112,33 @@ namespace OpenSim.Server.Base MainServer.Instance = httpServer; // If https_listener = true, then add an ssl listener on the https_port... - if (ssl_listener == true) + if (ssl_listener == true) { uint https_port = (uint)networkConfig.GetInt("https_port", 0); - string cert_path = networkConfig.GetString("cert_path",String.Empty); - if (cert_path == String.Empty) + m_log.WarnFormat("[SSL]: External flag is {0}", ssl_external); + if (!ssl_external) { - System.Console.WriteLine("ERROR: Path to X509 certificate is missing, server can't start."); - Environment.Exit(1); + string cert_path = networkConfig.GetString("cert_path",String.Empty); + if ( cert_path == String.Empty ) + { + System.Console.WriteLine("Path to X509 certificate is missing, server can't start."); + Thread.CurrentThread.Abort(); + } + string cert_pass = networkConfig.GetString("cert_pass",String.Empty); + if ( cert_pass == String.Empty ) + { + System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); + Thread.CurrentThread.Abort(); + } + + MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); } - - string cert_pass = networkConfig.GetString("cert_pass",String.Empty); - if (cert_pass == String.Empty) + else { - System.Console.WriteLine("ERROR: Password for X509 certificate is missing, server can't start."); - Environment.Exit(1); + m_log.WarnFormat("[SSL]: SSL port is active but no SSL is used because external SSL was requested."); + MainServer.AddHttpServer(new BaseHttpServer(https_port)); } - - MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); } } diff --git a/OpenSim/Server/Base/Properties/AssemblyInfo.cs b/OpenSim/Server/Base/Properties/AssemblyInfo.cs index 3c634a7..4be0f25 100644 --- a/OpenSim/Server/Base/Properties/AssemblyInfo.cs +++ b/OpenSim/Server/Base/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OpenSim.Server.Base")] @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,9 +25,9 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -[assembly: AssemblyVersion("0.8.3.*")] +[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs index 5c2278c..27eed4c 100644 --- a/OpenSim/Server/Base/ProtocolVersions.cs +++ b/OpenSim/Server/Base/ProtocolVersions.cs @@ -31,20 +31,20 @@ namespace OpenSim.Server.Base { /// /// This is the external protocol versions. It is separate from the OpenSimulator project version. - /// + /// /// These version numbers should be increased by 1 every time a code - /// change in the Service.Connectors and Server.Handlers, espectively, + /// change in the Service.Connectors and Server.Handlers, espectively, /// makes the previous OpenSimulator revision incompatible - /// with the new revision. - /// + /// with the new revision. + /// /// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality /// but not outright failure) do not need a version number increment. - /// + /// /// Having this version number allows the grid service to reject connections from regions running a version - /// of the code that is too old. + /// of the code that is too old. /// /// - + // The range of acceptable servers for client-side connectors public readonly static int ClientProtocolVersionMin = 1; public readonly static int ClientProtocolVersionMax = 1; diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 18a4266..cc506bc 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -39,7 +39,7 @@ using OpenMetaverse; using Mono.Addins; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers; - +using OpenMetaverse.StructuredData; // LitJson is hidden on this [assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)] namespace OpenSim.Server.Base @@ -104,7 +104,7 @@ namespace OpenSim.Server.Base // libomv, which has a hard-coded path to "." for pinvoke // to load the openjpeg dll // - // Will look for a way to fix, but for now this keeps the + // Will look for a way to fix, but for now this keeps the // confusion to a minimum. this was copied from our region // plugin loader, we have been doing this in there for a long time. // @@ -183,7 +183,7 @@ namespace OpenSim.Server.Base if(port != 0) server = MainServer.GetHttpServer(port); - else + else server = MainServer.Instance; return server; @@ -222,19 +222,19 @@ namespace OpenSim.Server.Base // This is good to debug configuration problems //if (dllName == string.Empty) // Util.PrintCallStack(); - + string className = String.Empty; // The path for a dynamic plugin will contain ":" on Windows string[] parts = dllName.Split (new char[] {':'}); - if (parts [0].Length > 1) + if (parts [0].Length > 1) { dllName = parts [0]; if (parts.Length > 1) className = parts[1]; - } - else + } + else { // This is Windows - we must replace the ":" in the path dllName = String.Format ("{0}:{1}", parts [0], parts [1]); @@ -242,6 +242,18 @@ namespace OpenSim.Server.Base className = parts[2]; } + // Handle extra string arguments in a more generic way + if (dllName.Contains("@")) + { + string[] dllNameParts = dllName.Split(new char[] {'@'}); + dllName = dllNameParts[dllNameParts.Length - 1]; + List argList = new List(args); + for (int i = 0 ; i < dllNameParts.Length - 1 ; ++i) + argList.Add(dllNameParts[i]); + + args = argList.ToArray(); + } + return LoadPlugin(dllName, className, args); } @@ -264,10 +276,10 @@ namespace OpenSim.Server.Base { if (pluginType.IsPublic) { - if (className != String.Empty + if (className != String.Empty && pluginType.ToString() != pluginType.Namespace + "." + className) continue; - + Type typeInterface = pluginType.GetInterface(interfaceName); if (typeInterface != null) @@ -283,8 +295,8 @@ namespace OpenSim.Server.Base if (!(e is System.MissingMethodException)) { m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin {0} from {1}. Exception: {2}", - interfaceName, - dllName, + interfaceName, + dllName, e.InnerException == null ? e.Message : e.InnerException.Message), e); } @@ -315,49 +327,62 @@ namespace OpenSim.Server.Base public static Dictionary ParseQueryString(string query) { - Dictionary result = new Dictionary(); string[] terms = query.Split(new char[] {'&'}); - if (terms.Length == 0) - return result; + int nterms = terms.Length; + if (nterms == 0) + return new Dictionary(); - foreach (string t in terms) + Dictionary result = new Dictionary(nterms); + string name; + + for(int i = 0; i < nterms; ++i) { - string[] elems = t.Split(new char[] {'='}); + string[] elems = terms[i].Split(new char[] {'='}); + if (elems.Length == 0) continue; - string name = System.Web.HttpUtility.UrlDecode(elems[0]); - string value = String.Empty; + if(String.IsNullOrWhiteSpace(elems[0])) + continue; - if (elems.Length > 1) - value = System.Web.HttpUtility.UrlDecode(elems[1]); + name = System.Web.HttpUtility.UrlDecode(elems[0]); if (name.EndsWith("[]")) { - string cleanName = name.Substring(0, name.Length - 2); - if (result.ContainsKey(cleanName)) + name = name.Substring(0, name.Length - 2); + if(String.IsNullOrWhiteSpace(name)) + continue; + if (result.ContainsKey(name)) { - if (!(result[cleanName] is List)) + if (!(result[name] is List)) continue; - List l = (List)result[cleanName]; - - l.Add(value); + List l = (List)result[name]; + if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + l.Add(System.Web.HttpUtility.UrlDecode(elems[1])); + else + l.Add(String.Empty); } else { List newList = new List(); - - newList.Add(value); - - result[cleanName] = newList; + if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + newList.Add(System.Web.HttpUtility.UrlDecode(elems[1])); + else + newList.Add(String.Empty); + result[name] = newList; } } else { if (!result.ContainsKey(name)) - result[name] = value; + { + if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + result[name] = System.Web.HttpUtility.UrlDecode(elems[1]); + else + result[name] = String.Empty; + } } } @@ -366,47 +391,70 @@ namespace OpenSim.Server.Base public static string BuildQueryString(Dictionary data) { - string qstring = String.Empty; + // this is not conform to html url encoding + // can only be used on Body of POST or PUT + StringBuilder sb = new StringBuilder(4096); - string part; + string pvalue; foreach (KeyValuePair kvp in data) { if (kvp.Value is List) { List l = (List)kvp.Value; - - foreach (string s in l) + int llen = l.Count; + string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key); + for(int i = 0; i < llen; ++i) { - part = System.Web.HttpUtility.UrlEncode(kvp.Key) + - "[]=" + System.Web.HttpUtility.UrlEncode(s); - - if (qstring != String.Empty) - qstring += "&"; - - qstring += part; + if (sb.Length != 0) + sb.Append("&"); + sb.Append(nkey); + sb.Append("[]="); + sb.Append(System.Web.HttpUtility.UrlEncode(l[i])); } } - else + else if(kvp.Value is Dictionary) { - if (kvp.Value.ToString() != String.Empty) + // encode complex structures as JSON + // needed for estate bans with the encoding used on xml + // encode can be here because object does contain the structure information + // but decode needs to be on estateSettings (or other user) + string js; + try { - part = System.Web.HttpUtility.UrlEncode(kvp.Key) + - "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); + // bypass libovm, we dont need even more useless high level maps + // this should only be called once.. but no problem, i hope + // (other uses may need more..) + LitJson.JsonMapper.RegisterExporter((uuid, writer) => writer.Write(uuid.ToString()) ); + js = LitJson.JsonMapper.ToJson(kvp.Value); } - else + // catch(Exception e) + catch { - part = System.Web.HttpUtility.UrlEncode(kvp.Key); + continue; + } + if (sb.Length != 0) + sb.Append("&"); + sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); + sb.Append("="); + sb.Append(System.Web.HttpUtility.UrlEncode(js)); + } + else + { + if (sb.Length != 0) + sb.Append("&"); + sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); + + pvalue = kvp.Value.ToString(); + if (!String.IsNullOrEmpty(pvalue)) + { + sb.Append("="); + sb.Append(System.Web.HttpUtility.UrlEncode(pvalue)); } - - if (qstring != String.Empty) - qstring += "&"; - - qstring += part; } } - return qstring; + return sb.ToString(); } public static string BuildXmlResponse(Dictionary data) @@ -465,18 +513,23 @@ namespace OpenSim.Server.Base Dictionary ret = new Dictionary(); XmlDocument doc = new XmlDocument(); + doc.XmlResolver = null; + try + { + doc.LoadXml(data); + XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); - doc.LoadXml(data); - - XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); - - if (rootL.Count != 1) - return ret; - - XmlNode rootNode = rootL[0]; + if (rootL.Count != 1) + return ret; - ret = ParseElement(rootNode); + XmlNode rootNode = rootL[0]; + ret = ParseElement(rootNode); + } + catch (Exception e) + { + m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0} \n --- string: {1} - ",e.Message, data); + } return ret; } diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 076868d..176e876 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -55,16 +55,16 @@ namespace OpenSim.Server.Base // protected string[] m_Arguments; - public string ConfigDirectory - { - get; - private set; - } + protected string m_configDirectory = "."; // Run flag // private bool m_Running = true; +#if (_MONO) + private static Mono.Unix.UnixSignal[] signals; +#endif + // Handle all the automagical stuff // public ServicesServerBase(string prompt, string[] args) : base() @@ -85,7 +85,7 @@ namespace OpenSim.Server.Base string fileName = ""; if (Assembly.GetEntryAssembly() != null) fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); - string iniFile = "../config/" + fileName + ".ini"; + string iniFile = fileName + ".ini"; string logConfig = null; IConfig startupConfig = argvConfig.Configs["Startup"]; @@ -96,39 +96,31 @@ namespace OpenSim.Server.Base // Check if a prompt was given on the command line prompt = startupConfig.GetString("prompt", prompt); - + // Check for a Log4Net config file on the command line logConfig =startupConfig.GetString("logconfig", logConfig); } - // Find out of the file name is a URI and remote load it if possible. - // Load it as a local file otherwise. - Uri configUri; + Config = ReadConfigSource(iniFile); - try + List sources = new List(); + sources.Add(iniFile); + + int sourceIndex = 1; + + while (AddIncludes(Config, sources)) { - if (Uri.TryCreate(iniFile, UriKind.Absolute, out configUri) && - configUri.Scheme == Uri.UriSchemeHttp) + for ( ; sourceIndex < sources.Count ; ++sourceIndex) { - XmlReader r = XmlReader.Create(iniFile); - Config = new XmlConfigSource(r); + IConfigSource s = ReadConfigSource(sources[sourceIndex]); + Config.Merge(s); } - else - { - Config = new IniConfigSource(iniFile); - } - } - catch (Exception e) - { - System.Console.WriteLine("Error reading from config source. {0}", e.Message); - System.Diagnostics.Process.GetCurrentProcess().Kill(); -///// Environment.Exit(1); } // Merge OpSys env vars - m_log.Info("[CONFIG]: Loading environment variables for Config"); + Console.WriteLine("[CONFIG]: Loading environment variables for Config"); Util.MergeEnvironmentToConfig(Config); - + // Merge the configuration from the command line into the loaded file Config.Merge(argvConfig); @@ -140,10 +132,12 @@ namespace OpenSim.Server.Base startupConfig = Config.Configs["Startup"]; } - ConfigDirectory = startupConfig.GetString("ConfigDirectory", "."); - - prompt = startupConfig.GetString("Prompt", prompt); + if (startupConfig != null) + { + m_configDirectory = startupConfig.GetString("ConfigDirectory", m_configDirectory); + prompt = startupConfig.GetString("Prompt", prompt); + } // Allow derived classes to load config before the console is opened. ReadConfig(); @@ -193,6 +187,42 @@ namespace OpenSim.Server.Base RegisterCommonCommands(); RegisterCommonComponents(Config); +#if (_MONO) + Thread signal_thread = new Thread (delegate () + { + while (true) + { + // Wait for a signal to be delivered + int index = Mono.Unix.UnixSignal.WaitAny (signals, -1); + + //Mono.Unix.Native.Signum signal = signals [index].Signum; + ShutdownSpecific(); + m_Running = false; + Environment.Exit(0); + } + }); + + if(!Util.IsWindows()) + { + try + { + // linux mac os specifics + signals = new Mono.Unix.UnixSignal[] + { + new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM) + }; + ignal_thread.IsBackground = true; + signal_thread.Start(); + } + catch (Exception e) + { + m_log.Info("Could not set up UNIX signal handlers. SIGTERM will not"); + m_log.InfoFormat("shut down gracefully: {0}", e.Message); + m_log.Debug("Exception was: ", e); + } + } +#endif + // Allow derived classes to perform initialization that // needs to be done after the console has opened Initialise(); @@ -220,6 +250,9 @@ namespace OpenSim.Server.Base } } + MemoryWatchdog.Enabled = false; + Watchdog.Enabled = false; + WorkManager.Stop(); RemovePIDFile(); return 0; @@ -240,5 +273,114 @@ namespace OpenSim.Server.Base protected virtual void Initialise() { } + + /// + /// Adds the included files as ini configuration files + /// + /// List of URL strings or filename strings + private bool AddIncludes(IConfigSource configSource, List sources) + { + bool sourcesAdded = false; + + //loop over config sources + foreach (IConfig config in configSource.Configs) + { + // Look for Include-* in the key name + string[] keys = config.GetKeys(); + foreach (string k in keys) + { + if (k.StartsWith("Include-")) + { + // read the config file to be included. + string file = config.GetString(k); + if (IsUri(file)) + { + if (!sources.Contains(file)) + { + sourcesAdded = true; + sources.Add(file); + } + } + else + { + string basepath = Path.GetFullPath(m_configDirectory); + // Resolve relative paths with wildcards + string chunkWithoutWildcards = file; + string chunkWithWildcards = string.Empty; + int wildcardIndex = file.IndexOfAny(new char[] { '*', '?' }); + if (wildcardIndex != -1) + { + chunkWithoutWildcards = file.Substring(0, wildcardIndex); + chunkWithWildcards = file.Substring(wildcardIndex); + } + string path = Path.Combine(basepath, chunkWithoutWildcards); + path = Path.GetFullPath(path) + chunkWithWildcards; + string[] paths = Util.Glob(path); + + // If the include path contains no wildcards, then warn the user that it wasn't found. + if (wildcardIndex == -1 && paths.Length == 0) + { + Console.WriteLine("[CONFIG]: Could not find include file {0}", path); + } + else + { + foreach (string p in paths) + { + if (!sources.Contains(p)) + { + sourcesAdded = true; + sources.Add(p); + } + } + } + } + } + } + } + + return sourcesAdded; + } + + /// + /// Check if we can convert the string to a URI + /// + /// String uri to the remote resource + /// true if we can convert the string to a Uri object + bool IsUri(string file) + { + Uri configUri; + + return Uri.TryCreate(file, UriKind.Absolute, + out configUri) && configUri.Scheme == Uri.UriSchemeHttp; + } + + IConfigSource ReadConfigSource(string iniFile) + { + // Find out of the file name is a URI and remote load it if possible. + // Load it as a local file otherwise. + Uri configUri; + IConfigSource s = null; + + try + { + if (Uri.TryCreate(iniFile, UriKind.Absolute, out configUri) && + configUri.Scheme == Uri.UriSchemeHttp) + { + XmlReader r = XmlReader.Create(iniFile); + s = new XmlConfigSource(r); + } + else + { + s = new IniConfigSource(iniFile); + } + } + catch (Exception e) + { + System.Console.WriteLine("Error reading from config source. {0}", e.Message); + Environment.Exit(1); + } + + return s; + } } } -- cgit v1.1 From 295e91b8f44a356ab742dedd27c1b7edfe7b1157 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 22:15:41 +1000 Subject: Move cache, config, logs out of tree, and various related clean ups. --- OpenSim/Server/Base/ServicesServerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 176e876..1484ee0 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -85,7 +85,7 @@ namespace OpenSim.Server.Base string fileName = ""; if (Assembly.GetEntryAssembly() != null) fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); - string iniFile = fileName + ".ini"; + string iniFile = Util.configDir() + fileName + ".ini"; string logConfig = null; IConfig startupConfig = argvConfig.Configs["Startup"]; -- cgit v1.1 From 19bf45d261a8df40af85b110c96190dcf2efdaad Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 4 Jul 2019 16:31:53 +1000 Subject: Properly combine Robust.ini path. --- OpenSim/Server/Base/ServicesServerBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 1484ee0..472998a 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -85,7 +85,7 @@ namespace OpenSim.Server.Base string fileName = ""; if (Assembly.GetEntryAssembly() != null) fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); - string iniFile = Util.configDir() + fileName + ".ini"; + string iniFile = Path.Combine(Util.configDir(), fileName + ".ini"); string logConfig = null; IConfig startupConfig = argvConfig.Configs["Startup"]; -- cgit v1.1