Browse Source

fix IClientIPEndpoint broken by justin long ago.. but stop using it
except on SceneBanner, later it my be also removed from there and
everywhere

UbitUmarov 7 years ago
parent
commit
73222e4dd4

+ 1 - 1
OpenSim/Framework/Client/IClientIPEndpoint.cs

@@ -34,6 +34,6 @@ namespace OpenSim.Framework.Client
 {
     public interface IClientIPEndpoint
     {
-        IPAddress EndPoint { get; }
+        IPEndPoint  RemoteEndPoint { get; }
     }
 }

+ 1 - 1
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
     /// </summary>
-    public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
+    public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector, IClientIPEndpoint
     {
         /// <value>
         /// Debug packet level.  See OpenSim.RegisterConsoleCommands() for more details.

+ 2 - 2
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
                     {

+ 11 - 16
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}>) " +