From c0a23d36dfa28a3204b31883e1e7bc76b249c8fb Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 15 Dec 2016 23:48:25 +0000 Subject: GetRegionsByName and GetHypergridRegionByName: detect that provided url is for local grid, and make it a local by region name local search --- OpenSim/Services/GridService/GridService.cs | 29 +++++++++++++++---------- OpenSim/Services/GridService/HypergridLinker.cs | 10 +++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 31a186a..82b910a 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -508,6 +508,7 @@ namespace OpenSim.Services.GridService if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) return null; + bool localGrid = string.IsNullOrWhiteSpace(regionURI); string mapname = regionURI + regionName; bool haveMatch = false; @@ -531,7 +532,7 @@ namespace OpenSim.Services.GridService if(haveMatch) return rinfos; } - + rdatas = m_Database.Get(Util.EscapeForLike(mapname)+ "%", scopeID); if (rdatas != null && (rdatas.Count > 0)) { @@ -554,14 +555,16 @@ namespace OpenSim.Services.GridService if(haveMatch) return rinfos; } - - string HGname = regionURI +" "+ regionName; - GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); - if (r != null) + if(!localGrid) { - if( count == maxNumber) - rinfos.RemoveAt(count - 1); - rinfos.Add(r); + string HGname = regionURI +" "+ regionName; // include space for compatibility + GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); + if (r != null) + { + if( count == maxNumber) + rinfos.RemoveAt(count - 1); + rinfos.Add(r); + } } } else if (rdatas != null && (rdatas.Count > 0)) @@ -597,11 +600,13 @@ namespace OpenSim.Services.GridService if ((rdatas != null) && (rdatas.Count > 0)) return RegionData2RegionInfo(rdatas[0]); // get the first - string HGname = regionURI +" "+ regionName; - return m_HypergridLinker.LinkRegion(scopeID, HGname); + if(!string.IsNullOrWhiteSpace(regionURI)) + { + string HGname = regionURI +" "+ regionName; + return m_HypergridLinker.LinkRegion(scopeID, HGname); + } } - else - return null; + return null; } public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index ceb2c6e..185f2ff 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -137,6 +137,12 @@ namespace OpenSim.Services.GridService m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); } + m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri; + if(m_ThisGatekeeperURI.Port == 80) + m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/"; + else if(m_ThisGatekeeperURI.Port == 443) + m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/"; + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); @@ -302,6 +308,10 @@ namespace OpenSim.Services.GridService serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/"; else if(uri.Port == 443) serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/"; + + if(serverURI == m_ThisGatekeeper) + serverURI = ""; // local grid, look for region name only + return true; } -- cgit v1.1 From e2d46c060c4b9557cf596d6d828ddd296fa0af70 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Dec 2016 03:38:20 +0000 Subject: ok.. another try on the HG uri --- OpenSim/Services/GridService/GridService.cs | 25 +++-- OpenSim/Services/GridService/HypergridLinker.cs | 121 +----------------------- 2 files changed, 22 insertions(+), 124 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 82b910a..c51bb8b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -505,11 +505,16 @@ namespace OpenSim.Services.GridService { string regionURI = ""; string regionName = ""; - if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) + if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) return null; - bool localGrid = string.IsNullOrWhiteSpace(regionURI); - string mapname = regionURI + regionName; + string mapname; + bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); + if(localGrid) + mapname = regionName; + else + mapname = regionURI + regionName; + bool haveMatch = false; if (rdatas != null && (rdatas.Count > 0)) @@ -555,7 +560,7 @@ namespace OpenSim.Services.GridService if(haveMatch) return rinfos; } - if(!localGrid) + if(!localGrid && !string.IsNullOrWhiteSpace(regionURI)) { string HGname = regionURI +" "+ regionName; // include space for compatibility GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); @@ -592,15 +597,21 @@ namespace OpenSim.Services.GridService { string regionURI = ""; string regionName = ""; - if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) + if(!Util.buildHGRegionURI(name, out regionURI, out regionName)) return null; - string mapname = regionURI + regionName; + string mapname; + bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI); + if(localGrid) + mapname = regionName; + else + mapname = regionURI + regionName; + List rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID); if ((rdatas != null) && (rdatas.Count > 0)) return RegionData2RegionInfo(rdatas[0]); // get the first - if(!string.IsNullOrWhiteSpace(regionURI)) + if(!localGrid && !string.IsNullOrWhiteSpace(regionURI)) { string HGname = regionURI +" "+ regionName; return m_HypergridLinker.LinkRegion(scopeID, HGname); diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 185f2ff..aa394ce 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -196,123 +196,10 @@ namespace OpenSim.Services.GridService { return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); } - - public bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) + + public bool IsLocalGrid(string serverURI) { - serverURI = string.Empty; - regionName = string.Empty; - - inputName = inputName.Trim(); - - if (!inputName.StartsWith("http") && !inputName.StartsWith("https")) - { - // Formats: grid.example.com:8002:region name - // grid.example.com:region name - // grid.example.com:8002 - // grid.example.com - - string host; - uint port = 80; - - string[] parts = inputName.Split(new char[] { ':' }); - int indx; - if(parts.Length == 0) - return false; - if (parts.Length == 1) - { - indx = inputName.IndexOf('/'); - if (indx < 0) - serverURI = "http://"+ inputName + "/"; - else - { - serverURI = "http://"+ inputName.Substring(0,indx + 1); - if(indx + 2 < inputName.Length) - regionName = inputName.Substring(indx + 1); - } - } - else - { - host = parts[0]; - - if (parts.Length >= 2) - { - indx = parts[1].IndexOf('/'); - if(indx < 0) - { - // If it's a number then assume it's a port. Otherwise, it's a region name. - if (!UInt32.TryParse(parts[1], out port)) - { - port = 80; - regionName = parts[1]; - } - } - else - { - string portstr = parts[1].Substring(0, indx); - if(indx + 2 < parts[1].Length) - regionName = parts[1].Substring(indx + 1); - if (!UInt32.TryParse(portstr, out port)) - port = 80; - } - } - // always take the last one - if (parts.Length >= 3) - { - regionName = parts[2]; - } - - serverURI = "http://"+ host +":"+ port.ToString() + "/"; - } - } - else - { - // Formats: http://grid.example.com region name - // http://grid.example.com "region name" - // http://grid.example.com - - string[] parts = inputName.Split(new char[] { ' ' }); - - if (parts.Length == 0) - return false; - - serverURI = parts[0]; - - int indx = serverURI.LastIndexOf('/'); - if(indx > 10) - { - if(indx + 2 < inputName.Length) - regionName = inputName.Substring(indx + 1); - serverURI = inputName.Substring(0, indx + 1); - } - else if (parts.Length >= 2) - { - regionName = inputName.Substring(serverURI.Length); - } - } - - // use better code for sanity check - Uri uri; - try - { - uri = new Uri(serverURI); - } - catch - { - return false; - } - - if(!string.IsNullOrEmpty(regionName)) - regionName = regionName.Trim(new char[] { '"', ' ' }); - serverURI = uri.AbsoluteUri; - if(uri.Port == 80) - serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/"; - else if(uri.Port == 443) - serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/"; - - if(serverURI == m_ThisGatekeeper) - serverURI = ""; // local grid, look for region name only - - return true; + return serverURI == m_ThisGatekeeper; } public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) @@ -323,7 +210,7 @@ namespace OpenSim.Services.GridService string serverURI = string.Empty; string regionName = string.Empty; - if(!buildHGRegionURI(mapName, out serverURI, out regionName)) + if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName)) { reason = "Wrong URI format for link-region"; return null; -- cgit v1.1 From 1ddc90f16ea9e97a77b8f7c92567b03311fa293a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Dec 2016 18:55:13 +0000 Subject: useless change that doesn't fix anything --- .../Services/Connectors/Land/LandServicesConnector.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs index 7839a68..5e9331e 100644 --- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs +++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs @@ -66,22 +66,31 @@ namespace OpenSim.Services.Connectors public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess) { LandData landData = null; - Hashtable hash = new Hashtable(); - hash["region_handle"] = regionHandle.ToString(); - hash["x"] = x.ToString(); - hash["y"] = y.ToString(); IList paramList = new ArrayList(); - paramList.Add(hash); regionAccess = 42; // Default to adult. Better safe... try { uint xpos = 0, ypos = 0; Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos); + GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos); if (info != null) // just to be sure { + string targetHandlestr = info.RegionHandle.ToString(); + if( ypos == 0 ) //HG proxy? + { + // this is real region handle on hg proxies hack + targetHandlestr = info.RegionSecret; + } + + Hashtable hash = new Hashtable(); + hash["region_handle"] = targetHandlestr; + hash["x"] = x.ToString(); + hash["y"] = y.ToString(); + paramList.Add(hash); + XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); XmlRpcResponse response = request.Send(info.ServerURI, 10000); if (response.IsFault) -- cgit v1.1 From be490a8312837ae66647a7597c29097a13d1c679 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Dec 2016 19:11:05 +0000 Subject: remove a nonsense option --- OpenSim/Services/GridService/GridService.cs | 5 ----- 1 file changed, 5 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index c51bb8b..c5419d5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -57,9 +57,6 @@ namespace OpenSim.Services.GridService protected bool m_AllowDuplicateNames = false; protected bool m_AllowHypergridMapSearch = false; - - protected bool m_SuppressVarregionOverlapCheckOnRegistration = false; - private static Dictionary m_ExtraFeatures = new Dictionary(); public GridService(IConfigSource config) @@ -86,8 +83,6 @@ namespace OpenSim.Services.GridService m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); - m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration); - // This service is also used locally by a simulator running in grid mode. This switches prevents // inappropriate console commands from being registered suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands); -- cgit v1.1 From aa9a56d4df25c073c504575eee2dafcb3d08f6d1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Dec 2016 21:15:21 +0000 Subject: dont allow regions to be register on map area reserved for HG links --- OpenSim/Services/GridService/GridService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index c5419d5..aa13a67 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -197,6 +197,9 @@ namespace OpenSim.Services.GridService if (regionInfos.RegionID == UUID.Zero) return "Invalid RegionID - cannot be zero UUID"; + if (regionInfos.RegionLocY <= Constants.MaximumRegionSize) + return "Region location reserved for HG links coord Y must be higher than " + (Constants.MaximumRegionSize/256).ToString(); + String reason = "Region overlaps another region"; List rdatas = m_Database.Get( @@ -290,7 +293,7 @@ namespace OpenSim.Services.GridService // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY); try { -- cgit v1.1