From bb363d9aa46932085296cadbd603f25d5be5a6a1 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 07:07:02 +0000 Subject: * "Fixed" an issue with NAT Login Handler, apparently an IPv4Mask can be null on an IPv4 address. Go figure. (!?!) --- OpenSim/Framework/NetworkUtil.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index 81e6cad..f9d9b89 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Net.Sockets; using System.Net; using System.Net.NetworkInformation; +using System.Reflection; +using log4net; namespace OpenSim.Framework { @@ -16,6 +18,9 @@ namespace OpenSim.Framework /// public static class NetworkUtil { + // Logger + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // IPv4Address, Subnet static readonly Dictionary m_subnets = new Dictionary(); @@ -25,7 +30,10 @@ namespace OpenSim.Framework foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) { if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork) + { + m_log.Info("[NATROUTING] Localhost user detected, sending them '" + host + "' instead of '" + simulator + "'"); return host; + } } // Check for same LAN segment @@ -50,7 +58,10 @@ namespace OpenSim.Framework } if (valid) + { + m_log.Info("[NATROUTING] Local LAN user detected, sending them '" + subnet.Key + "' instead of '" + simulator + "'"); return subnet.Key; + } } // Otherwise, return outside address @@ -65,7 +76,10 @@ namespace OpenSim.Framework foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname)) { if (host.AddressFamily == AddressFamily.InterNetworkV6) + { + m_log.Info("[NATROUTING] Localhost user detected, sending them '" + host + "' instead of '" + defaultHostname + "'"); return host; + } } } @@ -101,7 +115,10 @@ namespace OpenSim.Framework } if (valid) + { + m_log.Info("[NATROUTING] Local LAN user detected, sending them '" + subnet.Key + "' instead of '" + defaultHostname + "'"); return subnet.Key; + } } // Check to see if we can find a IPv4 address. @@ -123,7 +140,13 @@ namespace OpenSim.Framework { if (address.Address.AddressFamily == AddressFamily.InterNetwork) { - m_subnets.Add(address.Address, address.IPv4Mask); + if (address.IPv4Mask != null) + { + m_subnets.Add(address.Address, address.IPv4Mask); + } else + { + m_log.Warn("[NetworkUtil] Found IPv4 Address without Subnet Mask!?"); + } } } } -- cgit v1.1