diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Grid')
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 21 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridServerConnector.cs | 5 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 99 |
3 files changed, 97 insertions, 28 deletions
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 965a54e..346af32 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -170,14 +170,6 @@ namespace OpenSim.Server.Handlers.Grid | |||
170 | public string JsonGetGridInfoMethod(string request, string path, string param, | 170 | public string JsonGetGridInfoMethod(string request, string path, string param, |
171 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 171 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
172 | { | 172 | { |
173 | string HomeURI = String.Empty; | ||
174 | IConfig cfg = m_Config.Configs["LoginService"]; | ||
175 | |||
176 | if (null != cfg) | ||
177 | { | ||
178 | HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); | ||
179 | } | ||
180 | |||
181 | OSDMap map = new OSDMap(); | 173 | OSDMap map = new OSDMap(); |
182 | 174 | ||
183 | foreach (string k in _info.Keys) | 175 | foreach (string k in _info.Keys) |
@@ -185,9 +177,20 @@ namespace OpenSim.Server.Handlers.Grid | |||
185 | map[k] = OSD.FromString(_info[k].ToString()); | 177 | map[k] = OSD.FromString(_info[k].ToString()); |
186 | } | 178 | } |
187 | 179 | ||
180 | string HomeURI = Util.GetConfigVarFromSections<string>(m_Config, "HomeURI", | ||
181 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
182 | |||
188 | if (!String.IsNullOrEmpty(HomeURI)) | 183 | if (!String.IsNullOrEmpty(HomeURI)) |
184 | map["home"] = OSD.FromString(HomeURI); | ||
185 | else // Legacy. Remove soon! | ||
189 | { | 186 | { |
190 | map["home"] = OSD.FromString(HomeURI); | 187 | IConfig cfg = m_Config.Configs["LoginService"]; |
188 | |||
189 | if (null != cfg) | ||
190 | HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); | ||
191 | |||
192 | if (!String.IsNullOrEmpty(HomeURI)) | ||
193 | map["home"] = OSD.FromString(HomeURI); | ||
191 | } | 194 | } |
192 | 195 | ||
193 | return OSDParser.SerializeJsonString(map).ToString(); | 196 | return OSDParser.SerializeJsonString(map).ToString(); |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs index 14daf12..6eb6a79 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 30 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 31 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.ServiceAuth; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 34 | using OpenSim.Server.Handlers.Base; |
34 | 35 | ||
@@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Grid | |||
55 | Object[] args = new Object[] { config }; | 56 | Object[] args = new Object[] { config }; |
56 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | 57 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); |
57 | 58 | ||
58 | server.AddStreamHandler(new GridServerPostHandler(m_GridService)); | 59 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
60 | |||
61 | server.AddStreamHandler(new GridServerPostHandler(m_GridService, auth)); | ||
59 | } | 62 | } |
60 | } | 63 | } |
61 | } | 64 | } |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index ef5f33e..86fda36 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Server.Base; | |||
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.ServiceAuth; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | 44 | using OpenSim.Framework.Servers.HttpServer; |
44 | using OpenMetaverse; | 45 | using OpenMetaverse; |
45 | 46 | ||
@@ -49,15 +50,19 @@ namespace OpenSim.Server.Handlers.Grid | |||
49 | { | 50 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 52 | ||
53 | #pragma warning disable 414 | ||
54 | private static string LogHeader = "[GRID HANDLER]"; | ||
55 | #pragma warning restore 414 | ||
56 | |||
52 | private IGridService m_GridService; | 57 | private IGridService m_GridService; |
53 | 58 | ||
54 | public GridServerPostHandler(IGridService service) : | 59 | public GridServerPostHandler(IGridService service, IServiceAuth auth) : |
55 | base("POST", "/grid") | 60 | base("POST", "/grid", auth) |
56 | { | 61 | { |
57 | m_GridService = service; | 62 | m_GridService = service; |
58 | } | 63 | } |
59 | 64 | ||
60 | public override byte[] Handle(string path, Stream requestData, | 65 | protected override byte[] ProcessRequest(string path, Stream requestData, |
61 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 66 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
62 | { | 67 | { |
63 | StreamReader sr = new StreamReader(requestData); | 68 | StreamReader sr = new StreamReader(requestData); |
@@ -106,6 +111,9 @@ namespace OpenSim.Server.Handlers.Grid | |||
106 | case "get_default_regions": | 111 | case "get_default_regions": |
107 | return GetDefaultRegions(request); | 112 | return GetDefaultRegions(request); |
108 | 113 | ||
114 | case "get_default_hypergrid_regions": | ||
115 | return GetDefaultHypergridRegions(request); | ||
116 | |||
109 | case "get_fallback_regions": | 117 | case "get_fallback_regions": |
110 | return GetFallbackRegions(request); | 118 | return GetFallbackRegions(request); |
111 | 119 | ||
@@ -114,6 +122,9 @@ namespace OpenSim.Server.Handlers.Grid | |||
114 | 122 | ||
115 | case "get_region_flags": | 123 | case "get_region_flags": |
116 | return GetRegionFlags(request); | 124 | return GetRegionFlags(request); |
125 | |||
126 | case "get_grid_extra_features": | ||
127 | return GetGridExtraFeatures(request); | ||
117 | } | 128 | } |
118 | 129 | ||
119 | m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); | 130 | m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); |
@@ -148,7 +159,24 @@ namespace OpenSim.Server.Handlers.Grid | |||
148 | m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); | 159 | m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); |
149 | 160 | ||
150 | // Check the protocol version | 161 | // Check the protocol version |
151 | if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax)) | 162 | // This is how it works: |
163 | // Example 1: | ||
164 | // Client: [0 0] | ||
165 | // Server: [1 1] | ||
166 | // ==> fail | ||
167 | // Example 2: | ||
168 | // Client: [1 1] | ||
169 | // Server: [0 0] | ||
170 | // ==> fail | ||
171 | // Example 3: | ||
172 | // Client: [0 1] | ||
173 | // Server: [1 1] | ||
174 | // ==> success | ||
175 | // Example 4: | ||
176 | // Client: [1 1] | ||
177 | // Server: [0 1] | ||
178 | // ==> success | ||
179 | if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax || versionNumberMax < ProtocolVersions.ServerProtocolVersionMin)) | ||
152 | { | 180 | { |
153 | // Can't do, there is no overlap in the acceptable ranges | 181 | // Can't do, there is no overlap in the acceptable ranges |
154 | return FailureResult(); | 182 | return FailureResult(); |
@@ -278,8 +306,8 @@ namespace OpenSim.Server.Handlers.Grid | |||
278 | else | 306 | else |
279 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); | 307 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); |
280 | 308 | ||
309 | // m_log.DebugFormat("{0} GetRegionByPosition: loc=<{1},{2}>", LogHeader, x, y); | ||
281 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); | 310 | GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); |
282 | //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); | ||
283 | 311 | ||
284 | Dictionary<string, object> result = new Dictionary<string, object>(); | 312 | Dictionary<string, object> result = new Dictionary<string, object>(); |
285 | if (rinfo == null) | 313 | if (rinfo == null) |
@@ -444,6 +472,36 @@ namespace OpenSim.Server.Handlers.Grid | |||
444 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 472 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
445 | } | 473 | } |
446 | 474 | ||
475 | byte[] GetDefaultHypergridRegions(Dictionary<string, object> request) | ||
476 | { | ||
477 | //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions"); | ||
478 | UUID scopeID = UUID.Zero; | ||
479 | if (request.ContainsKey("SCOPEID")) | ||
480 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); | ||
481 | else | ||
482 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); | ||
483 | |||
484 | List<GridRegion> rinfos = m_GridService.GetDefaultHypergridRegions(scopeID); | ||
485 | |||
486 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
487 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
488 | result["result"] = "null"; | ||
489 | else | ||
490 | { | ||
491 | int i = 0; | ||
492 | foreach (GridRegion rinfo in rinfos) | ||
493 | { | ||
494 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
495 | result["region" + i] = rinfoDict; | ||
496 | i++; | ||
497 | } | ||
498 | } | ||
499 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
500 | |||
501 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
502 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
503 | } | ||
504 | |||
447 | byte[] GetFallbackRegions(Dictionary<string, object> request) | 505 | byte[] GetFallbackRegions(Dictionary<string, object> request) |
448 | { | 506 | { |
449 | //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); | 507 | //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); |
@@ -540,6 +598,22 @@ namespace OpenSim.Server.Handlers.Grid | |||
540 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | 598 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); |
541 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 599 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
542 | } | 600 | } |
601 | |||
602 | byte[] GetGridExtraFeatures(Dictionary<string, object> request) | ||
603 | { | ||
604 | |||
605 | Dictionary<string, object> result = new Dictionary<string, object> (); | ||
606 | Dictionary<string, object> extraFeatures = m_GridService.GetExtraFeatures (); | ||
607 | |||
608 | foreach (string key in extraFeatures.Keys) | ||
609 | { | ||
610 | result [key] = extraFeatures [key]; | ||
611 | } | ||
612 | |||
613 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
614 | |||
615 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
616 | } | ||
543 | 617 | ||
544 | #endregion | 618 | #endregion |
545 | 619 | ||
@@ -564,7 +638,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
564 | 638 | ||
565 | rootElement.AppendChild(result); | 639 | rootElement.AppendChild(result); |
566 | 640 | ||
567 | return DocToBytes(doc); | 641 | return Util.DocToBytes(doc); |
568 | } | 642 | } |
569 | 643 | ||
570 | private byte[] FailureResult() | 644 | private byte[] FailureResult() |
@@ -596,18 +670,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
596 | 670 | ||
597 | rootElement.AppendChild(message); | 671 | rootElement.AppendChild(message); |
598 | 672 | ||
599 | return DocToBytes(doc); | 673 | return Util.DocToBytes(doc); |
600 | } | ||
601 | |||
602 | private byte[] DocToBytes(XmlDocument doc) | ||
603 | { | ||
604 | MemoryStream ms = new MemoryStream(); | ||
605 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
606 | xw.Formatting = Formatting.Indented; | ||
607 | doc.WriteTo(xw); | ||
608 | xw.Flush(); | ||
609 | |||
610 | return ms.ToArray(); | ||
611 | } | 674 | } |
612 | 675 | ||
613 | #endregion | 676 | #endregion |