aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Base')
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs28
-rw-r--r--OpenSim/Server/Base/ProtocolVersions.cs56
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs120
3 files changed, 202 insertions, 2 deletions
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index 791e1ef..ed0210f 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Threading; 30using System.Threading;
30using System.Reflection; 31using System.Reflection;
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -40,17 +41,40 @@ namespace OpenSim.Server.Base
40 { 41 {
41 // Logger 42 // Logger
42 // 43 //
43 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 // The http server instance 46 // The http server instance
46 // 47 //
47 protected BaseHttpServer m_HttpServer = null; 48 protected BaseHttpServer m_HttpServer = null;
49 protected uint m_Port = 0;
50 protected Dictionary<uint, BaseHttpServer> m_Servers =
51 new Dictionary<uint, BaseHttpServer>();
48 52
49 public IHttpServer HttpServer 53 public IHttpServer HttpServer
50 { 54 {
51 get { return m_HttpServer; } 55 get { return m_HttpServer; }
52 } 56 }
53 57
58 public uint DefaultPort
59 {
60 get { return m_Port; }
61 }
62
63 public IHttpServer GetHttpServer(uint port)
64 {
65 m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
66 if (port == m_Port)
67 return HttpServer;
68
69 if (m_Servers.ContainsKey(port))
70 return m_Servers[port];
71
72 m_Servers[port] = new BaseHttpServer(port);
73 m_Servers[port].Start();
74
75 return m_Servers[port];
76 }
77
54 // Handle all the automagical stuff 78 // Handle all the automagical stuff
55 // 79 //
56 public HttpServerBase(string prompt, string[] args) : base(prompt, args) 80 public HttpServerBase(string prompt, string[] args) : base(prompt, args)
@@ -74,6 +98,8 @@ namespace OpenSim.Server.Base
74 Thread.CurrentThread.Abort(); 98 Thread.CurrentThread.Abort();
75 } 99 }
76 100
101 m_Port = port;
102
77 m_HttpServer = new BaseHttpServer(port); 103 m_HttpServer = new BaseHttpServer(port);
78 104
79 MainServer.Instance = m_HttpServer; 105 MainServer.Instance = m_HttpServer;
diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs
new file mode 100644
index 0000000..8db5bb6
--- /dev/null
+++ b/OpenSim/Server/Base/ProtocolVersions.cs
@@ -0,0 +1,56 @@
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
28namespace OpenSim.Server.Base
29{
30 public class ProtocolVersions
31 {
32 /// <value>
33 /// This is the external protocol versions. It is separate from the OpenSimulator project version.
34 ///
35 /// These version numbers should be increased by 1 every time a code
36 /// change in the Service.Connectors and Server.Handlers, espectively,
37 /// makes the previous OpenSimulator revision incompatible
38 /// with the new revision.
39 ///
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.
42 ///
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.
45 ///
46 /// </value>
47
48 // The range of acceptable servers for client-side connectors
49 public readonly static int ClientProtocolVersionMin = 0;
50 public readonly static int ClientProtocolVersionMax = 0;
51
52 // The range of acceptable clients in server-side handlers
53 public readonly static int ServerProtocolVersionMin = 0;
54 public readonly static int ServerProtocolVersionMax = 0;
55 }
56}
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 0a36bbe..9beadd8 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -141,7 +141,9 @@ namespace OpenSim.Server.Base
141 } 141 }
142 catch (Exception e) 142 catch (Exception e)
143 { 143 {
144 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); 144 if (!(e is System.MissingMethodException))
145 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException);
146 return null;
145 } 147 }
146 148
147 return plug; 149 return plug;
@@ -183,5 +185,121 @@ namespace OpenSim.Server.Base
183 185
184 return result; 186 return result;
185 } 187 }
188
189 public static string BuildQueryString(Dictionary<string, string> data)
190 {
191 string qstring = String.Empty;
192
193 foreach (KeyValuePair<string, string> kvp in data)
194 {
195 string part;
196 if (kvp.Value != String.Empty)
197 {
198 part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
199 "=" + System.Web.HttpUtility.UrlEncode(kvp.Value);
200 }
201 else
202 {
203 part = System.Web.HttpUtility.UrlEncode(kvp.Key);
204 }
205
206 if (qstring != String.Empty)
207 qstring += "&";
208
209 qstring += part;
210 }
211
212 return qstring;
213 }
214
215 public static string BuildXmlResponse(Dictionary<string, object> data)
216 {
217 XmlDocument doc = new XmlDocument();
218
219 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
220 "", "");
221
222 doc.AppendChild(xmlnode);
223
224 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
225 "");
226
227 doc.AppendChild(rootElement);
228
229 BuildXmlData(rootElement, data);
230
231 return doc.InnerXml;
232 }
233
234 private static void BuildXmlData(XmlElement parent, Dictionary<string, object> data)
235 {
236 foreach (KeyValuePair<string, object> kvp in data)
237 {
238 XmlElement elem = parent.OwnerDocument.CreateElement("",
239 kvp.Key, "");
240
241 if (kvp.Value is Dictionary<string, object>)
242 {
243 XmlAttribute type = parent.OwnerDocument.CreateAttribute("",
244 "type", "");
245 type.Value = "List";
246
247 elem.Attributes.Append(type);
248
249 BuildXmlData(elem, (Dictionary<string, object>)kvp.Value);
250 }
251 else
252 {
253 elem.AppendChild(parent.OwnerDocument.CreateTextNode(
254 kvp.Value.ToString()));
255 }
256
257 parent.AppendChild(elem);
258 }
259 }
260
261 public static Dictionary<string, object> ParseXmlResponse(string data)
262 {
263 //m_log.DebugFormat("[XXX]: received xml string: {0}", data);
264
265 Dictionary<string, object> ret = new Dictionary<string, object>();
266
267 XmlDocument doc = new XmlDocument();
268
269 doc.LoadXml(data);
270
271 XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
272
273 if (rootL.Count != 1)
274 return ret;
275
276 XmlNode rootNode = rootL[0];
277
278 ret = ParseElement(rootNode);
279
280 return ret;
281 }
282
283 private static Dictionary<string, object> ParseElement(XmlNode element)
284 {
285 Dictionary<string, object> ret = new Dictionary<string, object>();
286
287 XmlNodeList partL = element.ChildNodes;
288
289 foreach (XmlNode part in partL)
290 {
291 XmlNode type = part.Attributes.GetNamedItem("type");
292 if (type == null || type.Value != "List")
293 {
294 ret[part.Name] = part.InnerText;
295 }
296 else
297 {
298 ret[part.Name] = ParseElement(part);
299 }
300 }
301
302 return ret;
303 }
186 } 304 }
187} 305}