* Mono sucks. (Fixes crash due to Mono not implementing NetworkInformation.IPv4Mask aka Subnet masks)

0.6.6-post-fixes
Adam Frisby 2009-05-24 02:07:54 +00:00
parent ac79ff8dc6
commit 2cfe44f13e
1 changed files with 12 additions and 5 deletions

View File

@ -144,19 +144,26 @@ namespace OpenSim.Framework
static NetworkUtil()
{
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
try
{
foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses)
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
if (address.Address.AddressFamily == AddressFamily.InterNetwork)
foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses)
{
if (address.IPv4Mask != null)
if (address.Address.AddressFamily == AddressFamily.InterNetwork)
{
m_subnets.Add(address.Address, address.IPv4Mask);
if (address.IPv4Mask != null)
{
m_subnets.Add(address.Address, address.IPv4Mask);
}
}
}
}
}
catch (NotImplementedException)
{
// Mono Sucks.
}
}
public static IPAddress GetIPFor(IPEndPoint user, string defaultHostname)