aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorMelanie2010-08-21 00:32:26 +0100
committerMelanie2010-08-21 00:32:26 +0100
commitf8ff98577ef3e576326c6eea28cb12ebb4e0bdc4 (patch)
tree3ef10e646ddda95929142eb2c3774b42d0923b3b /OpenSim/Framework
parentForward-port a small improvement to the land out connector (diff)
parentForward-port a small improvement to the land out connector (diff)
downloadopensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.zip
opensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.gz
opensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.bz2
opensim-SC_OLD-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs4
-rw-r--r--OpenSim/Framework/Capabilities/CapsHandlers.cs2
-rw-r--r--OpenSim/Framework/Constants.cs4
-rw-r--r--OpenSim/Framework/NetworkUtil.cs82
-rw-r--r--OpenSim/Framework/RegionInfo.cs2
5 files changed, 7 insertions, 87 deletions
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index da953bb..0db7bb9 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -142,7 +142,7 @@ namespace OpenSim.Framework.Capabilities
142 142
143 m_httpListenPort = httpPort; 143 m_httpListenPort = httpPort;
144 144
145 if (httpServer.UseSSL) 145 if (httpServer != null && httpServer.UseSSL)
146 { 146 {
147 m_httpListenPort = httpServer.SSLPort; 147 m_httpListenPort = httpServer.SSLPort;
148 httpListen = httpServer.SSLCommonName; 148 httpListen = httpServer.SSLCommonName;
@@ -151,7 +151,7 @@ namespace OpenSim.Framework.Capabilities
151 151
152 m_agentID = agent; 152 m_agentID = agent;
153 m_dumpAssetsToFile = dumpAssetsToFile; 153 m_dumpAssetsToFile = dumpAssetsToFile;
154 m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, httpServer.UseSSL); 154 m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL);
155 m_regionName = regionName; 155 m_regionName = regionName;
156 } 156 }
157 157
diff --git a/OpenSim/Framework/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Capabilities/CapsHandlers.cs
index f000aed..864e6dd 100644
--- a/OpenSim/Framework/Capabilities/CapsHandlers.cs
+++ b/OpenSim/Framework/Capabilities/CapsHandlers.cs
@@ -74,7 +74,7 @@ namespace OpenSim.Framework.Capabilities
74 m_httpListenerHostName = httpListenerHostname; 74 m_httpListenerHostName = httpListenerHostname;
75 m_httpListenerPort = httpListenerPort; 75 m_httpListenerPort = httpListenerPort;
76 m_useSSL = https; 76 m_useSSL = https;
77 if (m_useSSL) 77 if (httpListener != null && m_useSSL)
78 { 78 {
79 m_httpListenerHostName = httpListener.SSLCommonName; 79 m_httpListenerHostName = httpListener.SSLCommonName;
80 m_httpListenerPort = httpListener.SSLPort; 80 m_httpListenerPort = httpListener.SSLPort;
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index 5757061..1b1aaf2 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -83,7 +83,9 @@ namespace OpenSim.Framework
83 /// <summary>Finished, Sim Changed</summary> 83 /// <summary>Finished, Sim Changed</summary>
84 FinishedViaNewSim = 1 << 28, 84 FinishedViaNewSim = 1 << 28,
85 /// <summary>Finished, Same Sim</summary> 85 /// <summary>Finished, Same Sim</summary>
86 FinishedViaSameSim = 1 << 29 86 FinishedViaSameSim = 1 << 29,
87 /// <summary>Agent coming into the grid from another grid</summary>
88 ViaHGLogin = 1 << 30
87 } 89 }
88 90
89 } 91 }
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs
index 831ff70..2e94b0d 100644
--- a/OpenSim/Framework/NetworkUtil.cs
+++ b/OpenSim/Framework/NetworkUtil.cs
@@ -181,18 +181,10 @@ namespace OpenSim.Framework
181 throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client"); 181 throw new ArgumentException("[NetworkUtil] Unable to resolve defaultHostname to an IPv4 address for an IPv4 client");
182 } 182 }
183 183
184 static IPAddress externalIPAddress;
185
186 static NetworkUtil() 184 static NetworkUtil()
187 { 185 {
188 try 186 try
189 { 187 {
190 externalIPAddress = GetExternalIP();
191 }
192 catch { /* ignore */ }
193
194 try
195 {
196 foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) 188 foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
197 { 189 {
198 foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses) 190 foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses)
@@ -254,79 +246,5 @@ namespace OpenSim.Framework
254 return defaultHostname; 246 return defaultHostname;
255 } 247 }
256 248
257 public static IPAddress GetExternalIPOf(IPAddress user)
258 {
259 if (externalIPAddress == null)
260 return user;
261
262 if (user.ToString() == "127.0.0.1")
263 {
264 m_log.Info("[NetworkUtil] 127.0.0.1 user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
265 return externalIPAddress;
266 }
267 // Check if we're accessing localhost.
268 foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName()))
269 {
270 if (host.Equals(user) && host.AddressFamily == AddressFamily.InterNetwork)
271 {
272 m_log.Info("[NetworkUtil] Localhost user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
273 return externalIPAddress;
274 }
275 }
276
277 // Check for same LAN segment
278 foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets)
279 {
280 byte[] subnetBytes = subnet.Value.GetAddressBytes();
281 byte[] localBytes = subnet.Key.GetAddressBytes();
282 byte[] destBytes = user.GetAddressBytes();
283
284 if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length)
285 return user;
286
287 bool valid = true;
288
289 for (int i = 0; i < subnetBytes.Length; i++)
290 {
291 if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i]))
292 {
293 valid = false;
294 break;
295 }
296 }
297
298 if (subnet.Key.AddressFamily != AddressFamily.InterNetwork)
299 valid = false;
300
301 if (valid)
302 {
303 m_log.Info("[NetworkUtil] Local LAN user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
304 return externalIPAddress;
305 }
306 }
307
308 // Otherwise, return user address
309 return user;
310 }
311
312 private static IPAddress GetExternalIP()
313 {
314 string whatIsMyIp = "http://www.whatismyip.com/automation/n09230945.asp";
315 WebClient wc = new WebClient();
316 UTF8Encoding utf8 = new UTF8Encoding();
317 string requestHtml = "";
318 try
319 {
320 requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp));
321 }
322 catch (WebException we)
323 {
324 m_log.Info("[NetworkUtil]: Exception in GetExternalIP: " + we.ToString());
325 return null;
326 }
327
328 IPAddress externalIp = IPAddress.Parse(requestHtml);
329 return externalIp;
330 }
331 } 249 }
332} 250}
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 2a74e79..ec25118 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -394,7 +394,7 @@ namespace OpenSim.Framework
394 if (!File.Exists(filename)) // New region config request 394 if (!File.Exists(filename)) // New region config request
395 { 395 {
396 IniConfigSource newFile = new IniConfigSource(); 396 IniConfigSource newFile = new IniConfigSource();
397 ReadNiniConfig(newFile, String.Empty); 397 ReadNiniConfig(newFile, configName);
398 398
399 newFile.Save(filename); 399 newFile.Save(filename);
400 400