aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs4
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerConnector.cs4
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs208
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs112
5 files changed, 304 insertions, 26 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 6c2b3ed..656fcf5 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -258,6 +258,8 @@ namespace OpenSim.Server.Base
258 258
259 public static Dictionary<string, object> ParseXmlResponse(string data) 259 public static Dictionary<string, object> ParseXmlResponse(string data)
260 { 260 {
261 //m_log.DebugFormat("[XXX]: received xml string: {0}", data);
262
261 Dictionary<string, object> ret = new Dictionary<string, object>(); 263 Dictionary<string, object> ret = new Dictionary<string, object>();
262 264
263 XmlDocument doc = new XmlDocument(); 265 XmlDocument doc = new XmlDocument();
@@ -284,7 +286,7 @@ namespace OpenSim.Server.Base
284 286
285 foreach (XmlNode part in partL) 287 foreach (XmlNode part in partL)
286 { 288 {
287 XmlNode type = part.Attributes.GetNamedItem("Type"); 289 XmlNode type = part.Attributes.GetNamedItem("type");
288 if (type == null || type.Value != "List") 290 if (type == null || type.Value != "List")
289 { 291 {
290 ret[part.Name] = part.InnerText; 292 ret[part.Name] = part.InnerText;
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/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
index b80c479..ebdf489 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
@@ -45,11 +45,11 @@ namespace OpenSim.Server.Handlers.Grid
45 if (serverConfig == null) 45 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 46 throw new Exception("No section 'Server' in config file");
47 47
48 string gridService = serverConfig.GetString("GridServiceModule", 48 string gridService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 49 String.Empty);
50 50
51 if (gridService == String.Empty) 51 if (gridService == String.Empty)
52 throw new Exception("No AuthenticationService in config file"); 52 throw new Exception("No GridService in config file");
53 53
54 Object[] args = new Object[] { config }; 54 Object[] args = new Object[] { config };
55 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 55 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index 39c0584..711639f 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using System.Collections.Generic; 38using System.Collections.Generic;
39using OpenSim.Server.Base; 39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Framework; 42using OpenSim.Framework;
42using OpenSim.Framework.Servers.HttpServer; 43using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse; 44using OpenMetaverse;
@@ -62,7 +63,10 @@ namespace OpenSim.Server.Handlers.Grid
62 StreamReader sr = new StreamReader(requestData); 63 StreamReader sr = new StreamReader(requestData);
63 string body = sr.ReadToEnd(); 64 string body = sr.ReadToEnd();
64 sr.Close(); 65 sr.Close();
65 66 body = body.Trim();
67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
69
66 Dictionary<string, string> request = 70 Dictionary<string, string> request =
67 ServerUtils.ParseQueryString(body); 71 ServerUtils.ParseQueryString(body);
68 72
@@ -97,11 +101,11 @@ namespace OpenSim.Server.Handlers.Grid
97 case "get_region_range": 101 case "get_region_range":
98 return GetRegionRange(request); 102 return GetRegionRange(request);
99 103
100 default:
101 m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method);
102 return FailureResult();
103 } 104 }
104 105
106 m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
107 return FailureResult();
108
105 } 109 }
106 110
107 #region Method-specific handlers 111 #region Method-specific handlers
@@ -117,7 +121,7 @@ namespace OpenSim.Server.Handlers.Grid
117 Dictionary<string, object> rinfoData = new Dictionary<string, object>(); 121 Dictionary<string, object> rinfoData = new Dictionary<string, object>();
118 foreach (KeyValuePair<string, string> kvp in request) 122 foreach (KeyValuePair<string, string> kvp in request)
119 rinfoData[kvp.Key] = kvp.Value; 123 rinfoData[kvp.Key] = kvp.Value;
120 SimpleRegionInfo rinfo = new SimpleRegionInfo(rinfoData); 124 GridRegion rinfo = new GridRegion(rinfoData);
121 125
122 bool result = m_GridService.RegisterRegion(scopeID, rinfo); 126 bool result = m_GridService.RegisterRegion(scopeID, rinfo);
123 127
@@ -154,22 +158,29 @@ namespace OpenSim.Server.Handlers.Grid
154 158
155 UUID regionID = UUID.Zero; 159 UUID regionID = UUID.Zero;
156 if (request["REGIONID"] != null) 160 if (request["REGIONID"] != null)
157 UUID.TryParse(request["REGIONID"], out scopeID); 161 UUID.TryParse(request["REGIONID"], out regionID);
158 else 162 else
159 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); 163 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
160 164
161 List<SimpleRegionInfo> rinfos = m_GridService.GetNeighbours(scopeID, regionID); 165 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
166 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
162 167
163 Dictionary<string, object> result = new Dictionary<string, object>(); 168 Dictionary<string, object> result = new Dictionary<string, object>();
164 int i = 0; 169 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
165 foreach (SimpleRegionInfo rinfo in rinfos) 170 result["result"] = "null";
171 else
166 { 172 {
167 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); 173 int i = 0;
168 result["region" + i] = rinfoDict; 174 foreach (GridRegion rinfo in rinfos)
169 i++; 175 {
176 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
177 result["region" + i] = rinfoDict;
178 i++;
179 }
170 } 180 }
171 181
172 string xmlString = ServerUtils.BuildXmlResponse(result); 182 string xmlString = ServerUtils.BuildXmlResponse(result);
183 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
173 UTF8Encoding encoding = new UTF8Encoding(); 184 UTF8Encoding encoding = new UTF8Encoding();
174 return encoding.GetBytes(xmlString); 185 return encoding.GetBytes(xmlString);
175 186
@@ -177,32 +188,185 @@ namespace OpenSim.Server.Handlers.Grid
177 188
178 byte[] GetRegionByUUID(Dictionary<string, string> request) 189 byte[] GetRegionByUUID(Dictionary<string, string> request)
179 { 190 {
180 // TODO 191 UUID scopeID = UUID.Zero;
181 return new byte[0]; 192 if (request["SCOPEID"] != null)
193 UUID.TryParse(request["SCOPEID"], out scopeID);
194 else
195 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
196
197 UUID regionID = UUID.Zero;
198 if (request["REGIONID"] != null)
199 UUID.TryParse(request["REGIONID"], out regionID);
200 else
201 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
202
203 GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
204 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
205
206 Dictionary<string, object> result = new Dictionary<string, object>();
207 if (rinfo == null)
208 result["result"] = "null";
209 else
210 result["result"] = rinfo.ToKeyValuePairs();
211
212 string xmlString = ServerUtils.BuildXmlResponse(result);
213 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
214 UTF8Encoding encoding = new UTF8Encoding();
215 return encoding.GetBytes(xmlString);
182 } 216 }
183 217
184 byte[] GetRegionByPosition(Dictionary<string, string> request) 218 byte[] GetRegionByPosition(Dictionary<string, string> request)
185 { 219 {
186 // TODO 220 UUID scopeID = UUID.Zero;
187 return new byte[0]; 221 if (request["SCOPEID"] != null)
222 UUID.TryParse(request["SCOPEID"], out scopeID);
223 else
224 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
225
226 int x = 0, y = 0;
227 if (request["X"] != null)
228 Int32.TryParse(request["X"], out x);
229 else
230 m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
231 if (request["Y"] != null)
232 Int32.TryParse(request["Y"], out y);
233 else
234 m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
235
236 GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
237 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
238
239 Dictionary<string, object> result = new Dictionary<string, object>();
240 if (rinfo == null)
241 result["result"] = "null";
242 else
243 result["result"] = rinfo.ToKeyValuePairs();
244
245 string xmlString = ServerUtils.BuildXmlResponse(result);
246 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
247 UTF8Encoding encoding = new UTF8Encoding();
248 return encoding.GetBytes(xmlString);
188 } 249 }
189 250
190 byte[] GetRegionByName(Dictionary<string, string> request) 251 byte[] GetRegionByName(Dictionary<string, string> request)
191 { 252 {
192 // TODO 253 UUID scopeID = UUID.Zero;
193 return new byte[0]; 254 if (request["SCOPEID"] != null)
255 UUID.TryParse(request["SCOPEID"], out scopeID);
256 else
257 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
258
259 string regionName = string.Empty;
260 if (request["NAME"] != null)
261 regionName = request["NAME"];
262 else
263 m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
264
265 GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
266 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
267
268 Dictionary<string, object> result = new Dictionary<string, object>();
269 if (rinfo == null)
270 result["result"] = "null";
271 else
272 result["result"] = rinfo.ToKeyValuePairs();
273
274 string xmlString = ServerUtils.BuildXmlResponse(result);
275 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
276 UTF8Encoding encoding = new UTF8Encoding();
277 return encoding.GetBytes(xmlString);
194 } 278 }
195 279
196 byte[] GetRegionsByName(Dictionary<string, string> request) 280 byte[] GetRegionsByName(Dictionary<string, string> request)
197 { 281 {
198 // TODO 282 UUID scopeID = UUID.Zero;
199 return new byte[0]; 283 if (request["SCOPEID"] != null)
284 UUID.TryParse(request["SCOPEID"], out scopeID);
285 else
286 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
287
288 string regionName = string.Empty;
289 if (request["NAME"] != null)
290 regionName = request["NAME"];
291 else
292 m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
293
294 int max = 0;
295 if (request["MAX"] != null)
296 Int32.TryParse(request["MAX"], out max);
297 else
298 m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
299
300 List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
301 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
302
303 Dictionary<string, object> result = new Dictionary<string, object>();
304 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
305 result["result"] = "null";
306 else
307 {
308 int i = 0;
309 foreach (GridRegion rinfo in rinfos)
310 {
311 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
312 result["region" + i] = rinfoDict;
313 i++;
314 }
315 }
316
317 string xmlString = ServerUtils.BuildXmlResponse(result);
318 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
319 UTF8Encoding encoding = new UTF8Encoding();
320 return encoding.GetBytes(xmlString);
200 } 321 }
201 322
202 byte[] GetRegionRange(Dictionary<string, string> request) 323 byte[] GetRegionRange(Dictionary<string, string> request)
203 { 324 {
204 // TODO 325 //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
205 return new byte[0]; 326 UUID scopeID = UUID.Zero;
327 if (request.ContainsKey("SCOPEID"))
328 UUID.TryParse(request["SCOPEID"], out scopeID);
329 else
330 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
331
332 int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
333 if (request.ContainsKey("XMIN"))
334 Int32.TryParse(request["XMIN"], out xmin);
335 else
336 m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
337 if (request.ContainsKey("XMAX"))
338 Int32.TryParse(request["XMAX"], out xmax);
339 else
340 m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
341 if (request.ContainsKey("YMIN"))
342 Int32.TryParse(request["YMIN"], out ymin);
343 else
344 m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
345 if (request.ContainsKey("YMAX"))
346 Int32.TryParse(request["YMAX"], out ymax);
347 else
348 m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
349
350
351 List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
352
353 Dictionary<string, object> result = new Dictionary<string, object>();
354 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
355 result["result"] = "null";
356 else
357 {
358 int i = 0;
359 foreach (GridRegion rinfo in rinfos)
360 {
361 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
362 result["region" + i] = rinfoDict;
363 i++;
364 }
365 }
366 string xmlString = ServerUtils.BuildXmlResponse(result);
367 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
368 UTF8Encoding encoding = new UTF8Encoding();
369 return encoding.GetBytes(xmlString);
206 } 370 }
207 371
208 #endregion 372 #endregion
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
new file mode 100644
index 0000000..ad63485
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -0,0 +1,112 @@
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;
39
40using log4net;
41using Nwc.XmlRpc;
42
43namespace OpenSim.Server.Handlers.Grid
44{
45 public class HypergridServiceInConnector : ServiceConnector
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private List<SimpleRegionInfo> m_RegionsOnSim = new List<SimpleRegionInfo>();
52
53 public HypergridServiceInConnector(IConfigSource config, IHttpServer server) :
54 base(config, server)
55 {
56 server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false);
57 }
58
59 /// <summary>
60 /// Someone wants to link to us
61 /// </summary>
62 /// <param name="request"></param>
63 /// <returns></returns>
64 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
65 {
66 Hashtable requestData = (Hashtable)request.Params[0];
67 //string host = (string)requestData["host"];
68 //string portstr = (string)requestData["port"];
69 string name = (string)requestData["region_name"];
70
71 m_log.DebugFormat("[HGrid]: Hyperlink request");
72
73 SimpleRegionInfo regInfo = null;
74 foreach (SimpleRegionInfo r in m_RegionsOnSim)
75 {
76 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
77 {
78 regInfo = r;
79 break;
80 }
81 }
82
83 if (regInfo == null)
84 regInfo = m_RegionsOnSim[0]; // Send out the first region
85
86 Hashtable hash = new Hashtable();
87 hash["uuid"] = regInfo.RegionID.ToString();
88 hash["handle"] = regInfo.RegionHandle.ToString();
89 //m_log.Debug(">> Here " + regInfo.RegionHandle);
90 //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
91 hash["region_name"] = regInfo.RegionName;
92 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
93 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
94
95
96 XmlRpcResponse response = new XmlRpcResponse();
97 response.Value = hash;
98 return response;
99 }
100
101 public void AddRegion(SimpleRegionInfo rinfo)
102 {
103 m_RegionsOnSim.Add(rinfo);
104 }
105
106 public void RemoveRegion(SimpleRegionInfo rinfo)
107 {
108 if (m_RegionsOnSim.Contains(rinfo))
109 m_RegionsOnSim.Remove(rinfo);
110 }
111 }
112}