Merge branch 'master' into careminster-presence-refactor

This commit is contained in:
Melanie
2010-08-21 00:32:26 +01:00
24 changed files with 675 additions and 550 deletions

View File

@@ -142,7 +142,7 @@ namespace OpenSim.Framework.Capabilities
m_httpListenPort = httpPort;
if (httpServer.UseSSL)
if (httpServer != null && httpServer.UseSSL)
{
m_httpListenPort = httpServer.SSLPort;
httpListen = httpServer.SSLCommonName;
@@ -151,7 +151,7 @@ namespace OpenSim.Framework.Capabilities
m_agentID = agent;
m_dumpAssetsToFile = dumpAssetsToFile;
m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL);
m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL);
m_regionName = regionName;
}

View File

@@ -74,7 +74,7 @@ namespace OpenSim.Framework.Capabilities
m_httpListenerHostName = httpListenerHostname;
m_httpListenerPort = httpListenerPort;
m_useSSL = https;
if (m_useSSL)
if (httpListener != null && m_useSSL)
{
m_httpListenerHostName = httpListener.SSLCommonName;
m_httpListenerPort = httpListener.SSLPort;

View File

@@ -83,7 +83,9 @@ namespace OpenSim.Framework
/// <summary>Finished, Sim Changed</summary>
FinishedViaNewSim = 1 << 28,
/// <summary>Finished, Same Sim</summary>
FinishedViaSameSim = 1 << 29
FinishedViaSameSim = 1 << 29,
/// <summary>Agent coming into the grid from another grid</summary>
ViaHGLogin = 1 << 30
}
}

View File

@@ -181,16 +181,8 @@ namespace OpenSim.Framework
throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client");
}
static IPAddress externalIPAddress;
static NetworkUtil()
{
try
{
externalIPAddress = GetExternalIP();
}
catch { /* ignore */ }
try
{
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
@@ -254,79 +246,5 @@ namespace OpenSim.Framework
return defaultHostname;
}
public static IPAddress GetExternalIPOf(IPAddress user)
{
if (externalIPAddress == null)
return user;
if (user.ToString() == "127.0.0.1")
{
m_log.Info("[NetworkUtil] 127.0.0.1 user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
return externalIPAddress;
}
// Check if we're accessing localhost.
foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork)
{
m_log.Info("[NetworkUtil] Localhost user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
return externalIPAddress;
}
}
// Check for same LAN segment
foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets)
{
byte[] subnetBytes = subnet.Value.GetAddressBytes();
byte[] localBytes = subnet.Key.GetAddressBytes();
byte[] destBytes = user.GetAddressBytes();
if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length)
return user;
bool valid = true;
for (int i = 0; i < subnetBytes.Length; i++)
{
if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i]))
{
valid = false;
break;
}
}
if (subnet.Key.AddressFamily != AddressFamily.InterNetwork)
valid = false;
if (valid)
{
m_log.Info("[NetworkUtil] Local LAN user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
return externalIPAddress;
}
}
// Otherwise, return user address
return user;
}
private static IPAddress GetExternalIP()
{
string whatIsMyIp = "http://www.whatismyip.com/automation/n09230945.asp";
WebClient wc = new WebClient();
UTF8Encoding utf8 = new UTF8Encoding();
string requestHtml = "";
try
{
requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp));
}
catch (WebException we)
{
m_log.Info("[NetworkUtil]: Exception in GetExternalIP: " + we.ToString());
return null;
}
IPAddress externalIp = IPAddress.Parse(requestHtml);
return externalIp;
}
}
}

View File

@@ -394,7 +394,7 @@ namespace OpenSim.Framework
if (!File.Exists(filename)) // New region config request
{
IniConfigSource newFile = new IniConfigSource();
ReadNiniConfig(newFile, String.Empty);
ReadNiniConfig(newFile, configName);
newFile.Save(filename);