diff options
author | Justin Clark-Casey (justincc) | 2010-08-19 00:54:48 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-19 00:54:48 +0100 |
commit | 5e3d53bef2b1d1473a54a92ff8035bf04d422b0c (patch) | |
tree | 0fa5281da45eca965f413d73fb71173387535db8 /OpenSim/Framework | |
parent | minor: Correct string format in "Can't find linkset root prim" message (diff) | |
parent | One more go at GetExternalIpOf(user). Addresses mantis #4955 and #4943. (diff) | |
download | opensim-SC_OLD-5e3d53bef2b1d1473a54a92ff8035bf04d422b0c.zip opensim-SC_OLD-5e3d53bef2b1d1473a54a92ff8035bf04d422b0c.tar.gz opensim-SC_OLD-5e3d53bef2b1d1473a54a92ff8035bf04d422b0c.tar.bz2 opensim-SC_OLD-5e3d53bef2b1d1473a54a92ff8035bf04d422b0c.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/NetworkUtil.cs | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs index 831ff70..5649131 100644 --- a/OpenSim/Framework/NetworkUtil.cs +++ b/OpenSim/Framework/NetworkUtil.cs | |||
@@ -274,37 +274,49 @@ namespace OpenSim.Framework | |||
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | // Check for same LAN segment | 277 | // Check for private networks |
278 | foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets) | 278 | if (user.ToString().StartsWith("192.168")) |
279 | { | 279 | { |
280 | byte[] subnetBytes = subnet.Value.GetAddressBytes(); | 280 | m_log.Info("[NetworkUtil] Private network user detected, sending '" + externalIPAddress + "' instead of '" + user + "'"); |
281 | byte[] localBytes = subnet.Key.GetAddressBytes(); | 281 | return externalIPAddress; |
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 | } | 282 | } |
307 | 283 | ||
284 | // We may need to do more fancy configuration-based checks... I'm not entirely sure there is | ||
285 | // a 100% algorithmic manner of dealing with all the network setups out there. This code | ||
286 | // will evolve as people bump into problems. | ||
287 | |||
288 | //// Check for same LAN segment -- I don't think we want to do this in general. Leaving it here | ||
289 | //// for now as a reminder | ||
290 | //foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets) | ||
291 | //{ | ||
292 | // byte[] subnetBytes = subnet.Value.GetAddressBytes(); | ||
293 | // byte[] localBytes = subnet.Key.GetAddressBytes(); | ||
294 | // byte[] destBytes = user.GetAddressBytes(); | ||
295 | |||
296 | // if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length) | ||
297 | // return user; | ||
298 | |||
299 | // bool valid = true; | ||
300 | |||
301 | // for (int i = 0; i < subnetBytes.Length; i++) | ||
302 | // { | ||
303 | // if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i])) | ||
304 | // { | ||
305 | // valid = false; | ||
306 | // break; | ||
307 | // } | ||
308 | // } | ||
309 | |||
310 | // if (subnet.Key.AddressFamily != AddressFamily.InterNetwork) | ||
311 | // valid = false; | ||
312 | |||
313 | // if (valid) | ||
314 | // { | ||
315 | // m_log.Info("[NetworkUtil] Local LAN user detected, sending '" + externalIPAddress + "' instead of '" + user + "'"); | ||
316 | // return externalIPAddress; | ||
317 | // } | ||
318 | //} | ||
319 | |||
308 | // Otherwise, return user address | 320 | // Otherwise, return user address |
309 | return user; | 321 | return user; |
310 | } | 322 | } |