Change handling of the SYSTEMIP constant to be more sane.

This will now choose the first network interface IP address, or the loopback
interface if no external interfaces are found. It will log the IP address
used as [NETWORK]: Using x.x.x.x for SYSTEMIP.
0.6.9
Melanie 2010-02-18 04:19:33 +00:00
parent 92f8f3e9d2
commit 842b68eeff
3 changed files with 14 additions and 7 deletions

View File

@ -487,7 +487,6 @@ namespace OpenSim.Framework
else
m_externalHostName = externalName;
// Master avatar cruft
//
string masterAvatarUUID;

View File

@ -589,11 +589,17 @@ namespace OpenSim.Framework
public static IPAddress GetLocalHost()
{
string dnsAddress = "localhost";
IPAddress[] iplist = GetLocalHosts();
IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList;
if (iplist.Length == 0) // No accessible external interfaces
{
IPAddress[] loopback = Dns.GetHostAddresses("localhost");
IPAddress localhost = loopback[0];
foreach (IPAddress host in hosts)
return localhost;
}
foreach (IPAddress host in iplist)
{
if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork)
{
@ -601,15 +607,15 @@ namespace OpenSim.Framework
}
}
if (hosts.Length > 0)
if (iplist.Length > 0)
{
foreach (IPAddress host in hosts)
foreach (IPAddress host in iplist)
{
if (host.AddressFamily == AddressFamily.InterNetwork)
return host;
}
// Well all else failed...
return hosts[0];
return iplist[0];
}
return null;

View File

@ -190,6 +190,8 @@ namespace OpenSim
PrintFileToConsole("startuplogo.txt");
m_log.InfoFormat("[NETWORK]: Using {0} as SYSTEMIP", Util.GetLocalHost().ToString());
// For now, start at the 'root' level by default
if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
ChangeSelectedRegion("region",