diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Base/CommandManager.cs | 90 | ||||
-rw-r--r-- | OpenSim/Server/Base/HttpServerBase.cs | 35 | ||||
-rw-r--r-- | OpenSim/Server/Base/Properties/AssemblyInfo.cs | 10 | ||||
-rw-r--r-- | OpenSim/Server/Base/ProtocolVersions.cs | 14 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 179 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 202 |
6 files changed, 367 insertions, 163 deletions
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 | |||
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Command manager - | 43 | /// Command manager - |
44 | /// Wrapper for OpenSim.Framework.PluginManager to allow | 44 | /// Wrapper for OpenSim.Framework.PluginManager to allow |
45 | /// us to add commands to the console to perform operations | 45 | /// us to add commands to the console to perform operations |
46 | /// on our repos and plugins | 46 | /// on our repos and plugins |
47 | /// </summary> | 47 | /// </summary> |
48 | public class CommandManager | 48 | public class CommandManager |
49 | { | 49 | { |
50 | public AddinRegistry PluginRegistry; | 50 | public AddinRegistry PluginRegistry; |
51 | protected PluginManager PluginManager; | 51 | protected PluginManager PluginManager; |
52 | 52 | ||
53 | public CommandManager(AddinRegistry registry) | 53 | public CommandManager(AddinRegistry registry) |
54 | { | 54 | { |
55 | PluginRegistry = registry; | 55 | PluginRegistry = registry; |
56 | PluginManager = new PluginManager(PluginRegistry); | 56 | PluginManager = new PluginManager(PluginRegistry); |
57 | AddManagementCommands(); | 57 | AddManagementCommands(); |
58 | } | 58 | } |
59 | 59 | ||
60 | private void AddManagementCommands() | 60 | private void AddManagementCommands() |
61 | { | 61 | { |
62 | // add plugin | 62 | // add plugin |
63 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 63 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
64 | "plugin add", "plugin add \"plugin index\"", | 64 | "plugin add", "plugin add \"plugin index\"", |
65 | "Install plugin from repository.", | 65 | "Install plugin from repository.", |
66 | HandleConsoleInstallPlugin); | 66 | HandleConsoleInstallPlugin); |
67 | 67 | ||
68 | // remove plugin | 68 | // remove plugin |
69 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 69 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
70 | "plugin remove", "plugin remove \"plugin index\"", | 70 | "plugin remove", "plugin remove \"plugin index\"", |
71 | "Remove plugin from repository", | 71 | "Remove plugin from repository", |
72 | HandleConsoleUnInstallPlugin); | 72 | HandleConsoleUnInstallPlugin); |
73 | 73 | ||
74 | // list installed plugins | 74 | // list installed plugins |
75 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 75 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
76 | "plugin list installed", | 76 | "plugin list installed", |
77 | "plugin list installed","List install plugins", | 77 | "plugin list installed","List install plugins", |
78 | HandleConsoleListInstalledPlugin); | 78 | HandleConsoleListInstalledPlugin); |
79 | 79 | ||
80 | // list plugins available from registered repositories | 80 | // list plugins available from registered repositories |
81 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 81 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
82 | "plugin list available", | 82 | "plugin list available", |
83 | "plugin list available","List available plugins", | 83 | "plugin list available","List available plugins", |
84 | HandleConsoleListAvailablePlugin); | 84 | HandleConsoleListAvailablePlugin); |
85 | // List available updates | 85 | // List available updates |
86 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 86 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
87 | "plugin updates", "plugin updates","List availble updates", | 87 | "plugin updates", "plugin updates","List availble updates", |
88 | HandleConsoleListUpdates); | 88 | HandleConsoleListUpdates); |
89 | 89 | ||
90 | // Update plugin | 90 | // Update plugin |
91 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 91 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
92 | "plugin update", "plugin update \"plugin index\"","Update the plugin", | 92 | "plugin update", "plugin update \"plugin index\"","Update the plugin", |
93 | HandleConsoleUpdatePlugin); | 93 | HandleConsoleUpdatePlugin); |
94 | 94 | ||
95 | // Add repository | 95 | // Add repository |
96 | MainConsole.Instance.Commands.AddCommand("Repository", true, | 96 | MainConsole.Instance.Commands.AddCommand("Repository", true, |
97 | "repo add", "repo add \"url\"","Add repository", | 97 | "repo add", "repo add \"url\"","Add repository", |
98 | HandleConsoleAddRepo); | 98 | HandleConsoleAddRepo); |
99 | 99 | ||
100 | // Refresh repo | 100 | // Refresh repo |
101 | MainConsole.Instance.Commands.AddCommand("Repository", true, | 101 | MainConsole.Instance.Commands.AddCommand("Repository", true, |
102 | "repo refresh", "repo refresh \"url\"", "Sync with a registered repository", | 102 | "repo refresh", "repo refresh \"url\"", "Sync with a registered repository", |
103 | HandleConsoleGetRepo); | 103 | HandleConsoleGetRepo); |
104 | 104 | ||
105 | // Remove repository from registry | 105 | // Remove repository from registry |
106 | MainConsole.Instance.Commands.AddCommand("Repository", true, | 106 | MainConsole.Instance.Commands.AddCommand("Repository", true, |
107 | "repo remove", | 107 | "repo remove", |
108 | "repo remove \"[url | index]\"", | 108 | "repo remove \"[url | index]\"", |
109 | "Remove repository from registry", | 109 | "Remove repository from registry", |
110 | HandleConsoleRemoveRepo); | 110 | HandleConsoleRemoveRepo); |
111 | 111 | ||
112 | // Enable repo | 112 | // Enable repo |
113 | MainConsole.Instance.Commands.AddCommand("Repository", true, | 113 | MainConsole.Instance.Commands.AddCommand("Repository", true, |
114 | "repo enable", "repo enable \"[url | index]\"", | 114 | "repo enable", "repo enable \"[url | index]\"", |
115 | "Enable registered repository", | 115 | "Enable registered repository", |
116 | HandleConsoleEnableRepo); | 116 | HandleConsoleEnableRepo); |
117 | 117 | ||
118 | // Disable repo | 118 | // Disable repo |
119 | MainConsole.Instance.Commands.AddCommand("Repository", true, | 119 | MainConsole.Instance.Commands.AddCommand("Repository", true, |
120 | "repo disable", "repo disable\"[url | index]\"", | 120 | "repo disable", "repo disable\"[url | index]\"", |
121 | "Disable registered repository", | 121 | "Disable registered repository", |
122 | HandleConsoleDisableRepo); | 122 | HandleConsoleDisableRepo); |
123 | 123 | ||
124 | // List registered repositories | 124 | // List registered repositories |
125 | MainConsole.Instance.Commands.AddCommand("Repository", true, | 125 | MainConsole.Instance.Commands.AddCommand("Repository", true, |
126 | "repo list", "repo list", | 126 | "repo list", "repo list", |
127 | "List registered repositories", | 127 | "List registered repositories", |
128 | HandleConsoleListRepos); | 128 | HandleConsoleListRepos); |
129 | 129 | ||
130 | // * | 130 | // * |
131 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 131 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
132 | "plugin info", "plugin info \"plugin index\"","Show detailed information for plugin", | 132 | "plugin info", "plugin info \"plugin index\"","Show detailed information for plugin", |
133 | HandleConsoleShowAddinInfo); | 133 | HandleConsoleShowAddinInfo); |
134 | 134 | ||
135 | // Plugin disable | 135 | // Plugin disable |
136 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 136 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
137 | "plugin disable", "plugin disable \"plugin index\"", | 137 | "plugin disable", "plugin disable \"plugin index\"", |
138 | "Disable a plugin", | 138 | "Disable a plugin", |
139 | HandleConsoleDisablePlugin); | 139 | HandleConsoleDisablePlugin); |
140 | 140 | ||
141 | // Enable plugin | 141 | // Enable plugin |
142 | MainConsole.Instance.Commands.AddCommand("Plugin", true, | 142 | MainConsole.Instance.Commands.AddCommand("Plugin", true, |
143 | "plugin enable", "plugin enable \"plugin index\"", | 143 | "plugin enable", "plugin enable \"plugin index\"", |
144 | "Enable the selected plugin plugin", | 144 | "Enable the selected plugin plugin", |
145 | HandleConsoleEnablePlugin); | 145 | HandleConsoleEnablePlugin); |
146 | } | 146 | } |
147 | 147 | ||
148 | #region console handlers | 148 | #region console handlers |
149 | // Handle our console commands | 149 | // Handle our console commands |
150 | // | 150 | // |
151 | // Install plugin from registered repository | 151 | // Install plugin from registered repository |
152 | /// <summary> | 152 | /// <summary> |
153 | /// Handles the console install plugin command. Attempts to install the selected plugin | 153 | /// Handles the console install plugin command. Attempts to install the selected plugin |
154 | /// and | 154 | /// and |
155 | /// </summary> | 155 | /// </summary> |
156 | /// <param name='module'> | 156 | /// <param name='module'> |
157 | /// Module. | 157 | /// Module. |
@@ -323,7 +323,7 @@ namespace OpenSim.Server.Base | |||
323 | { | 323 | { |
324 | if (cmd.Length >= 3) | 324 | if (cmd.Length >= 3) |
325 | { | 325 | { |
326 | 326 | ||
327 | Dictionary<string, object> result = new Dictionary<string, object>(); | 327 | Dictionary<string, object> result = new Dictionary<string, object>(); |
328 | 328 | ||
329 | int ndx = Convert.ToInt16(cmd[2]); | 329 | int ndx = Convert.ToInt16(cmd[2]); |
@@ -355,5 +355,5 @@ namespace OpenSim.Server.Base | |||
355 | return; | 355 | return; |
356 | } | 356 | } |
357 | #endregion | 357 | #endregion |
358 | } | 358 | } |
359 | } \ No newline at end of file | 359 | } \ 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 | |||
40 | { | 40 | { |
41 | public class HttpServerBase : ServicesServerBase | 41 | public class HttpServerBase : ServicesServerBase |
42 | { | 42 | { |
43 | // private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 44 | ||
45 | private uint m_consolePort; | 45 | private uint m_consolePort; |
46 | 46 | ||
@@ -70,6 +70,7 @@ namespace OpenSim.Server.Base | |||
70 | 70 | ||
71 | bool ssl_main = networkConfig.GetBoolean("https_main",false); | 71 | bool ssl_main = networkConfig.GetBoolean("https_main",false); |
72 | bool ssl_listener = networkConfig.GetBoolean("https_listener",false); | 72 | bool ssl_listener = networkConfig.GetBoolean("https_listener",false); |
73 | bool ssl_external = networkConfig.GetBoolean("https_external",false); | ||
73 | 74 | ||
74 | m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); | 75 | m_consolePort = (uint)networkConfig.GetInt("ConsolePort", 0); |
75 | 76 | ||
@@ -111,25 +112,33 @@ namespace OpenSim.Server.Base | |||
111 | MainServer.Instance = httpServer; | 112 | MainServer.Instance = httpServer; |
112 | 113 | ||
113 | // If https_listener = true, then add an ssl listener on the https_port... | 114 | // If https_listener = true, then add an ssl listener on the https_port... |
114 | if (ssl_listener == true) | 115 | if (ssl_listener == true) |
115 | { | 116 | { |
116 | uint https_port = (uint)networkConfig.GetInt("https_port", 0); | 117 | uint https_port = (uint)networkConfig.GetInt("https_port", 0); |
117 | 118 | ||
118 | string cert_path = networkConfig.GetString("cert_path",String.Empty); | 119 | m_log.WarnFormat("[SSL]: External flag is {0}", ssl_external); |
119 | if (cert_path == String.Empty) | 120 | if (!ssl_external) |
120 | { | 121 | { |
121 | System.Console.WriteLine("ERROR: Path to X509 certificate is missing, server can't start."); | 122 | string cert_path = networkConfig.GetString("cert_path",String.Empty); |
122 | Environment.Exit(1); | 123 | if ( cert_path == String.Empty ) |
124 | { | ||
125 | System.Console.WriteLine("Path to X509 certificate is missing, server can't start."); | ||
126 | Thread.CurrentThread.Abort(); | ||
127 | } | ||
128 | string cert_pass = networkConfig.GetString("cert_pass",String.Empty); | ||
129 | if ( cert_pass == String.Empty ) | ||
130 | { | ||
131 | System.Console.WriteLine("Password for X509 certificate is missing, server can't start."); | ||
132 | Thread.CurrentThread.Abort(); | ||
133 | } | ||
134 | |||
135 | MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); | ||
123 | } | 136 | } |
124 | 137 | else | |
125 | string cert_pass = networkConfig.GetString("cert_pass",String.Empty); | ||
126 | if (cert_pass == String.Empty) | ||
127 | { | 138 | { |
128 | System.Console.WriteLine("ERROR: Password for X509 certificate is missing, server can't start."); | 139 | m_log.WarnFormat("[SSL]: SSL port is active but no SSL is used because external SSL was requested."); |
129 | Environment.Exit(1); | 140 | MainServer.AddHttpServer(new BaseHttpServer(https_port)); |
130 | } | 141 | } |
131 | |||
132 | MainServer.AddHttpServer(new BaseHttpServer(https_port, ssl_listener, cert_path, cert_pass)); | ||
133 | } | 142 | } |
134 | } | 143 | } |
135 | 144 | ||
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 @@ | |||
2 | using System.Runtime.CompilerServices; | 2 | using System.Runtime.CompilerServices; |
3 | using System.Runtime.InteropServices; | 3 | using System.Runtime.InteropServices; |
4 | 4 | ||
5 | // General Information about an assembly is controlled through the following | 5 | // General Information about an assembly is controlled through the following |
6 | // set of attributes. Change these attribute values to modify the information | 6 | // set of attributes. Change these attribute values to modify the information |
7 | // associated with an assembly. | 7 | // associated with an assembly. |
8 | [assembly: AssemblyTitle("OpenSim.Server.Base")] | 8 | [assembly: AssemblyTitle("OpenSim.Server.Base")] |
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices; | |||
14 | [assembly: AssemblyTrademark("")] | 14 | [assembly: AssemblyTrademark("")] |
15 | [assembly: AssemblyCulture("")] | 15 | [assembly: AssemblyCulture("")] |
16 | 16 | ||
17 | // Setting ComVisible to false makes the types in this assembly not visible | 17 | // Setting ComVisible to false makes the types in this assembly not visible |
18 | // to COM components. If you need to access a type in this assembly from | 18 | // to COM components. If you need to access a type in this assembly from |
19 | // COM, set the ComVisible attribute to true on that type. | 19 | // COM, set the ComVisible attribute to true on that type. |
20 | [assembly: ComVisible(false)] | 20 | [assembly: ComVisible(false)] |
21 | 21 | ||
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices; | |||
25 | // Version information for an assembly consists of the following four values: | 25 | // Version information for an assembly consists of the following four values: |
26 | // | 26 | // |
27 | // Major Version | 27 | // Major Version |
28 | // Minor Version | 28 | // Minor Version |
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.8.3.*")] | 32 | [assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] |
33 | 33 | ||
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 | |||
31 | { | 31 | { |
32 | /// <value> | 32 | /// <value> |
33 | /// This is the external protocol versions. It is separate from the OpenSimulator project version. | 33 | /// This is the external protocol versions. It is separate from the OpenSimulator project version. |
34 | /// | 34 | /// |
35 | /// These version numbers should be increased by 1 every time a code | 35 | /// These version numbers should be increased by 1 every time a code |
36 | /// change in the Service.Connectors and Server.Handlers, espectively, | 36 | /// change in the Service.Connectors and Server.Handlers, espectively, |
37 | /// makes the previous OpenSimulator revision incompatible | 37 | /// makes the previous OpenSimulator revision incompatible |
38 | /// with the new revision. | 38 | /// with the new revision. |
39 | /// | 39 | /// |
40 | /// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality | 40 | /// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality |
41 | /// but not outright failure) do not need a version number increment. | 41 | /// but not outright failure) do not need a version number increment. |
42 | /// | 42 | /// |
43 | /// Having this version number allows the grid service to reject connections from regions running a version | 43 | /// Having this version number allows the grid service to reject connections from regions running a version |
44 | /// of the code that is too old. | 44 | /// of the code that is too old. |
45 | /// | 45 | /// |
46 | /// </value> | 46 | /// </value> |
47 | 47 | ||
48 | // The range of acceptable servers for client-side connectors | 48 | // The range of acceptable servers for client-side connectors |
49 | public readonly static int ClientProtocolVersionMin = 1; | 49 | public readonly static int ClientProtocolVersionMin = 1; |
50 | public readonly static int ClientProtocolVersionMax = 1; | 50 | 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; | |||
39 | using Mono.Addins; | 39 | using Mono.Addins; |
40 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
41 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
42 | 42 | using OpenMetaverse.StructuredData; // LitJson is hidden on this | |
43 | 43 | ||
44 | [assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)] | 44 | [assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)] |
45 | namespace OpenSim.Server.Base | 45 | namespace OpenSim.Server.Base |
@@ -104,7 +104,7 @@ namespace OpenSim.Server.Base | |||
104 | // libomv, which has a hard-coded path to "." for pinvoke | 104 | // libomv, which has a hard-coded path to "." for pinvoke |
105 | // to load the openjpeg dll | 105 | // to load the openjpeg dll |
106 | // | 106 | // |
107 | // Will look for a way to fix, but for now this keeps the | 107 | // Will look for a way to fix, but for now this keeps the |
108 | // confusion to a minimum. this was copied from our region | 108 | // confusion to a minimum. this was copied from our region |
109 | // plugin loader, we have been doing this in there for a long time. | 109 | // plugin loader, we have been doing this in there for a long time. |
110 | // | 110 | // |
@@ -183,7 +183,7 @@ namespace OpenSim.Server.Base | |||
183 | 183 | ||
184 | if(port != 0) | 184 | if(port != 0) |
185 | server = MainServer.GetHttpServer(port); | 185 | server = MainServer.GetHttpServer(port); |
186 | else | 186 | else |
187 | server = MainServer.Instance; | 187 | server = MainServer.Instance; |
188 | 188 | ||
189 | return server; | 189 | return server; |
@@ -222,19 +222,19 @@ namespace OpenSim.Server.Base | |||
222 | // This is good to debug configuration problems | 222 | // This is good to debug configuration problems |
223 | //if (dllName == string.Empty) | 223 | //if (dllName == string.Empty) |
224 | // Util.PrintCallStack(); | 224 | // Util.PrintCallStack(); |
225 | 225 | ||
226 | string className = String.Empty; | 226 | string className = String.Empty; |
227 | 227 | ||
228 | // The path for a dynamic plugin will contain ":" on Windows | 228 | // The path for a dynamic plugin will contain ":" on Windows |
229 | string[] parts = dllName.Split (new char[] {':'}); | 229 | string[] parts = dllName.Split (new char[] {':'}); |
230 | 230 | ||
231 | if (parts [0].Length > 1) | 231 | if (parts [0].Length > 1) |
232 | { | 232 | { |
233 | dllName = parts [0]; | 233 | dllName = parts [0]; |
234 | if (parts.Length > 1) | 234 | if (parts.Length > 1) |
235 | className = parts[1]; | 235 | className = parts[1]; |
236 | } | 236 | } |
237 | else | 237 | else |
238 | { | 238 | { |
239 | // This is Windows - we must replace the ":" in the path | 239 | // This is Windows - we must replace the ":" in the path |
240 | dllName = String.Format ("{0}:{1}", parts [0], parts [1]); | 240 | dllName = String.Format ("{0}:{1}", parts [0], parts [1]); |
@@ -242,6 +242,18 @@ namespace OpenSim.Server.Base | |||
242 | className = parts[2]; | 242 | className = parts[2]; |
243 | } | 243 | } |
244 | 244 | ||
245 | // Handle extra string arguments in a more generic way | ||
246 | if (dllName.Contains("@")) | ||
247 | { | ||
248 | string[] dllNameParts = dllName.Split(new char[] {'@'}); | ||
249 | dllName = dllNameParts[dllNameParts.Length - 1]; | ||
250 | List<Object> argList = new List<Object>(args); | ||
251 | for (int i = 0 ; i < dllNameParts.Length - 1 ; ++i) | ||
252 | argList.Add(dllNameParts[i]); | ||
253 | |||
254 | args = argList.ToArray(); | ||
255 | } | ||
256 | |||
245 | return LoadPlugin<T>(dllName, className, args); | 257 | return LoadPlugin<T>(dllName, className, args); |
246 | } | 258 | } |
247 | 259 | ||
@@ -264,10 +276,10 @@ namespace OpenSim.Server.Base | |||
264 | { | 276 | { |
265 | if (pluginType.IsPublic) | 277 | if (pluginType.IsPublic) |
266 | { | 278 | { |
267 | if (className != String.Empty | 279 | if (className != String.Empty |
268 | && pluginType.ToString() != pluginType.Namespace + "." + className) | 280 | && pluginType.ToString() != pluginType.Namespace + "." + className) |
269 | continue; | 281 | continue; |
270 | 282 | ||
271 | Type typeInterface = pluginType.GetInterface(interfaceName); | 283 | Type typeInterface = pluginType.GetInterface(interfaceName); |
272 | 284 | ||
273 | if (typeInterface != null) | 285 | if (typeInterface != null) |
@@ -283,8 +295,8 @@ namespace OpenSim.Server.Base | |||
283 | if (!(e is System.MissingMethodException)) | 295 | if (!(e is System.MissingMethodException)) |
284 | { | 296 | { |
285 | m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin {0} from {1}. Exception: {2}", | 297 | m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin {0} from {1}. Exception: {2}", |
286 | interfaceName, | 298 | interfaceName, |
287 | dllName, | 299 | dllName, |
288 | e.InnerException == null ? e.Message : e.InnerException.Message), | 300 | e.InnerException == null ? e.Message : e.InnerException.Message), |
289 | e); | 301 | e); |
290 | } | 302 | } |
@@ -315,49 +327,62 @@ namespace OpenSim.Server.Base | |||
315 | 327 | ||
316 | public static Dictionary<string, object> ParseQueryString(string query) | 328 | public static Dictionary<string, object> ParseQueryString(string query) |
317 | { | 329 | { |
318 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
319 | string[] terms = query.Split(new char[] {'&'}); | 330 | string[] terms = query.Split(new char[] {'&'}); |
320 | 331 | ||
321 | if (terms.Length == 0) | 332 | int nterms = terms.Length; |
322 | return result; | 333 | if (nterms == 0) |
334 | return new Dictionary<string, object>(); | ||
323 | 335 | ||
324 | foreach (string t in terms) | 336 | Dictionary<string, object> result = new Dictionary<string, object>(nterms); |
337 | string name; | ||
338 | |||
339 | for(int i = 0; i < nterms; ++i) | ||
325 | { | 340 | { |
326 | string[] elems = t.Split(new char[] {'='}); | 341 | string[] elems = terms[i].Split(new char[] {'='}); |
342 | |||
327 | if (elems.Length == 0) | 343 | if (elems.Length == 0) |
328 | continue; | 344 | continue; |
329 | 345 | ||
330 | string name = System.Web.HttpUtility.UrlDecode(elems[0]); | 346 | if(String.IsNullOrWhiteSpace(elems[0])) |
331 | string value = String.Empty; | 347 | continue; |
332 | 348 | ||
333 | if (elems.Length > 1) | 349 | name = System.Web.HttpUtility.UrlDecode(elems[0]); |
334 | value = System.Web.HttpUtility.UrlDecode(elems[1]); | ||
335 | 350 | ||
336 | if (name.EndsWith("[]")) | 351 | if (name.EndsWith("[]")) |
337 | { | 352 | { |
338 | string cleanName = name.Substring(0, name.Length - 2); | 353 | name = name.Substring(0, name.Length - 2); |
339 | if (result.ContainsKey(cleanName)) | 354 | if(String.IsNullOrWhiteSpace(name)) |
355 | continue; | ||
356 | if (result.ContainsKey(name)) | ||
340 | { | 357 | { |
341 | if (!(result[cleanName] is List<string>)) | 358 | if (!(result[name] is List<string>)) |
342 | continue; | 359 | continue; |
343 | 360 | ||
344 | List<string> l = (List<string>)result[cleanName]; | 361 | List<string> l = (List<string>)result[name]; |
345 | 362 | if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) | |
346 | l.Add(value); | 363 | l.Add(System.Web.HttpUtility.UrlDecode(elems[1])); |
364 | else | ||
365 | l.Add(String.Empty); | ||
347 | } | 366 | } |
348 | else | 367 | else |
349 | { | 368 | { |
350 | List<string> newList = new List<string>(); | 369 | List<string> newList = new List<string>(); |
351 | 370 | if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) | |
352 | newList.Add(value); | 371 | newList.Add(System.Web.HttpUtility.UrlDecode(elems[1])); |
353 | 372 | else | |
354 | result[cleanName] = newList; | 373 | newList.Add(String.Empty); |
374 | result[name] = newList; | ||
355 | } | 375 | } |
356 | } | 376 | } |
357 | else | 377 | else |
358 | { | 378 | { |
359 | if (!result.ContainsKey(name)) | 379 | if (!result.ContainsKey(name)) |
360 | result[name] = value; | 380 | { |
381 | if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) | ||
382 | result[name] = System.Web.HttpUtility.UrlDecode(elems[1]); | ||
383 | else | ||
384 | result[name] = String.Empty; | ||
385 | } | ||
361 | } | 386 | } |
362 | } | 387 | } |
363 | 388 | ||
@@ -366,47 +391,70 @@ namespace OpenSim.Server.Base | |||
366 | 391 | ||
367 | public static string BuildQueryString(Dictionary<string, object> data) | 392 | public static string BuildQueryString(Dictionary<string, object> data) |
368 | { | 393 | { |
369 | string qstring = String.Empty; | 394 | // this is not conform to html url encoding |
395 | // can only be used on Body of POST or PUT | ||
396 | StringBuilder sb = new StringBuilder(4096); | ||
370 | 397 | ||
371 | string part; | 398 | string pvalue; |
372 | 399 | ||
373 | foreach (KeyValuePair<string, object> kvp in data) | 400 | foreach (KeyValuePair<string, object> kvp in data) |
374 | { | 401 | { |
375 | if (kvp.Value is List<string>) | 402 | if (kvp.Value is List<string>) |
376 | { | 403 | { |
377 | List<string> l = (List<String>)kvp.Value; | 404 | List<string> l = (List<String>)kvp.Value; |
378 | 405 | int llen = l.Count; | |
379 | foreach (string s in l) | 406 | string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key); |
407 | for(int i = 0; i < llen; ++i) | ||
380 | { | 408 | { |
381 | part = System.Web.HttpUtility.UrlEncode(kvp.Key) + | 409 | if (sb.Length != 0) |
382 | "[]=" + System.Web.HttpUtility.UrlEncode(s); | 410 | sb.Append("&"); |
383 | 411 | sb.Append(nkey); | |
384 | if (qstring != String.Empty) | 412 | sb.Append("[]="); |
385 | qstring += "&"; | 413 | sb.Append(System.Web.HttpUtility.UrlEncode(l[i])); |
386 | |||
387 | qstring += part; | ||
388 | } | 414 | } |
389 | } | 415 | } |
390 | else | 416 | else if(kvp.Value is Dictionary<string, object>) |
391 | { | 417 | { |
392 | if (kvp.Value.ToString() != String.Empty) | 418 | // encode complex structures as JSON |
419 | // needed for estate bans with the encoding used on xml | ||
420 | // encode can be here because object does contain the structure information | ||
421 | // but decode needs to be on estateSettings (or other user) | ||
422 | string js; | ||
423 | try | ||
393 | { | 424 | { |
394 | part = System.Web.HttpUtility.UrlEncode(kvp.Key) + | 425 | // bypass libovm, we dont need even more useless high level maps |
395 | "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); | 426 | // this should only be called once.. but no problem, i hope |
427 | // (other uses may need more..) | ||
428 | LitJson.JsonMapper.RegisterExporter<UUID>((uuid, writer) => writer.Write(uuid.ToString()) ); | ||
429 | js = LitJson.JsonMapper.ToJson(kvp.Value); | ||
396 | } | 430 | } |
397 | else | 431 | // catch(Exception e) |
432 | catch | ||
398 | { | 433 | { |
399 | part = System.Web.HttpUtility.UrlEncode(kvp.Key); | 434 | continue; |
435 | } | ||
436 | if (sb.Length != 0) | ||
437 | sb.Append("&"); | ||
438 | sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); | ||
439 | sb.Append("="); | ||
440 | sb.Append(System.Web.HttpUtility.UrlEncode(js)); | ||
441 | } | ||
442 | else | ||
443 | { | ||
444 | if (sb.Length != 0) | ||
445 | sb.Append("&"); | ||
446 | sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); | ||
447 | |||
448 | pvalue = kvp.Value.ToString(); | ||
449 | if (!String.IsNullOrEmpty(pvalue)) | ||
450 | { | ||
451 | sb.Append("="); | ||
452 | sb.Append(System.Web.HttpUtility.UrlEncode(pvalue)); | ||
400 | } | 453 | } |
401 | |||
402 | if (qstring != String.Empty) | ||
403 | qstring += "&"; | ||
404 | |||
405 | qstring += part; | ||
406 | } | 454 | } |
407 | } | 455 | } |
408 | 456 | ||
409 | return qstring; | 457 | return sb.ToString(); |
410 | } | 458 | } |
411 | 459 | ||
412 | public static string BuildXmlResponse(Dictionary<string, object> data) | 460 | public static string BuildXmlResponse(Dictionary<string, object> data) |
@@ -465,18 +513,23 @@ namespace OpenSim.Server.Base | |||
465 | Dictionary<string, object> ret = new Dictionary<string, object>(); | 513 | Dictionary<string, object> ret = new Dictionary<string, object>(); |
466 | 514 | ||
467 | XmlDocument doc = new XmlDocument(); | 515 | XmlDocument doc = new XmlDocument(); |
516 | doc.XmlResolver = null; | ||
517 | try | ||
518 | { | ||
519 | doc.LoadXml(data); | ||
520 | XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); | ||
468 | 521 | ||
469 | doc.LoadXml(data); | 522 | if (rootL.Count != 1) |
470 | 523 | return ret; | |
471 | XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); | ||
472 | |||
473 | if (rootL.Count != 1) | ||
474 | return ret; | ||
475 | |||
476 | XmlNode rootNode = rootL[0]; | ||
477 | 524 | ||
478 | ret = ParseElement(rootNode); | 525 | XmlNode rootNode = rootL[0]; |
479 | 526 | ||
527 | ret = ParseElement(rootNode); | ||
528 | } | ||
529 | catch (Exception e) | ||
530 | { | ||
531 | m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0} \n --- string: {1} - ",e.Message, data); | ||
532 | } | ||
480 | return ret; | 533 | return ret; |
481 | } | 534 | } |
482 | 535 | ||
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 | |||
55 | // | 55 | // |
56 | protected string[] m_Arguments; | 56 | protected string[] m_Arguments; |
57 | 57 | ||
58 | public string ConfigDirectory | 58 | protected string m_configDirectory = "."; |
59 | { | ||
60 | get; | ||
61 | private set; | ||
62 | } | ||
63 | 59 | ||
64 | // Run flag | 60 | // Run flag |
65 | // | 61 | // |
66 | private bool m_Running = true; | 62 | private bool m_Running = true; |
67 | 63 | ||
64 | #if (_MONO) | ||
65 | private static Mono.Unix.UnixSignal[] signals; | ||
66 | #endif | ||
67 | |||
68 | // Handle all the automagical stuff | 68 | // Handle all the automagical stuff |
69 | // | 69 | // |
70 | public ServicesServerBase(string prompt, string[] args) : base() | 70 | public ServicesServerBase(string prompt, string[] args) : base() |
@@ -85,7 +85,7 @@ namespace OpenSim.Server.Base | |||
85 | string fileName = ""; | 85 | string fileName = ""; |
86 | if (Assembly.GetEntryAssembly() != null) | 86 | if (Assembly.GetEntryAssembly() != null) |
87 | fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); | 87 | fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); |
88 | string iniFile = "../config/" + fileName + ".ini"; | 88 | string iniFile = fileName + ".ini"; |
89 | string logConfig = null; | 89 | string logConfig = null; |
90 | 90 | ||
91 | IConfig startupConfig = argvConfig.Configs["Startup"]; | 91 | IConfig startupConfig = argvConfig.Configs["Startup"]; |
@@ -96,39 +96,31 @@ namespace OpenSim.Server.Base | |||
96 | 96 | ||
97 | // Check if a prompt was given on the command line | 97 | // Check if a prompt was given on the command line |
98 | prompt = startupConfig.GetString("prompt", prompt); | 98 | prompt = startupConfig.GetString("prompt", prompt); |
99 | 99 | ||
100 | // Check for a Log4Net config file on the command line | 100 | // Check for a Log4Net config file on the command line |
101 | logConfig =startupConfig.GetString("logconfig", logConfig); | 101 | logConfig =startupConfig.GetString("logconfig", logConfig); |
102 | } | 102 | } |
103 | 103 | ||
104 | // Find out of the file name is a URI and remote load it if possible. | 104 | Config = ReadConfigSource(iniFile); |
105 | // Load it as a local file otherwise. | ||
106 | Uri configUri; | ||
107 | 105 | ||
108 | try | 106 | List<string> sources = new List<string>(); |
107 | sources.Add(iniFile); | ||
108 | |||
109 | int sourceIndex = 1; | ||
110 | |||
111 | while (AddIncludes(Config, sources)) | ||
109 | { | 112 | { |
110 | if (Uri.TryCreate(iniFile, UriKind.Absolute, out configUri) && | 113 | for ( ; sourceIndex < sources.Count ; ++sourceIndex) |
111 | configUri.Scheme == Uri.UriSchemeHttp) | ||
112 | { | 114 | { |
113 | XmlReader r = XmlReader.Create(iniFile); | 115 | IConfigSource s = ReadConfigSource(sources[sourceIndex]); |
114 | Config = new XmlConfigSource(r); | 116 | Config.Merge(s); |
115 | } | 117 | } |
116 | else | ||
117 | { | ||
118 | Config = new IniConfigSource(iniFile); | ||
119 | } | ||
120 | } | ||
121 | catch (Exception e) | ||
122 | { | ||
123 | System.Console.WriteLine("Error reading from config source. {0}", e.Message); | ||
124 | System.Diagnostics.Process.GetCurrentProcess().Kill(); | ||
125 | ///// Environment.Exit(1); | ||
126 | } | 118 | } |
127 | 119 | ||
128 | // Merge OpSys env vars | 120 | // Merge OpSys env vars |
129 | m_log.Info("[CONFIG]: Loading environment variables for Config"); | 121 | Console.WriteLine("[CONFIG]: Loading environment variables for Config"); |
130 | Util.MergeEnvironmentToConfig(Config); | 122 | Util.MergeEnvironmentToConfig(Config); |
131 | 123 | ||
132 | // Merge the configuration from the command line into the loaded file | 124 | // Merge the configuration from the command line into the loaded file |
133 | Config.Merge(argvConfig); | 125 | Config.Merge(argvConfig); |
134 | 126 | ||
@@ -140,10 +132,12 @@ namespace OpenSim.Server.Base | |||
140 | startupConfig = Config.Configs["Startup"]; | 132 | startupConfig = Config.Configs["Startup"]; |
141 | } | 133 | } |
142 | 134 | ||
143 | ConfigDirectory = startupConfig.GetString("ConfigDirectory", "."); | 135 | if (startupConfig != null) |
144 | 136 | { | |
145 | prompt = startupConfig.GetString("Prompt", prompt); | 137 | m_configDirectory = startupConfig.GetString("ConfigDirectory", m_configDirectory); |
146 | 138 | ||
139 | prompt = startupConfig.GetString("Prompt", prompt); | ||
140 | } | ||
147 | // Allow derived classes to load config before the console is opened. | 141 | // Allow derived classes to load config before the console is opened. |
148 | ReadConfig(); | 142 | ReadConfig(); |
149 | 143 | ||
@@ -193,6 +187,42 @@ namespace OpenSim.Server.Base | |||
193 | RegisterCommonCommands(); | 187 | RegisterCommonCommands(); |
194 | RegisterCommonComponents(Config); | 188 | RegisterCommonComponents(Config); |
195 | 189 | ||
190 | #if (_MONO) | ||
191 | Thread signal_thread = new Thread (delegate () | ||
192 | { | ||
193 | while (true) | ||
194 | { | ||
195 | // Wait for a signal to be delivered | ||
196 | int index = Mono.Unix.UnixSignal.WaitAny (signals, -1); | ||
197 | |||
198 | //Mono.Unix.Native.Signum signal = signals [index].Signum; | ||
199 | ShutdownSpecific(); | ||
200 | m_Running = false; | ||
201 | Environment.Exit(0); | ||
202 | } | ||
203 | }); | ||
204 | |||
205 | if(!Util.IsWindows()) | ||
206 | { | ||
207 | try | ||
208 | { | ||
209 | // linux mac os specifics | ||
210 | signals = new Mono.Unix.UnixSignal[] | ||
211 | { | ||
212 | new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM) | ||
213 | }; | ||
214 | ignal_thread.IsBackground = true; | ||
215 | signal_thread.Start(); | ||
216 | } | ||
217 | catch (Exception e) | ||
218 | { | ||
219 | m_log.Info("Could not set up UNIX signal handlers. SIGTERM will not"); | ||
220 | m_log.InfoFormat("shut down gracefully: {0}", e.Message); | ||
221 | m_log.Debug("Exception was: ", e); | ||
222 | } | ||
223 | } | ||
224 | #endif | ||
225 | |||
196 | // Allow derived classes to perform initialization that | 226 | // Allow derived classes to perform initialization that |
197 | // needs to be done after the console has opened | 227 | // needs to be done after the console has opened |
198 | Initialise(); | 228 | Initialise(); |
@@ -220,6 +250,9 @@ namespace OpenSim.Server.Base | |||
220 | } | 250 | } |
221 | } | 251 | } |
222 | 252 | ||
253 | MemoryWatchdog.Enabled = false; | ||
254 | Watchdog.Enabled = false; | ||
255 | WorkManager.Stop(); | ||
223 | RemovePIDFile(); | 256 | RemovePIDFile(); |
224 | 257 | ||
225 | return 0; | 258 | return 0; |
@@ -240,5 +273,114 @@ namespace OpenSim.Server.Base | |||
240 | protected virtual void Initialise() | 273 | protected virtual void Initialise() |
241 | { | 274 | { |
242 | } | 275 | } |
276 | |||
277 | /// <summary> | ||
278 | /// Adds the included files as ini configuration files | ||
279 | /// </summary> | ||
280 | /// <param name="sources">List of URL strings or filename strings</param> | ||
281 | private bool AddIncludes(IConfigSource configSource, List<string> sources) | ||
282 | { | ||
283 | bool sourcesAdded = false; | ||
284 | |||
285 | //loop over config sources | ||
286 | foreach (IConfig config in configSource.Configs) | ||
287 | { | ||
288 | // Look for Include-* in the key name | ||
289 | string[] keys = config.GetKeys(); | ||
290 | foreach (string k in keys) | ||
291 | { | ||
292 | if (k.StartsWith("Include-")) | ||
293 | { | ||
294 | // read the config file to be included. | ||
295 | string file = config.GetString(k); | ||
296 | if (IsUri(file)) | ||
297 | { | ||
298 | if (!sources.Contains(file)) | ||
299 | { | ||
300 | sourcesAdded = true; | ||
301 | sources.Add(file); | ||
302 | } | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | string basepath = Path.GetFullPath(m_configDirectory); | ||
307 | // Resolve relative paths with wildcards | ||
308 | string chunkWithoutWildcards = file; | ||
309 | string chunkWithWildcards = string.Empty; | ||
310 | int wildcardIndex = file.IndexOfAny(new char[] { '*', '?' }); | ||
311 | if (wildcardIndex != -1) | ||
312 | { | ||
313 | chunkWithoutWildcards = file.Substring(0, wildcardIndex); | ||
314 | chunkWithWildcards = file.Substring(wildcardIndex); | ||
315 | } | ||
316 | string path = Path.Combine(basepath, chunkWithoutWildcards); | ||
317 | path = Path.GetFullPath(path) + chunkWithWildcards; | ||
318 | string[] paths = Util.Glob(path); | ||
319 | |||
320 | // If the include path contains no wildcards, then warn the user that it wasn't found. | ||
321 | if (wildcardIndex == -1 && paths.Length == 0) | ||
322 | { | ||
323 | Console.WriteLine("[CONFIG]: Could not find include file {0}", path); | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | foreach (string p in paths) | ||
328 | { | ||
329 | if (!sources.Contains(p)) | ||
330 | { | ||
331 | sourcesAdded = true; | ||
332 | sources.Add(p); | ||
333 | } | ||
334 | } | ||
335 | } | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | |||
341 | return sourcesAdded; | ||
342 | } | ||
343 | |||
344 | /// <summary> | ||
345 | /// Check if we can convert the string to a URI | ||
346 | /// </summary> | ||
347 | /// <param name="file">String uri to the remote resource</param> | ||
348 | /// <returns>true if we can convert the string to a Uri object</returns> | ||
349 | bool IsUri(string file) | ||
350 | { | ||
351 | Uri configUri; | ||
352 | |||
353 | return Uri.TryCreate(file, UriKind.Absolute, | ||
354 | out configUri) && configUri.Scheme == Uri.UriSchemeHttp; | ||
355 | } | ||
356 | |||
357 | IConfigSource ReadConfigSource(string iniFile) | ||
358 | { | ||
359 | // Find out of the file name is a URI and remote load it if possible. | ||
360 | // Load it as a local file otherwise. | ||
361 | Uri configUri; | ||
362 | IConfigSource s = null; | ||
363 | |||
364 | try | ||
365 | { | ||
366 | if (Uri.TryCreate(iniFile, UriKind.Absolute, out configUri) && | ||
367 | configUri.Scheme == Uri.UriSchemeHttp) | ||
368 | { | ||
369 | XmlReader r = XmlReader.Create(iniFile); | ||
370 | s = new XmlConfigSource(r); | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | s = new IniConfigSource(iniFile); | ||
375 | } | ||
376 | } | ||
377 | catch (Exception e) | ||
378 | { | ||
379 | System.Console.WriteLine("Error reading from config source. {0}", e.Message); | ||
380 | Environment.Exit(1); | ||
381 | } | ||
382 | |||
383 | return s; | ||
384 | } | ||
243 | } | 385 | } |
244 | } | 386 | } |