diff options
author | Kitto Flora | 2010-09-06 21:45:17 +0000 |
---|---|---|
committer | Kitto Flora | 2010-09-06 21:45:17 +0000 |
commit | cfaefad754642677dbddfcbe743c3fa5e058785d (patch) | |
tree | 48ac26cc5289d8c0459837cd7d6936152216403b /OpenSim/Framework/Util.cs | |
parent | Falling animation fix, comment out instrumentation. (diff) | |
parent | Fix yet another cause of "Ghost attachments" (diff) | |
download | opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.zip opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.tar.gz opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.tar.bz2 opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.tar.xz |
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index af5a0ce..b66d826 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1495,5 +1495,49 @@ namespace OpenSim.Framework | |||
1495 | } | 1495 | } |
1496 | } | 1496 | } |
1497 | 1497 | ||
1498 | /// <summary> | ||
1499 | /// Gets the client IP address | ||
1500 | /// </summary> | ||
1501 | /// <param name="xff"></param> | ||
1502 | /// <returns></returns> | ||
1503 | public static IPEndPoint GetClientIPFromXFF(string xff) | ||
1504 | { | ||
1505 | if (xff == string.Empty) | ||
1506 | return null; | ||
1507 | |||
1508 | string[] parts = xff.Split(new char[] { ',' }); | ||
1509 | if (parts.Length > 0) | ||
1510 | { | ||
1511 | try | ||
1512 | { | ||
1513 | return new IPEndPoint(IPAddress.Parse(parts[0]), 0); | ||
1514 | } | ||
1515 | catch (Exception e) | ||
1516 | { | ||
1517 | m_log.WarnFormat("[UTIL]: Exception parsing XFF header {0}: {1}", xff, e.Message); | ||
1518 | } | ||
1519 | } | ||
1520 | |||
1521 | return null; | ||
1522 | } | ||
1523 | |||
1524 | public static string GetCallerIP(Hashtable req) | ||
1525 | { | ||
1526 | if (req.ContainsKey("headers")) | ||
1527 | { | ||
1528 | try | ||
1529 | { | ||
1530 | Hashtable headers = (Hashtable)req["headers"]; | ||
1531 | if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null) | ||
1532 | return headers["remote_addr"].ToString(); | ||
1533 | } | ||
1534 | catch (Exception e) | ||
1535 | { | ||
1536 | m_log.WarnFormat("[UTIL]: exception in GetCallerIP: {0}", e.Message); | ||
1537 | } | ||
1538 | } | ||
1539 | return string.Empty; | ||
1540 | } | ||
1541 | |||
1498 | } | 1542 | } |
1499 | } | 1543 | } |