aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/NetworkUtil.cs
diff options
context:
space:
mode:
authorMelanie2010-08-19 20:25:17 +0100
committerMelanie2010-08-19 20:25:17 +0100
commit1ab631f01544c36dec165caab3857f641f697190 (patch)
treed47bc9aa8533be7e2f0ab725d62e63dd55a72059 /OpenSim/Framework/NetworkUtil.cs
parentShort-circuit the grid server lookup for RequestSimulatorData if the region (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-1ab631f01544c36dec165caab3857f641f697190.zip
opensim-SC-1ab631f01544c36dec165caab3857f641f697190.tar.gz
opensim-SC-1ab631f01544c36dec165caab3857f641f697190.tar.bz2
opensim-SC-1ab631f01544c36dec165caab3857f641f697190.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Framework/NetworkUtil.cs')
-rw-r--r--OpenSim/Framework/NetworkUtil.cs68
1 files changed, 28 insertions, 40 deletions
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs
index 5649131..831ff70 100644
--- a/OpenSim/Framework/NetworkUtil.cs
+++ b/OpenSim/Framework/NetworkUtil.cs
@@ -274,48 +274,36 @@ namespace OpenSim.Framework
274 } 274 }
275 } 275 }
276 276
277 // Check for private networks 277 // Check for same LAN segment
278 if (user.ToString().StartsWith("192.168")) 278 foreach (KeyValuePair<IPAddress, IPAddress> subnet in m_subnets)
279 { 279 {
280 m_log.Info("[NetworkUtil] Private network user detected, sending '" + externalIPAddress + "' instead of '" + user + "'"); 280 byte[] subnetBytes = subnet.Value.GetAddressBytes();
281 return externalIPAddress; 281 byte[] localBytes = subnet.Key.GetAddressBytes();
282 } 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;
283 300
284 // We may need to do more fancy configuration-based checks... I'm not entirely sure there is 301 if (valid)
285 // a 100% algorithmic manner of dealing with all the network setups out there. This code 302 {
286 // will evolve as people bump into problems. 303 m_log.Info("[NetworkUtil] Local LAN user detected, sending '" + externalIPAddress + "' instead of '" + user + "'");
287 304 return externalIPAddress;
288 //// Check for same LAN segment -- I don't think we want to do this in general. Leaving it here 305 }
289 //// for now as a reminder 306 }
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 307
320 // Otherwise, return user address 308 // Otherwise, return user address
321 return user; 309 return user;