aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs28
-rw-r--r--OpenSim/Server/Base/ProtocolVersions.cs56
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs120
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs13
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs12
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs11
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Base/ServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs14
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerConnector.cs61
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs451
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs208
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs11
-rw-r--r--OpenSim/Server/Handlers/Land/LandServiceInConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs10
-rw-r--r--OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs2
-rw-r--r--OpenSim/Server/ServerMain.cs50
19 files changed, 1019 insertions, 42 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..488a9e6
--- /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}
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index 7c74e05..f7eb292 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -37,13 +37,17 @@ namespace OpenSim.Server.Handlers.Asset
37 public class AssetServiceConnector : ServiceConnector 37 public class AssetServiceConnector : ServiceConnector
38 { 38 {
39 private IAssetService m_AssetService; 39 private IAssetService m_AssetService;
40 private string m_ConfigName = "AssetService";
40 41
41 public AssetServiceConnector(IConfigSource config, IHttpServer server) : 42 public AssetServiceConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["AssetService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47
48 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 49 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 50 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 51
48 string assetService = serverConfig.GetString("LocalServiceModule", 52 string assetService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 53 String.Empty);
@@ -55,7 +59,6 @@ namespace OpenSim.Server.Handlers.Asset
55 m_AssetService = 59 m_AssetService =
56 ServerUtils.LoadPlugin<IAssetService>(assetService, args); 60 ServerUtils.LoadPlugin<IAssetService>(assetService, args);
57 61
58 //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no"));
59 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); 62 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService));
60 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); 63 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService));
61 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService)); 64 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService));
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
index 589dc3b..2abef0a 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
@@ -37,13 +37,17 @@ namespace OpenSim.Server.Handlers.Authentication
37 public class AuthenticationServiceConnector : ServiceConnector 37 public class AuthenticationServiceConnector : ServiceConnector
38 { 38 {
39 private IAuthenticationService m_AuthenticationService; 39 private IAuthenticationService m_AuthenticationService;
40 private string m_ConfigName = "AuthenticationService";
40 41
41 public AuthenticationServiceConnector(IConfigSource config, IHttpServer server) : 42 public AuthenticationServiceConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["AuthenticationService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47
48 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 49 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 50 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 51
48 string authenticationService = serverConfig.GetString("AuthenticationServiceModule", 52 string authenticationService = serverConfig.GetString("AuthenticationServiceModule",
49 String.Empty); 53 String.Empty);
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index 6cf7d56..490a13a 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -157,7 +157,7 @@ namespace OpenSim.Server.Handlers.Authentication
157 157
158 doc.AppendChild(xmlnode); 158 doc.AppendChild(xmlnode);
159 159
160 XmlElement rootElement = doc.CreateElement("", "Authentication", 160 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
161 ""); 161 "");
162 162
163 doc.AppendChild(rootElement); 163 doc.AppendChild(rootElement);
@@ -179,7 +179,7 @@ namespace OpenSim.Server.Handlers.Authentication
179 179
180 doc.AppendChild(xmlnode); 180 doc.AppendChild(xmlnode);
181 181
182 XmlElement rootElement = doc.CreateElement("", "Authentication", 182 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
183 ""); 183 "");
184 184
185 doc.AppendChild(rootElement); 185 doc.AppendChild(rootElement);
@@ -201,7 +201,7 @@ namespace OpenSim.Server.Handlers.Authentication
201 201
202 doc.AppendChild(xmlnode); 202 doc.AppendChild(xmlnode);
203 203
204 XmlElement rootElement = doc.CreateElement("", "Authentication", 204 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
205 ""); 205 "");
206 206
207 doc.AppendChild(rootElement); 207 doc.AppendChild(rootElement);
diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs
index 0d9f239..20fd0f7 100644
--- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs
+++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs
@@ -37,13 +37,16 @@ namespace OpenSim.Server.Handlers.Authorization
37 public class AuthorizationServerConnector : ServiceConnector 37 public class AuthorizationServerConnector : ServiceConnector
38 { 38 {
39 private IAuthorizationService m_AuthorizationService; 39 private IAuthorizationService m_AuthorizationService;
40 private string m_ConfigName = "AuthorizationService";
40 41
41 public AuthorizationServerConnector(IConfigSource config, IHttpServer server) : 42 public AuthorizationServerConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["AuthorizationService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 48 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 49 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 50
48 string authorizationService = serverConfig.GetString("LocalServiceModule", 51 string authorizationService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 52 String.Empty);
diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
index 69acd25..f987de4 100644
--- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Authorization
44{ 44{
45 public class AuthorizationServerPostHandler : BaseStreamHandler 45 public class AuthorizationServerPostHandler : BaseStreamHandler
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private IAuthorizationService m_AuthorizationService; 49 private IAuthorizationService m_AuthorizationService;
50 50
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs
index 62fe773..71876da 100644
--- a/OpenSim/Server/Handlers/Base/ServerConnector.cs
+++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Server.Handlers.Base
39 39
40 public class ServiceConnector : IServiceConnector 40 public class ServiceConnector : IServiceConnector
41 { 41 {
42 public ServiceConnector(IConfigSource config, IHttpServer server) 42 public ServiceConnector(IConfigSource config, IHttpServer server, string configName)
43 { 43 {
44 } 44 }
45 } 45 }
diff --git a/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs b/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
index a4ab0d3..07bafc8 100644
--- a/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
+++ b/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
@@ -37,19 +37,23 @@ namespace OpenSim.Server.Handlers.Freeswitch
37 public class FreeswitchServerConnector : ServiceConnector 37 public class FreeswitchServerConnector : ServiceConnector
38 { 38 {
39 private IFreeswitchService m_FreeswitchService; 39 private IFreeswitchService m_FreeswitchService;
40 private string m_ConfigName = "FreeswitchService";
40 41
41 public FreeswitchServerConnector(IConfigSource config, IHttpServer server) : 42 public FreeswitchServerConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["FreeswitchService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47
48 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 49 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 50 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 51
48 string freeswitchService = serverConfig.GetString("LocalServiceModule", 52 string freeswitchService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 53 String.Empty);
50 54
51 if (freeswitchService == String.Empty) 55 if (freeswitchService == String.Empty)
52 throw new Exception("No FreeswitchService in config file"); 56 throw new Exception("No LocalServiceModule in config file");
53 57
54 Object[] args = new Object[] { config }; 58 Object[] args = new Object[] { config };
55 m_FreeswitchService = 59 m_FreeswitchService =
diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
new file mode 100644
index 0000000..14daf12
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
@@ -0,0 +1,61 @@
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
28using System;
29using Nini.Config;
30using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base;
34
35namespace OpenSim.Server.Handlers.Grid
36{
37 public class GridServiceConnector : ServiceConnector
38 {
39 private IGridService m_GridService;
40 private string m_ConfigName = "GridService";
41
42 public GridServiceConnector(IConfigSource config, IHttpServer server, string configName) :
43 base(config, server, configName)
44 {
45 IConfig serverConfig = config.Configs[m_ConfigName];
46 if (serverConfig == null)
47 throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
48
49 string gridService = serverConfig.GetString("LocalServiceModule",
50 String.Empty);
51
52 if (gridService == String.Empty)
53 throw new Exception("No LocalServiceModule in config file");
54
55 Object[] args = new Object[] { config };
56 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
57
58 server.AddStreamHandler(new GridServerPostHandler(m_GridService));
59 }
60 }
61}
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
new file mode 100644
index 0000000..e22328d
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -0,0 +1,451 @@
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
28using Nini.Config;
29using log4net;
30using System;
31using System.Reflection;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Xml;
37using System.Xml.Serialization;
38using System.Collections.Generic;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42using OpenSim.Framework;
43using OpenSim.Framework.Servers.HttpServer;
44using OpenMetaverse;
45
46namespace OpenSim.Server.Handlers.Grid
47{
48 public class GridServerPostHandler : BaseStreamHandler
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private IGridService m_GridService;
53
54 public GridServerPostHandler(IGridService service) :
55 base("POST", "/grid")
56 {
57 m_GridService = service;
58 }
59
60 public override byte[] Handle(string path, Stream requestData,
61 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
62 {
63 StreamReader sr = new StreamReader(requestData);
64 string body = sr.ReadToEnd();
65 sr.Close();
66 body = body.Trim();
67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
69
70 Dictionary<string, string> request =
71 ServerUtils.ParseQueryString(body);
72
73 if (!request.ContainsKey("METHOD"))
74 return FailureResult();
75
76 string method = request["METHOD"];
77
78 switch (method)
79 {
80 case "register":
81 return Register(request);
82
83 case "deregister":
84 return Deregister(request);
85
86 case "get_neighbours":
87 return GetNeighbours(request);
88
89 case "get_region_by_uuid":
90 return GetRegionByUUID(request);
91
92 case "get_region_by_position":
93 return GetRegionByPosition(request);
94
95 case "get_region_by_name":
96 return GetRegionByName(request);
97
98 case "get_regions_by_name":
99 return GetRegionsByName(request);
100
101 case "get_region_range":
102 return GetRegionRange(request);
103
104 }
105
106 m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
107 return FailureResult();
108
109 }
110
111 #region Method-specific handlers
112
113 byte[] Register(Dictionary<string, string> request)
114 {
115 UUID scopeID = UUID.Zero;
116 if (request["SCOPEID"] != null)
117 UUID.TryParse(request["SCOPEID"], out scopeID);
118 else
119 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
120
121 int versionNumberMin = 0, versionNumberMax = 0;
122 if (request.ContainsKey("VERSIONMIN"))
123 Int32.TryParse(request["VERSIONMIN"], out versionNumberMin);
124 else
125 m_log.WarnFormat("[GRID HANDLER]: no minimum protocol version in request to register region");
126
127 if (request.ContainsKey("VERSIONMAX"))
128 Int32.TryParse(request["VERSIONMAX"], out versionNumberMax);
129 else
130 m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region");
131
132 // Check the protocol version
133 if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax))
134 {
135 // Can't do, there is no overlap in the acceptable ranges
136 return FailureResult();
137 }
138
139 Dictionary<string, object> rinfoData = new Dictionary<string, object>();
140 foreach (KeyValuePair<string, string> kvp in request)
141 rinfoData[kvp.Key] = kvp.Value;
142 GridRegion rinfo = new GridRegion(rinfoData);
143
144 bool result = m_GridService.RegisterRegion(scopeID, rinfo);
145
146 if (result)
147 return SuccessResult();
148 else
149 return FailureResult();
150 }
151
152 byte[] Deregister(Dictionary<string, string> request)
153 {
154 UUID regionID = UUID.Zero;
155 if (request["REGIONID"] != null)
156 UUID.TryParse(request["REGIONID"], out regionID);
157 else
158 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region");
159
160 bool result = m_GridService.DeregisterRegion(regionID);
161
162 if (result)
163 return SuccessResult();
164 else
165 return FailureResult();
166
167 }
168
169 byte[] GetNeighbours(Dictionary<string, string> request)
170 {
171 UUID scopeID = UUID.Zero;
172 if (request["SCOPEID"] != null)
173 UUID.TryParse(request["SCOPEID"], out scopeID);
174 else
175 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
176
177 UUID regionID = UUID.Zero;
178 if (request["REGIONID"] != null)
179 UUID.TryParse(request["REGIONID"], out regionID);
180 else
181 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
182
183 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
184 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
185
186 Dictionary<string, object> result = new Dictionary<string, object>();
187 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
188 result["result"] = "null";
189 else
190 {
191 int i = 0;
192 foreach (GridRegion rinfo in rinfos)
193 {
194 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
195 result["region" + i] = rinfoDict;
196 i++;
197 }
198 }
199
200 string xmlString = ServerUtils.BuildXmlResponse(result);
201 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
202 UTF8Encoding encoding = new UTF8Encoding();
203 return encoding.GetBytes(xmlString);
204
205 }
206
207 byte[] GetRegionByUUID(Dictionary<string, string> request)
208 {
209 UUID scopeID = UUID.Zero;
210 if (request["SCOPEID"] != null)
211 UUID.TryParse(request["SCOPEID"], out scopeID);
212 else
213 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
214
215 UUID regionID = UUID.Zero;
216 if (request["REGIONID"] != null)
217 UUID.TryParse(request["REGIONID"], out regionID);
218 else
219 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
220
221 GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
222 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
223
224 Dictionary<string, object> result = new Dictionary<string, object>();
225 if (rinfo == null)
226 result["result"] = "null";
227 else
228 result["result"] = rinfo.ToKeyValuePairs();
229
230 string xmlString = ServerUtils.BuildXmlResponse(result);
231 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
232 UTF8Encoding encoding = new UTF8Encoding();
233 return encoding.GetBytes(xmlString);
234 }
235
236 byte[] GetRegionByPosition(Dictionary<string, string> request)
237 {
238 UUID scopeID = UUID.Zero;
239 if (request["SCOPEID"] != null)
240 UUID.TryParse(request["SCOPEID"], out scopeID);
241 else
242 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
243
244 int x = 0, y = 0;
245 if (request["X"] != null)
246 Int32.TryParse(request["X"], out x);
247 else
248 m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
249 if (request["Y"] != null)
250 Int32.TryParse(request["Y"], out y);
251 else
252 m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
253
254 GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
255 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
256
257 Dictionary<string, object> result = new Dictionary<string, object>();
258 if (rinfo == null)
259 result["result"] = "null";
260 else
261 result["result"] = rinfo.ToKeyValuePairs();
262
263 string xmlString = ServerUtils.BuildXmlResponse(result);
264 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
265 UTF8Encoding encoding = new UTF8Encoding();
266 return encoding.GetBytes(xmlString);
267 }
268
269 byte[] GetRegionByName(Dictionary<string, string> request)
270 {
271 UUID scopeID = UUID.Zero;
272 if (request["SCOPEID"] != null)
273 UUID.TryParse(request["SCOPEID"], out scopeID);
274 else
275 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
276
277 string regionName = string.Empty;
278 if (request["NAME"] != null)
279 regionName = request["NAME"];
280 else
281 m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
282
283 GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
284 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
285
286 Dictionary<string, object> result = new Dictionary<string, object>();
287 if (rinfo == null)
288 result["result"] = "null";
289 else
290 result["result"] = rinfo.ToKeyValuePairs();
291
292 string xmlString = ServerUtils.BuildXmlResponse(result);
293 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
294 UTF8Encoding encoding = new UTF8Encoding();
295 return encoding.GetBytes(xmlString);
296 }
297
298 byte[] GetRegionsByName(Dictionary<string, string> request)
299 {
300 UUID scopeID = UUID.Zero;
301 if (request["SCOPEID"] != null)
302 UUID.TryParse(request["SCOPEID"], out scopeID);
303 else
304 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
305
306 string regionName = string.Empty;
307 if (request["NAME"] != null)
308 regionName = request["NAME"];
309 else
310 m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
311
312 int max = 0;
313 if (request["MAX"] != null)
314 Int32.TryParse(request["MAX"], out max);
315 else
316 m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
317
318 List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
319 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
320
321 Dictionary<string, object> result = new Dictionary<string, object>();
322 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
323 result["result"] = "null";
324 else
325 {
326 int i = 0;
327 foreach (GridRegion rinfo in rinfos)
328 {
329 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
330 result["region" + i] = rinfoDict;
331 i++;
332 }
333 }
334
335 string xmlString = ServerUtils.BuildXmlResponse(result);
336 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
337 UTF8Encoding encoding = new UTF8Encoding();
338 return encoding.GetBytes(xmlString);
339 }
340
341 byte[] GetRegionRange(Dictionary<string, string> request)
342 {
343 //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
344 UUID scopeID = UUID.Zero;
345 if (request.ContainsKey("SCOPEID"))
346 UUID.TryParse(request["SCOPEID"], out scopeID);
347 else
348 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
349
350 int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
351 if (request.ContainsKey("XMIN"))
352 Int32.TryParse(request["XMIN"], out xmin);
353 else
354 m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
355 if (request.ContainsKey("XMAX"))
356 Int32.TryParse(request["XMAX"], out xmax);
357 else
358 m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
359 if (request.ContainsKey("YMIN"))
360 Int32.TryParse(request["YMIN"], out ymin);
361 else
362 m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
363 if (request.ContainsKey("YMAX"))
364 Int32.TryParse(request["YMAX"], out ymax);
365 else
366 m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
367
368
369 List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
370
371 Dictionary<string, object> result = new Dictionary<string, object>();
372 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
373 result["result"] = "null";
374 else
375 {
376 int i = 0;
377 foreach (GridRegion rinfo in rinfos)
378 {
379 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
380 result["region" + i] = rinfoDict;
381 i++;
382 }
383 }
384 string xmlString = ServerUtils.BuildXmlResponse(result);
385 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
386 UTF8Encoding encoding = new UTF8Encoding();
387 return encoding.GetBytes(xmlString);
388 }
389
390 #endregion
391
392 #region Misc
393
394 private byte[] SuccessResult()
395 {
396 XmlDocument doc = new XmlDocument();
397
398 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
399 "", "");
400
401 doc.AppendChild(xmlnode);
402
403 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
404 "");
405
406 doc.AppendChild(rootElement);
407
408 XmlElement result = doc.CreateElement("", "Result", "");
409 result.AppendChild(doc.CreateTextNode("Success"));
410
411 rootElement.AppendChild(result);
412
413 return DocToBytes(doc);
414 }
415
416 private byte[] FailureResult()
417 {
418 XmlDocument doc = new XmlDocument();
419
420 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
421 "", "");
422
423 doc.AppendChild(xmlnode);
424
425 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
426 "");
427
428 doc.AppendChild(rootElement);
429
430 XmlElement result = doc.CreateElement("", "Result", "");
431 result.AppendChild(doc.CreateTextNode("Failure"));
432
433 rootElement.AppendChild(result);
434
435 return DocToBytes(doc);
436 }
437
438 private byte[] DocToBytes(XmlDocument doc)
439 {
440 MemoryStream ms = new MemoryStream();
441 XmlTextWriter xw = new XmlTextWriter(ms, null);
442 xw.Formatting = Formatting.Indented;
443 doc.WriteTo(xw);
444 xw.Flush();
445
446 return ms.ToArray();
447 }
448
449 #endregion
450 }
451}
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
new file mode 100644
index 0000000..115ac29
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -0,0 +1,208 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40
41using OpenMetaverse;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Server.Handlers.Grid
46{
47 public class HypergridServiceInConnector : ServiceConnector
48 {
49 private static readonly ILog m_log =
50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType);
52
53 private List<GridRegion> m_RegionsOnSim = new List<GridRegion>();
54 private IHyperlinkService m_HyperlinkService;
55
56 public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) :
57 base(config, server, String.Empty)
58 {
59 m_HyperlinkService = hyperService;
60 server.AddXmlRPCHandler("link_region", LinkRegionRequest, false);
61 server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false);
62 }
63
64 public void AddRegion(GridRegion rinfo)
65 {
66 m_RegionsOnSim.Add(rinfo);
67 }
68
69 public void RemoveRegion(GridRegion rinfo)
70 {
71 if (m_RegionsOnSim.Contains(rinfo))
72 m_RegionsOnSim.Remove(rinfo);
73 }
74
75 /// <summary>
76 /// Someone wants to link to us
77 /// </summary>
78 /// <param name="request"></param>
79 /// <returns></returns>
80 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
81 {
82 Hashtable requestData = (Hashtable)request.Params[0];
83 //string host = (string)requestData["host"];
84 //string portstr = (string)requestData["port"];
85 string name = (string)requestData["region_name"];
86
87 m_log.DebugFormat("[HGrid]: Hyperlink request");
88
89 GridRegion regInfo = null;
90 foreach (GridRegion r in m_RegionsOnSim)
91 {
92 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
93 {
94 regInfo = r;
95 break;
96 }
97 }
98
99 if (regInfo == null)
100 regInfo = m_RegionsOnSim[0]; // Send out the first region
101
102 Hashtable hash = new Hashtable();
103 hash["uuid"] = regInfo.RegionID.ToString();
104 m_log.Debug(">> Here " + regInfo.RegionID);
105 hash["handle"] = regInfo.RegionHandle.ToString();
106 hash["region_image"] = regInfo.TerrainImage.ToString();
107 hash["region_name"] = regInfo.RegionName;
108 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
109 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
110
111
112 XmlRpcResponse response = new XmlRpcResponse();
113 response.Value = hash;
114 return response;
115 }
116
117 /// <summary>
118 /// Received from other HGrid nodes when a user wants to teleport here. This call allows
119 /// the region to prepare for direct communication from the client. Sends back an empty
120 /// xmlrpc response on completion.
121 /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of
122 /// registering the user in the local user cache.
123 /// </summary>
124 /// <param name="request"></param>
125 /// <returns></returns>
126 public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient)
127 {
128 Hashtable requestData = (Hashtable)request.Params[0];
129 ForeignUserProfileData userData = new ForeignUserProfileData();
130
131 userData.FirstName = (string)requestData["firstname"];
132 userData.SurName = (string)requestData["lastname"];
133 userData.ID = new UUID((string)requestData["agent_id"]);
134 UUID sessionID = new UUID((string)requestData["session_id"]);
135 userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]),
136 (float)Convert.ToDecimal((string)requestData["startpos_y"]),
137 (float)Convert.ToDecimal((string)requestData["startpos_z"]));
138
139 userData.UserServerURI = (string)requestData["userserver_id"];
140 userData.UserAssetURI = (string)requestData["assetserver_id"];
141 userData.UserInventoryURI = (string)requestData["inventoryserver_id"];
142
143 m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}",
144 userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID);
145
146 ulong userRegionHandle = 0;
147 int userhomeinternalport = 0;
148 if (requestData.ContainsKey("region_uuid"))
149 {
150 UUID uuid = UUID.Zero;
151 UUID.TryParse((string)requestData["region_uuid"], out uuid);
152 userData.HomeRegionID = uuid;
153 userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
154 userData.UserHomeAddress = (string)requestData["home_address"];
155 userData.UserHomePort = (string)requestData["home_port"];
156 userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]);
157
158 m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress +
159 "; home_port: " + userData.UserHomePort);
160 }
161 else
162 m_log.WarnFormat("[HGrid]: User has no home region information");
163
164 XmlRpcResponse resp = new XmlRpcResponse();
165
166 // Let's check if someone is trying to get in with a stolen local identity.
167 // The need for this test is a consequence of not having truly global names :-/
168 bool comingHome = false;
169 if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false)
170 {
171 m_log.WarnFormat("[HGrid]: Access denied to foreign user.");
172 Hashtable respdata = new Hashtable();
173 respdata["success"] = "FALSE";
174 respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled.";
175 resp.Value = respdata;
176 return resp;
177 }
178
179 // Finally, everything looks ok
180 //m_log.Debug("XXX---- EVERYTHING OK ---XXX");
181
182 if (!comingHome)
183 {
184 // We don't do this if the user is coming to the home grid
185 GridRegion home = new GridRegion();
186 home.RegionID = userData.HomeRegionID;
187 home.ExternalHostName = userData.UserHomeAddress;
188 home.HttpPort = Convert.ToUInt32(userData.UserHomePort);
189 uint x = 0, y = 0;
190 Utils.LongToUInts(userRegionHandle, out x, out y);
191 home.RegionLocX = (int)x;
192 home.RegionLocY = (int)y;
193 home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport);
194
195 m_HyperlinkService.AcceptUser(userData, home);
196 }
197 // else the user is coming to a non-home region of the home grid
198 // We simply drop this user information altogether
199
200 Hashtable respdata2 = new Hashtable();
201 respdata2["success"] = "TRUE";
202 resp.Value = respdata2;
203
204 return resp;
205 }
206
207 }
208}
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
index 998b322..ca45263 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
@@ -54,19 +54,20 @@ namespace OpenSim.Server.Handlers.Inventory
54 //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); 54 //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME);
55 55
56 private string m_userserver_url; 56 private string m_userserver_url;
57 private string m_ConfigName = "InventoryService";
57 58
58 public InventoryServiceInConnector(IConfigSource config, IHttpServer server) : 59 public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) :
59 base(config, server) 60 base(config, server, configName)
60 { 61 {
61 IConfig serverConfig = config.Configs["InventoryService"]; 62 IConfig serverConfig = config.Configs[m_ConfigName];
62 if (serverConfig == null) 63 if (serverConfig == null)
63 throw new Exception("No section 'InventoryService' in config file"); 64 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
64 65
65 string inventoryService = serverConfig.GetString("LocalServiceModule", 66 string inventoryService = serverConfig.GetString("LocalServiceModule",
66 String.Empty); 67 String.Empty);
67 68
68 if (inventoryService == String.Empty) 69 if (inventoryService == String.Empty)
69 throw new Exception("No InventoryService in config file"); 70 throw new Exception("No LocalServiceModule in config file");
70 71
71 Object[] args = new Object[] { config }; 72 Object[] args = new Object[] { config };
72 m_InventoryService = 73 m_InventoryService =
diff --git a/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs b/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
index 10e3b47..d368bd3 100644
--- a/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Land
46 // TODO : private IAuthenticationService m_AuthenticationService; 46 // TODO : private IAuthenticationService m_AuthenticationService;
47 47
48 public LandServiceInConnector(IConfigSource source, IHttpServer server, ILandService service, IScene scene) : 48 public LandServiceInConnector(IConfigSource source, IHttpServer server, ILandService service, IScene scene) :
49 base(source, server) 49 base(source, server, String.Empty)
50 { 50 {
51 m_LandService = service; 51 m_LandService = service;
52 if (m_LandService == null) 52 if (m_LandService == null)
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
index c0933a8..d6ef22e 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
@@ -36,6 +36,7 @@ using OpenSim.Server.Handlers.Base;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40using OpenMetaverse; 41using OpenMetaverse;
41using OpenMetaverse.StructuredData; 42using OpenMetaverse.StructuredData;
@@ -148,11 +149,14 @@ namespace OpenSim.Server.Handlers.Neighbour
148 } 149 }
149 150
150 // Finally! 151 // Finally!
151 bool success = m_NeighbourService.HelloNeighbour(regionhandle, aRegion); 152 GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);
152 153
153 OSDMap resp = new OSDMap(1); 154 OSDMap resp = new OSDMap(1);
154 155
155 resp["success"] = OSD.FromBoolean(success); 156 if (thisRegion != null)
157 resp["success"] = OSD.FromBoolean(true);
158 else
159 resp["success"] = OSD.FromBoolean(false);
156 160
157 httpResponse.StatusCode = (int)HttpStatusCode.OK; 161 httpResponse.StatusCode = (int)HttpStatusCode.OK;
158 162
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs
index b3a91cf..ac2e75f 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Neighbour
46 private IAuthenticationService m_AuthenticationService = null; 46 private IAuthenticationService m_AuthenticationService = null;
47 47
48 public NeighbourServiceInConnector(IConfigSource source, IHttpServer server, INeighbourService nService, IScene scene) : 48 public NeighbourServiceInConnector(IConfigSource source, IHttpServer server, INeighbourService nService, IScene scene) :
49 base(source, server) 49 base(source, server, String.Empty)
50 { 50 {
51 51
52 m_NeighbourService = nService; 52 m_NeighbourService = nService;
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
index 0bb4713..fe93fa5 100644
--- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Server.Handlers.Simulation
41 private IAuthenticationService m_AuthenticationService; 41 private IAuthenticationService m_AuthenticationService;
42 42
43 public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : 43 public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
44 base(config, server) 44 base(config, server, String.Empty)
45 { 45 {
46 IConfig serverConfig = config.Configs["SimulationService"]; 46 IConfig serverConfig = config.Configs["SimulationService"];
47 if (serverConfig == null) 47 if (serverConfig == null)
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index 77dfebb..a7b33c9 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -30,6 +30,7 @@ using log4net;
30using System.Reflection; 30using System.Reflection;
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Base; 34using OpenSim.Server.Base;
34using OpenSim.Server.Handlers.Base; 35using OpenSim.Server.Handlers.Base;
35 36
@@ -60,22 +61,59 @@ namespace OpenSim.Server
60 string connList = serverConfig.GetString("ServiceConnectors", String.Empty); 61 string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
61 string[] conns = connList.Split(new char[] {',', ' '}); 62 string[] conns = connList.Split(new char[] {',', ' '});
62 63
63 foreach (string conn in conns) 64 int i = 0;
65 foreach (string c in conns)
64 { 66 {
65 if (conn == String.Empty) 67 if (c == String.Empty)
66 continue; 68 continue;
67 69
70 string configName = String.Empty;
71 string conn = c;
72 uint port = 0;
73
74 string[] split1 = conn.Split(new char[] {'/'});
75 if (split1.Length > 1)
76 {
77 conn = split1[1];
78
79 string[] split2 = split1[0].Split(new char[] {'@'});
80 if (split2.Length > 1)
81 {
82 configName = split2[0];
83 port = Convert.ToUInt32(split2[1]);
84 }
85 else
86 {
87 port = Convert.ToUInt32(split1[0]);
88 }
89 }
68 string[] parts = conn.Split(new char[] {':'}); 90 string[] parts = conn.Split(new char[] {':'});
69 string friendlyName = parts[0]; 91 string friendlyName = parts[0];
70 if (parts.Length > 1) 92 if (parts.Length > 1)
71 friendlyName = parts[1]; 93 friendlyName = parts[1];
72 94
73 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); 95 IHttpServer server = m_Server.HttpServer;
96 if (port != 0)
97 server = m_Server.GetHttpServer(port);
74 98
75 Object[] modargs = new Object[] { m_Server.Config, m_Server.HttpServer }; 99 if (port != m_Server.DefaultPort)
76 IServiceConnector connector = 100 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port);
77 ServerUtils.LoadPlugin<IServiceConnector>(conn, 101 else
102 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName);
103
104 IServiceConnector connector = null;
105
106 Object[] modargs = new Object[] { m_Server.Config, server,
107 configName };
108 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn,
78 modargs); 109 modargs);
110 if (connector == null)
111 {
112 modargs = new Object[] { m_Server.Config, server };
113 connector =
114 ServerUtils.LoadPlugin<IServiceConnector>(conn,
115 modargs);
116 }
79 117
80 if (connector != null) 118 if (connector != null)
81 { 119 {