From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 21 +++-- .../Server/Handlers/Grid/GridServerConnector.cs | 5 +- .../Server/Handlers/Grid/GridServerPostHandler.cs | 99 ++++++++++++++++++---- 3 files changed, 97 insertions(+), 28 deletions(-) (limited to 'OpenSim/Server/Handlers/Grid') 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 public string JsonGetGridInfoMethod(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - string HomeURI = String.Empty; - IConfig cfg = m_Config.Configs["LoginService"]; - - if (null != cfg) - { - HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); - } - OSDMap map = new OSDMap(); foreach (string k in _info.Keys) @@ -185,9 +177,20 @@ namespace OpenSim.Server.Handlers.Grid map[k] = OSD.FromString(_info[k].ToString()); } + string HomeURI = Util.GetConfigVarFromSections(m_Config, "HomeURI", + new string[] { "Startup", "Hypergrid" }, String.Empty); + if (!String.IsNullOrEmpty(HomeURI)) + map["home"] = OSD.FromString(HomeURI); + else // Legacy. Remove soon! { - map["home"] = OSD.FromString(HomeURI); + IConfig cfg = m_Config.Configs["LoginService"]; + + if (null != cfg) + HomeURI = cfg.GetString("SRV_HomeURI", HomeURI); + + if (!String.IsNullOrEmpty(HomeURI)) + map["home"] = OSD.FromString(HomeURI); } 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; using Nini.Config; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; @@ -55,7 +56,9 @@ namespace OpenSim.Server.Handlers.Grid Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin(gridService, args); - server.AddStreamHandler(new GridServerPostHandler(m_GridService)); + IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); + + server.AddStreamHandler(new GridServerPostHandler(m_GridService, auth)); } } } 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; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse; @@ -49,15 +50,19 @@ namespace OpenSim.Server.Handlers.Grid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +#pragma warning disable 414 + private static string LogHeader = "[GRID HANDLER]"; +#pragma warning restore 414 + private IGridService m_GridService; - public GridServerPostHandler(IGridService service) : - base("POST", "/grid") + public GridServerPostHandler(IGridService service, IServiceAuth auth) : + base("POST", "/grid", auth) { m_GridService = service; } - public override byte[] Handle(string path, Stream requestData, + protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); @@ -106,6 +111,9 @@ namespace OpenSim.Server.Handlers.Grid case "get_default_regions": return GetDefaultRegions(request); + case "get_default_hypergrid_regions": + return GetDefaultHypergridRegions(request); + case "get_fallback_regions": return GetFallbackRegions(request); @@ -114,6 +122,9 @@ namespace OpenSim.Server.Handlers.Grid case "get_region_flags": return GetRegionFlags(request); + + case "get_grid_extra_features": + return GetGridExtraFeatures(request); } m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method); @@ -148,7 +159,24 @@ namespace OpenSim.Server.Handlers.Grid m_log.WarnFormat("[GRID HANDLER]: no maximum protocol version in request to register region"); // Check the protocol version - if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax && versionNumberMax < ProtocolVersions.ServerProtocolVersionMax)) + // This is how it works: + // Example 1: + // Client: [0 0] + // Server: [1 1] + // ==> fail + // Example 2: + // Client: [1 1] + // Server: [0 0] + // ==> fail + // Example 3: + // Client: [0 1] + // Server: [1 1] + // ==> success + // Example 4: + // Client: [1 1] + // Server: [0 1] + // ==> success + if ((versionNumberMin > ProtocolVersions.ServerProtocolVersionMax || versionNumberMax < ProtocolVersions.ServerProtocolVersionMin)) { // Can't do, there is no overlap in the acceptable ranges return FailureResult(); @@ -278,8 +306,8 @@ namespace OpenSim.Server.Handlers.Grid else m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position"); + // m_log.DebugFormat("{0} GetRegionByPosition: loc=<{1},{2}>", LogHeader, x, y); GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y); - //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count); Dictionary result = new Dictionary(); if (rinfo == null) @@ -444,6 +472,36 @@ namespace OpenSim.Server.Handlers.Grid return Util.UTF8NoBomEncoding.GetBytes(xmlString); } + byte[] GetDefaultHypergridRegions(Dictionary request) + { + //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions"); + UUID scopeID = UUID.Zero; + if (request.ContainsKey("SCOPEID")) + UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); + else + m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); + + List rinfos = m_GridService.GetDefaultHypergridRegions(scopeID); + + Dictionary result = new Dictionary(); + if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) + result["result"] = "null"; + else + { + int i = 0; + foreach (GridRegion rinfo in rinfos) + { + Dictionary rinfoDict = rinfo.ToKeyValuePairs(); + result["region" + i] = rinfoDict; + i++; + } + } + string xmlString = ServerUtils.BuildXmlResponse(result); + + //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); + return Util.UTF8NoBomEncoding.GetBytes(xmlString); + } + byte[] GetFallbackRegions(Dictionary request) { //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); @@ -540,6 +598,22 @@ namespace OpenSim.Server.Handlers.Grid //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); return Util.UTF8NoBomEncoding.GetBytes(xmlString); } + + byte[] GetGridExtraFeatures(Dictionary request) + { + + Dictionary result = new Dictionary (); + Dictionary extraFeatures = m_GridService.GetExtraFeatures (); + + foreach (string key in extraFeatures.Keys) + { + result [key] = extraFeatures [key]; + } + + string xmlString = ServerUtils.BuildXmlResponse(result); + + return Util.UTF8NoBomEncoding.GetBytes(xmlString); + } #endregion @@ -564,7 +638,7 @@ namespace OpenSim.Server.Handlers.Grid rootElement.AppendChild(result); - return DocToBytes(doc); + return Util.DocToBytes(doc); } private byte[] FailureResult() @@ -596,18 +670,7 @@ namespace OpenSim.Server.Handlers.Grid rootElement.AppendChild(message); - return DocToBytes(doc); - } - - private byte[] DocToBytes(XmlDocument doc) - { - MemoryStream ms = new MemoryStream(); - XmlTextWriter xw = new XmlTextWriter(ms, null); - xw.Formatting = Formatting.Indented; - doc.WriteTo(xw); - xw.Flush(); - - return ms.ToArray(); + return Util.DocToBytes(doc); } #endregion -- cgit v1.1