diff options
author | Diva Canto | 2010-07-30 14:27:53 -0700 |
---|---|---|
committer | Diva Canto | 2010-07-30 14:27:53 -0700 |
commit | 86bc25b84fbc01c827f3959b4eca67e34383b041 (patch) | |
tree | 6b43563713968fca7a594f34b541449da7dcbcb7 /OpenSim/Framework/NetworkUtil.cs | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-86bc25b84fbc01c827f3959b4eca67e34383b041.zip opensim-SC_OLD-86bc25b84fbc01c827f3959b4eca67e34383b041.tar.gz opensim-SC_OLD-86bc25b84fbc01c827f3959b4eca67e34383b041.tar.bz2 opensim-SC_OLD-86bc25b84fbc01c827f3959b4eca67e34383b041.tar.xz |
Slight improvement on previous commit.
Diffstat (limited to 'OpenSim/Framework/NetworkUtil.cs')
-rw-r--r-- | OpenSim/Framework/NetworkUtil.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index 7c30bd3..831ff70 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs | |||
@@ -188,7 +188,11 @@ namespace OpenSim.Framework | |||
188 | try | 188 | try |
189 | { | 189 | { |
190 | externalIPAddress = GetExternalIP(); | 190 | externalIPAddress = GetExternalIP(); |
191 | } | ||
192 | catch { /* ignore */ } | ||
191 | 193 | ||
194 | try | ||
195 | { | ||
192 | foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) | 196 | foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) |
193 | { | 197 | { |
194 | foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses) | 198 | foreach (UnicastIPAddressInformation address in ni.GetIPProperties().UnicastAddresses) |
@@ -252,6 +256,14 @@ namespace OpenSim.Framework | |||
252 | 256 | ||
253 | public static IPAddress GetExternalIPOf(IPAddress user) | 257 | public static IPAddress GetExternalIPOf(IPAddress user) |
254 | { | 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 | } | ||
255 | // Check if we're accessing localhost. | 267 | // Check if we're accessing localhost. |
256 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) | 268 | foreach (IPAddress host in Dns.GetHostAddresses(Dns.GetHostName())) |
257 | { | 269 | { |
@@ -309,8 +321,8 @@ namespace OpenSim.Framework | |||
309 | } | 321 | } |
310 | catch (WebException we) | 322 | catch (WebException we) |
311 | { | 323 | { |
312 | // do something with exception | ||
313 | m_log.Info("[NetworkUtil]: Exception in GetExternalIP: " + we.ToString()); | 324 | m_log.Info("[NetworkUtil]: Exception in GetExternalIP: " + we.ToString()); |
325 | return null; | ||
314 | } | 326 | } |
315 | 327 | ||
316 | IPAddress externalIp = IPAddress.Parse(requestHtml); | 328 | IPAddress externalIp = IPAddress.Parse(requestHtml); |