* Fixes [irritating] edge case in Util.GetLocalHost which could return an IPv6 address if no non-loopback IPv4 address can be found.

* Restores internal IPv6 support to NetworkUtil.*
* Fixes bad login unit tests.
This commit is contained in:
Adam Frisby
2009-05-23 07:51:29 +00:00
parent 6fe55a7ff8
commit 70f6a2852e
3 changed files with 47 additions and 15 deletions

View File

@@ -73,9 +73,8 @@ namespace OpenSim.Framework
private static IPAddress GetExternalIPFor(IPAddress destination, string defaultHostname)
{
bool ipv6 = false;
// Adds IPv6 Support (Not that any of the major protocols supports it...)
if (ipv6 && destination.AddressFamily == AddressFamily.InterNetworkV6)
if (destination.AddressFamily == AddressFamily.InterNetworkV6)
{
foreach (IPAddress host in Dns.GetHostAddresses(defaultHostname))
{
@@ -91,10 +90,14 @@ namespace OpenSim.Framework
return null;
// Check if we're accessing localhost.
foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName()))
foreach (KeyValuePair<IPAddress, IPAddress> pair in m_subnets)
{
IPAddress host = pair.Value;
if (host.Equals(destination) && host.AddressFamily == AddressFamily.InterNetwork)
{
m_log.Info("[NATROUTING] Localhost user detected, sending them '" + host + "' instead of '" + defaultHostname + "'");
return destination;
}
}
// Check for same LAN segment