From 73222e4dd4e735225845184de22e245c454b40db Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 22 May 2017 19:14:19 +0100 Subject: [PATCH] fix IClientIPEndpoint broken by justin long ago.. but stop using it except on SceneBanner, later it my be also removed from there and everywhere --- OpenSim/Framework/Client/IClientIPEndpoint.cs | 2 +- .../ClientStack/Linden/UDP/LLClientView.cs | 2 +- .../CoreModules/Agent/IPBan/SceneBanner.cs | 4 +-- .../EntityTransfer/EntityTransferModule.cs | 27 ++++++++----------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/Client/IClientIPEndpoint.cs b/OpenSim/Framework/Client/IClientIPEndpoint.cs index 2b99bf0a99..2194616a02 100644 --- a/OpenSim/Framework/Client/IClientIPEndpoint.cs +++ b/OpenSim/Framework/Client/IClientIPEndpoint.cs @@ -34,6 +34,6 @@ namespace OpenSim.Framework.Client { public interface IClientIPEndpoint { - IPAddress EndPoint { get; } + IPEndPoint RemoteEndPoint { get; } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 298c933da6..f658a709af 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -62,7 +62,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Handles new client connections /// Constructor takes a single Packet and authenticates everything /// - public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector + public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector, IClientIPEndpoint { /// /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details. diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs index 8502006cd7..b4c68e2a65 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs @@ -53,9 +53,9 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan if (bans.Count > 0) { IClientIPEndpoint ipEndpoint; - if (client.TryGet(out ipEndpoint)) + if (client.TryGet(out ipEndpoint) && ipEndpoint.RemoteEndPoint != null) { - IPAddress end = ipEndpoint.EndPoint; + IPAddress end = ipEndpoint.RemoteEndPoint.Address; try { diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 87b76dc30b..3564f7f581 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -813,8 +813,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agentCircuit.Id0 = currentAgentCircuit.Id0; } - IClientIPEndpoint ipepClient; - uint newRegionX, newRegionY, oldRegionX, oldRegionY; Util.RegionHandleToRegionLoc(destinationHandle, out newRegionX, out newRegionY); Util.RegionHandleToRegionLoc(sourceRegion.RegionHandle, out oldRegionX, out oldRegionY); @@ -834,11 +832,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); #region IP Translation for NAT - // Uses ipepClient above - if (sp.ClientView.TryGet(out ipepClient)) - { - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); - } + IPEndPoint clientEP = sp.ControllingClient.RemoteEndPoint; + if (clientEP != null && clientEP.Address != null) + endPoint.Address = NetworkUtil.GetIPFor(clientEP.Address, endPoint.Address); + #endregion agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); } @@ -1746,10 +1743,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (m_eqModule != null) { #region IP Translation for NAT - IClientIPEndpoint ipepClient; - if (agent.ClientView.TryGet(out ipepClient)) - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); - + IPEndPoint clientEP = agent.ControllingClient.RemoteEndPoint; + if (clientEP != null && clientEP.Address != null) + endPoint.Address = NetworkUtil.GetIPFor(clientEP.Address, endPoint.Address); + m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + "and EstablishAgentCommunication with seed cap {8}", LogHeader, source.RegionName, agent.Name, @@ -2402,11 +2399,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if(sp == null || sp.IsDeleted || sp.ClientView == null) // something bad already happened return; - IClientIPEndpoint ipepClient; - if (sp.ClientView.TryGet(out ipepClient)) - { - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); - } + IPEndPoint clientEP = sp.ControllingClient.RemoteEndPoint; + if (clientEP != null && clientEP.Address != null) + endPoint.Address = NetworkUtil.GetIPFor(clientEP.Address, endPoint.Address); #endregion m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +