diff options
Diffstat (limited to 'OpenSim/Server')
-rw-r--r-- | OpenSim/Server/Base/HttpServerBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Server/Base/Properties/AssemblyInfo.cs | 33 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 138 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | 20 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | 47 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs | 15 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs | 110 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | 18 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Properties/AssemblyInfo.cs | 33 | ||||
-rw-r--r-- | OpenSim/Server/Properties/AssemblyInfo.cs | 33 | ||||
-rw-r--r-- | OpenSim/Server/ServerMain.cs | 22 |
11 files changed, 336 insertions, 135 deletions
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index 29b1c00..954783c 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Server.Base | |||
52 | 52 | ||
53 | protected override void ReadConfig() | 53 | protected override void ReadConfig() |
54 | { | 54 | { |
55 | IConfig networkConfig = m_Config.Configs["Network"]; | 55 | IConfig networkConfig = Config.Configs["Network"]; |
56 | 56 | ||
57 | if (networkConfig == null) | 57 | if (networkConfig == null) |
58 | { | 58 | { |
diff --git a/OpenSim/Server/Base/Properties/AssemblyInfo.cs b/OpenSim/Server/Base/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4bbe358 --- /dev/null +++ b/OpenSim/Server/Base/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Server.Base")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
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 | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("8fbd5035-0dbc-4b9a-ad1a-a7567f254ea9")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index b137c05..5b23149 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -33,6 +34,7 @@ using System.Text; | |||
33 | using System.Xml; | 34 | using System.Xml; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Servers; | ||
36 | using log4net; | 38 | using log4net; |
37 | using log4net.Config; | 39 | using log4net.Config; |
38 | using log4net.Appender; | 40 | using log4net.Appender; |
@@ -42,7 +44,7 @@ using Nini.Config; | |||
42 | 44 | ||
43 | namespace OpenSim.Server.Base | 45 | namespace OpenSim.Server.Base |
44 | { | 46 | { |
45 | public class ServicesServerBase | 47 | public class ServicesServerBase : ServerBase |
46 | { | 48 | { |
47 | // Logger | 49 | // Logger |
48 | // | 50 | // |
@@ -54,26 +56,13 @@ namespace OpenSim.Server.Base | |||
54 | // | 56 | // |
55 | protected string[] m_Arguments; | 57 | protected string[] m_Arguments; |
56 | 58 | ||
57 | // Configuration | ||
58 | // | ||
59 | protected IConfigSource m_Config = null; | ||
60 | |||
61 | public IConfigSource Config | ||
62 | { | ||
63 | get { return m_Config; } | ||
64 | } | ||
65 | |||
66 | // Run flag | 59 | // Run flag |
67 | // | 60 | // |
68 | private bool m_Running = true; | 61 | private bool m_Running = true; |
69 | 62 | ||
70 | // PID file | ||
71 | // | ||
72 | private string m_pidFile = String.Empty; | ||
73 | |||
74 | // Handle all the automagical stuff | 63 | // Handle all the automagical stuff |
75 | // | 64 | // |
76 | public ServicesServerBase(string prompt, string[] args) | 65 | public ServicesServerBase(string prompt, string[] args) : base() |
77 | { | 66 | { |
78 | // Save raw arguments | 67 | // Save raw arguments |
79 | // | 68 | // |
@@ -120,11 +109,11 @@ namespace OpenSim.Server.Base | |||
120 | configUri.Scheme == Uri.UriSchemeHttp) | 109 | configUri.Scheme == Uri.UriSchemeHttp) |
121 | { | 110 | { |
122 | XmlReader r = XmlReader.Create(iniFile); | 111 | XmlReader r = XmlReader.Create(iniFile); |
123 | m_Config = new XmlConfigSource(r); | 112 | Config = new XmlConfigSource(r); |
124 | } | 113 | } |
125 | else | 114 | else |
126 | { | 115 | { |
127 | m_Config = new IniConfigSource(iniFile); | 116 | Config = new IniConfigSource(iniFile); |
128 | } | 117 | } |
129 | } | 118 | } |
130 | catch (Exception e) | 119 | catch (Exception e) |
@@ -136,13 +125,13 @@ namespace OpenSim.Server.Base | |||
136 | // Merge the configuration from the command line into the | 125 | // Merge the configuration from the command line into the |
137 | // loaded file | 126 | // loaded file |
138 | // | 127 | // |
139 | m_Config.Merge(argvConfig); | 128 | Config.Merge(argvConfig); |
140 | 129 | ||
141 | // Refresh the startupConfig post merge | 130 | // Refresh the startupConfig post merge |
142 | // | 131 | // |
143 | if (m_Config.Configs["Startup"] != null) | 132 | if (Config.Configs["Startup"] != null) |
144 | { | 133 | { |
145 | startupConfig = m_Config.Configs["Startup"]; | 134 | startupConfig = Config.Configs["Startup"]; |
146 | } | 135 | } |
147 | 136 | ||
148 | prompt = startupConfig.GetString("Prompt", prompt); | 137 | prompt = startupConfig.GetString("Prompt", prompt); |
@@ -172,6 +161,8 @@ namespace OpenSim.Server.Base | |||
172 | MainConsole.Instance = new LocalConsole(prompt); | 161 | MainConsole.Instance = new LocalConsole(prompt); |
173 | } | 162 | } |
174 | 163 | ||
164 | m_console = MainConsole.Instance; | ||
165 | |||
175 | // Configure the appenders for log4net | 166 | // Configure the appenders for log4net |
176 | // | 167 | // |
177 | OpenSimAppender consoleAppender = null; | 168 | OpenSimAppender consoleAppender = null; |
@@ -187,54 +178,15 @@ namespace OpenSim.Server.Base | |||
187 | XmlConfigurator.Configure(); | 178 | XmlConfigurator.Configure(); |
188 | } | 179 | } |
189 | 180 | ||
190 | ILoggerRepository repository = LogManager.GetRepository(); | 181 | RegisterCommonAppenders(startupConfig); |
191 | IAppender[] appenders = repository.GetAppenders(); | ||
192 | |||
193 | foreach (IAppender appender in appenders) | ||
194 | { | ||
195 | if (appender.Name == "Console") | ||
196 | { | ||
197 | consoleAppender = (OpenSimAppender)appender; | ||
198 | } | ||
199 | if (appender.Name == "LogFileAppender") | ||
200 | { | ||
201 | fileAppender = (FileAppender)appender; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | if (consoleAppender == null) | ||
206 | { | ||
207 | System.Console.WriteLine("No console appender found. Server can't start"); | ||
208 | Thread.CurrentThread.Abort(); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | consoleAppender.Console = (ConsoleBase)MainConsole.Instance; | ||
213 | |||
214 | if (null == consoleAppender.Threshold) | ||
215 | consoleAppender.Threshold = Level.All; | ||
216 | } | ||
217 | |||
218 | // Set log file | ||
219 | // | ||
220 | if (fileAppender != null) | ||
221 | { | ||
222 | if (startupConfig != null) | ||
223 | { | ||
224 | string cfgFileName = startupConfig.GetString("logfile", null); | ||
225 | if (cfgFileName != null) | ||
226 | { | ||
227 | fileAppender.File = cfgFileName; | ||
228 | fileAppender.ActivateOptions(); | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | 182 | ||
233 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) | 183 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) |
234 | { | 184 | { |
235 | CreatePIDFile(startupConfig.GetString("PIDFile")); | 185 | CreatePIDFile(startupConfig.GetString("PIDFile")); |
236 | } | 186 | } |
237 | 187 | ||
188 | RegisterCommonCommands(); | ||
189 | |||
238 | // Register the quit command | 190 | // Register the quit command |
239 | // | 191 | // |
240 | MainConsole.Instance.Commands.AddCommand("General", false, "quit", | 192 | MainConsole.Instance.Commands.AddCommand("General", false, "quit", |
@@ -244,12 +196,6 @@ namespace OpenSim.Server.Base | |||
244 | MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", | 196 | MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", |
245 | "shutdown", | 197 | "shutdown", |
246 | "Quit the application", HandleQuit); | 198 | "Quit the application", HandleQuit); |
247 | |||
248 | // Register a command to read other commands from a file | ||
249 | MainConsole.Instance.Commands.AddCommand("General", false, "command-script", | ||
250 | "command-script <script>", | ||
251 | "Run a command script from file", HandleScript); | ||
252 | |||
253 | 199 | ||
254 | // Allow derived classes to perform initialization that | 200 | // Allow derived classes to perform initialization that |
255 | // needs to be done after the console has opened | 201 | // needs to be done after the console has opened |
@@ -276,8 +222,8 @@ namespace OpenSim.Server.Base | |||
276 | } | 222 | } |
277 | } | 223 | } |
278 | 224 | ||
279 | if (m_pidFile != String.Empty) | 225 | RemovePIDFile(); |
280 | File.Delete(m_pidFile); | 226 | |
281 | return 0; | 227 | return 0; |
282 | } | 228 | } |
283 | 229 | ||
@@ -285,43 +231,9 @@ namespace OpenSim.Server.Base | |||
285 | { | 231 | { |
286 | m_Running = false; | 232 | m_Running = false; |
287 | m_log.Info("[CONSOLE] Quitting"); | 233 | m_log.Info("[CONSOLE] Quitting"); |
288 | } | ||
289 | |||
290 | protected virtual void HandleScript(string module, string[] parms) | ||
291 | { | ||
292 | if (parms.Length != 2) | ||
293 | { | ||
294 | return; | ||
295 | } | ||
296 | RunCommandScript(parms[1]); | ||
297 | } | ||
298 | |||
299 | /// <summary> | ||
300 | /// Run an optional startup list of commands | ||
301 | /// </summary> | ||
302 | /// <param name="fileName"></param> | ||
303 | private void RunCommandScript(string fileName) | ||
304 | { | ||
305 | if (File.Exists(fileName)) | ||
306 | { | ||
307 | m_log.Info("[COMMANDFILE]: Running " + fileName); | ||
308 | 234 | ||
309 | using (StreamReader readFile = File.OpenText(fileName)) | ||
310 | { | ||
311 | string currentCommand; | ||
312 | while ((currentCommand = readFile.ReadLine()) != null) | ||
313 | { | ||
314 | if (currentCommand != String.Empty) | ||
315 | { | ||
316 | m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); | ||
317 | MainConsole.Instance.RunCommand(currentCommand); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | } | ||
322 | } | 235 | } |
323 | 236 | ||
324 | |||
325 | protected virtual void ReadConfig() | 237 | protected virtual void ReadConfig() |
326 | { | 238 | { |
327 | } | 239 | } |
@@ -329,21 +241,5 @@ namespace OpenSim.Server.Base | |||
329 | protected virtual void Initialise() | 241 | protected virtual void Initialise() |
330 | { | 242 | { |
331 | } | 243 | } |
332 | |||
333 | protected void CreatePIDFile(string path) | ||
334 | { | ||
335 | try | ||
336 | { | ||
337 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
338 | FileStream fs = File.Create(path); | ||
339 | Byte[] buf = Encoding.ASCII.GetBytes(pidstring); | ||
340 | fs.Write(buf, 0, buf.Length); | ||
341 | fs.Close(); | ||
342 | m_pidFile = path; | ||
343 | } | ||
344 | catch (Exception) | ||
345 | { | ||
346 | } | ||
347 | } | ||
348 | } | 244 | } |
349 | } | 245 | } \ No newline at end of file |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 46b0c67..ff45d94 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -67,10 +67,25 @@ namespace OpenSim.Server.Handlers.Asset | |||
67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | 67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); |
68 | 68 | ||
69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); | 69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); |
70 | bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); | ||
71 | |||
72 | AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; | ||
73 | |||
74 | if (!allowDelete) | ||
75 | { | ||
76 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.None; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | if (allowDeleteAllTypes) | ||
81 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.All; | ||
82 | else | ||
83 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; | ||
84 | } | ||
70 | 85 | ||
71 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 86 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); |
72 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); | 87 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); |
73 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); | 88 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); |
74 | 89 | ||
75 | MainConsole.Instance.Commands.AddCommand("Assets", false, | 90 | MainConsole.Instance.Commands.AddCommand("Assets", false, |
76 | "show asset", | 91 | "show asset", |
@@ -141,6 +156,9 @@ namespace OpenSim.Server.Handlers.Asset | |||
141 | } | 156 | } |
142 | 157 | ||
143 | string fileName = rawAssetId; | 158 | string fileName = rawAssetId; |
159 | |||
160 | if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName)) | ||
161 | return; | ||
144 | 162 | ||
145 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | 163 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) |
146 | { | 164 | { |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 0cfe5b1..986394b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |||
@@ -42,18 +42,32 @@ using OpenSim.Framework.Servers.HttpServer; | |||
42 | 42 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 43 | namespace OpenSim.Server.Handlers.Asset |
44 | { | 44 | { |
45 | /// <summary> | ||
46 | /// Remote deletes allowed. | ||
47 | /// </summary> | ||
48 | public enum AllowedRemoteDeleteTypes | ||
49 | { | ||
50 | None, | ||
51 | MapTile, | ||
52 | All | ||
53 | } | ||
54 | |||
45 | public class AssetServerDeleteHandler : BaseStreamHandler | 55 | public class AssetServerDeleteHandler : BaseStreamHandler |
46 | { | 56 | { |
47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 58 | ||
49 | private IAssetService m_AssetService; | 59 | private IAssetService m_AssetService; |
50 | protected bool m_allowDelete; | ||
51 | 60 | ||
52 | public AssetServerDeleteHandler(IAssetService service, bool allowDelete) : | 61 | /// <summary> |
62 | /// Asset types that can be deleted remotely. | ||
63 | /// </summary> | ||
64 | private AllowedRemoteDeleteTypes m_allowedTypes; | ||
65 | |||
66 | public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes) : | ||
53 | base("DELETE", "/assets") | 67 | base("DELETE", "/assets") |
54 | { | 68 | { |
55 | m_AssetService = service; | 69 | m_AssetService = service; |
56 | m_allowDelete = allowDelete; | 70 | m_allowedTypes = allowedTypes; |
57 | } | 71 | } |
58 | 72 | ||
59 | public override byte[] Handle(string path, Stream request, | 73 | public override byte[] Handle(string path, Stream request, |
@@ -63,13 +77,32 @@ namespace OpenSim.Server.Handlers.Asset | |||
63 | 77 | ||
64 | string[] p = SplitParams(path); | 78 | string[] p = SplitParams(path); |
65 | 79 | ||
66 | if (p.Length > 0 && m_allowDelete) | 80 | if (p.Length > 0) |
67 | { | 81 | { |
68 | result = m_AssetService.Delete(p[0]); | 82 | if (m_allowedTypes != AllowedRemoteDeleteTypes.None) |
83 | { | ||
84 | string assetID = p[0]; | ||
85 | |||
86 | AssetBase asset = m_AssetService.Get(assetID); | ||
87 | if (asset != null) | ||
88 | { | ||
89 | if (m_allowedTypes == AllowedRemoteDeleteTypes.All | ||
90 | || (int)(asset.Flags & AssetFlags.Maptile) != 0) | ||
91 | { | ||
92 | result = m_AssetService.Delete(assetID); | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | m_log.DebugFormat( | ||
97 | "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but type is {1} and allowed remote delete types are {2}", | ||
98 | assetID, (AssetFlags)asset.Flags, m_allowedTypes); | ||
99 | } | ||
100 | } | ||
101 | } | ||
69 | } | 102 | } |
70 | 103 | ||
71 | XmlSerializer xs = new XmlSerializer(typeof(bool)); | 104 | XmlSerializer xs = new XmlSerializer(typeof(bool)); |
72 | return ServerUtils.SerializeResult(xs, result); | 105 | return ServerUtils.SerializeResult(xs, result); |
73 | } | 106 | } |
74 | } | 107 | } |
75 | } | 108 | } \ No newline at end of file |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs index 87b3d2d..a006fa8 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs | |||
@@ -57,14 +57,23 @@ namespace OpenSim.Server.Handlers.Asset | |||
57 | public override byte[] Handle(string path, Stream request, | 57 | public override byte[] Handle(string path, Stream request, |
58 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 58 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
59 | { | 59 | { |
60 | AssetBase asset; | ||
60 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); | 61 | XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); |
61 | AssetBase asset = (AssetBase) xs.Deserialize(request); | 62 | |
63 | try | ||
64 | { | ||
65 | asset = (AssetBase)xs.Deserialize(request); | ||
66 | } | ||
67 | catch (XmlException) | ||
68 | { | ||
69 | httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; | ||
70 | return null; | ||
71 | } | ||
62 | 72 | ||
63 | string[] p = SplitParams(path); | 73 | string[] p = SplitParams(path); |
64 | if (p.Length > 1) | 74 | if (p.Length > 1) |
65 | { | 75 | { |
66 | bool result = | 76 | bool result = m_AssetService.UpdateContent(p[1], asset.Data); |
67 | m_AssetService.UpdateContent(p[1], asset.Data); | ||
68 | 77 | ||
69 | xs = new XmlSerializer(typeof(bool)); | 78 | xs = new XmlSerializer(typeof(bool)); |
70 | return ServerUtils.SerializeResult(xs, result); | 79 | return ServerUtils.SerializeResult(xs, result); |
diff --git a/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs new file mode 100644 index 0000000..427fa16 --- /dev/null +++ b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Text; | ||
32 | using System.Xml; | ||
33 | using System.Xml.Serialization; | ||
34 | using Nini.Config; | ||
35 | using NUnit.Framework; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Server.Handlers.Asset; | ||
39 | using OpenSim.Services.AssetService; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Tests.Common; | ||
42 | using OpenSim.Tests.Common.Mock; | ||
43 | |||
44 | namespace OpenSim.Server.Handlers.Asset.Test | ||
45 | { | ||
46 | [TestFixture] | ||
47 | public class AssetServerPostHandlerTests : OpenSimTestCase | ||
48 | { | ||
49 | [Test] | ||
50 | public void TestGoodAssetStoreRequest() | ||
51 | { | ||
52 | TestHelpers.InMethod(); | ||
53 | |||
54 | UUID assetId = TestHelpers.ParseTail(0x1); | ||
55 | |||
56 | IConfigSource config = new IniConfigSource(); | ||
57 | config.AddConfig("AssetService"); | ||
58 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | ||
59 | |||
60 | AssetService assetService = new AssetService(config); | ||
61 | |||
62 | AssetServerPostHandler asph = new AssetServerPostHandler(assetService); | ||
63 | |||
64 | AssetBase asset = AssetHelpers.CreateNotecardAsset(assetId, "Hello World"); | ||
65 | |||
66 | MemoryStream buffer = new MemoryStream(); | ||
67 | |||
68 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
69 | settings.Encoding = Encoding.UTF8; | ||
70 | |||
71 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
72 | { | ||
73 | XmlSerializer serializer = new XmlSerializer(typeof(AssetBase)); | ||
74 | serializer.Serialize(writer, asset); | ||
75 | writer.Flush(); | ||
76 | } | ||
77 | |||
78 | buffer.Position = 0; | ||
79 | asph.Handle(null, buffer, null, null); | ||
80 | |||
81 | AssetBase retrievedAsset = assetService.Get(assetId.ToString()); | ||
82 | |||
83 | Assert.That(retrievedAsset, Is.Not.Null); | ||
84 | } | ||
85 | |||
86 | [Test] | ||
87 | public void TestBadXmlAssetStoreRequest() | ||
88 | { | ||
89 | TestHelpers.InMethod(); | ||
90 | |||
91 | IConfigSource config = new IniConfigSource(); | ||
92 | config.AddConfig("AssetService"); | ||
93 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | ||
94 | |||
95 | AssetService assetService = new AssetService(config); | ||
96 | |||
97 | AssetServerPostHandler asph = new AssetServerPostHandler(assetService); | ||
98 | |||
99 | MemoryStream buffer = new MemoryStream(); | ||
100 | byte[] badData = new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f }; | ||
101 | buffer.Write(badData, 0, badData.Length); | ||
102 | buffer.Position = 0; | ||
103 | |||
104 | TestOSHttpResponse response = new TestOSHttpResponse(); | ||
105 | asph.Handle(null, buffer, null, response); | ||
106 | |||
107 | Assert.That(response.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest)); | ||
108 | } | ||
109 | } | ||
110 | } \ No newline at end of file | ||
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index 393584e..8cd747e 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | |||
@@ -137,6 +137,8 @@ namespace OpenSim.Server.Handlers.Avatar | |||
137 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | 137 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) |
138 | return FailureResult(); | 138 | return FailureResult(); |
139 | 139 | ||
140 | RemoveRequestParamsNotForStorage(request); | ||
141 | |||
140 | AvatarData avatar = new AvatarData(request); | 142 | AvatarData avatar = new AvatarData(request); |
141 | if (m_AvatarService.SetAvatar(user, avatar)) | 143 | if (m_AvatarService.SetAvatar(user, avatar)) |
142 | return SuccessResult(); | 144 | return SuccessResult(); |
@@ -153,11 +155,25 @@ namespace OpenSim.Server.Handlers.Avatar | |||
153 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | 155 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) |
154 | return FailureResult(); | 156 | return FailureResult(); |
155 | 157 | ||
158 | RemoveRequestParamsNotForStorage(request); | ||
159 | |||
156 | if (m_AvatarService.ResetAvatar(user)) | 160 | if (m_AvatarService.ResetAvatar(user)) |
157 | return SuccessResult(); | 161 | return SuccessResult(); |
158 | 162 | ||
159 | return FailureResult(); | 163 | return FailureResult(); |
160 | } | 164 | } |
165 | |||
166 | /// <summary> | ||
167 | /// Remove parameters that were used to invoke the method and should not in themselves be persisted. | ||
168 | /// </summary> | ||
169 | /// <param name='request'></param> | ||
170 | private void RemoveRequestParamsNotForStorage(Dictionary<string, object> request) | ||
171 | { | ||
172 | request.Remove("VERSIONMAX"); | ||
173 | request.Remove("VERSIONMIN"); | ||
174 | request.Remove("METHOD"); | ||
175 | request.Remove("UserID"); | ||
176 | } | ||
161 | 177 | ||
162 | byte[] SetItems(Dictionary<string, object> request) | 178 | byte[] SetItems(Dictionary<string, object> request) |
163 | { | 179 | { |
@@ -173,6 +189,8 @@ namespace OpenSim.Server.Handlers.Avatar | |||
173 | if (!(request["Names"] is List<string> || request["Values"] is List<string>)) | 189 | if (!(request["Names"] is List<string> || request["Values"] is List<string>)) |
174 | return FailureResult(); | 190 | return FailureResult(); |
175 | 191 | ||
192 | RemoveRequestParamsNotForStorage(request); | ||
193 | |||
176 | List<string> _names = (List<string>)request["Names"]; | 194 | List<string> _names = (List<string>)request["Names"]; |
177 | names = _names.ToArray(); | 195 | names = _names.ToArray(); |
178 | List<string> _values = (List<string>)request["Values"]; | 196 | List<string> _values = (List<string>)request["Values"]; |
diff --git a/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs b/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..53e9737 --- /dev/null +++ b/OpenSim/Server/Handlers/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Server.Handlers")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
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 | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("6319afca-d740-4468-a95d-d7f87a081cb3")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Server/Properties/AssemblyInfo.cs b/OpenSim/Server/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ebc10fb --- /dev/null +++ b/OpenSim/Server/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("Robust")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
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 | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("d347c5cb-baf8-4566-a221-35d948e1776f")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs index 21fb678..45c13fb 100644 --- a/OpenSim/Server/ServerMain.cs +++ b/OpenSim/Server/ServerMain.cs | |||
@@ -60,7 +60,25 @@ namespace OpenSim.Server | |||
60 | } | 60 | } |
61 | 61 | ||
62 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); | 62 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); |
63 | string[] conns = connList.Split(new char[] {',', ' '}); | 63 | |
64 | IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; | ||
65 | if (servicesConfig != null) | ||
66 | { | ||
67 | List<string> servicesList = new List<string>(); | ||
68 | if (connList != String.Empty) | ||
69 | servicesList.Add(connList); | ||
70 | |||
71 | foreach (string k in servicesConfig.GetKeys()) | ||
72 | { | ||
73 | string v = servicesConfig.GetString(k); | ||
74 | if (v != String.Empty) | ||
75 | servicesList.Add(v); | ||
76 | } | ||
77 | |||
78 | connList = String.Join(",", servicesList.ToArray()); | ||
79 | } | ||
80 | |||
81 | string[] conns = connList.Split(new char[] {',', ' ', '\n', '\r', '\t'}); | ||
64 | 82 | ||
65 | // int i = 0; | 83 | // int i = 0; |
66 | foreach (string c in conns) | 84 | foreach (string c in conns) |
@@ -130,4 +148,4 @@ namespace OpenSim.Server | |||
130 | return 0; | 148 | return 0; |
131 | } | 149 | } |
132 | } | 150 | } |
133 | } \ No newline at end of file | 151 | } |