aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorMelanie2010-09-05 15:06:00 +0100
committerMelanie2010-09-05 15:06:00 +0100
commite4c2b44e5cb756b957a96d13ad9a611dfba12df4 (patch)
treed7978fc31ce346cae467df7a81737cfa323ae6c1 /OpenSim/Framework/Util.cs
parentRemove "Dwell" support from core and replace it with calls to methods (diff)
parentRemove "Dwell" support from core and replace it with calls to methods (diff)
downloadopensim-SC-e4c2b44e5cb756b957a96d13ad9a611dfba12df4.zip
opensim-SC-e4c2b44e5cb756b957a96d13ad9a611dfba12df4.tar.gz
opensim-SC-e4c2b44e5cb756b957a96d13ad9a611dfba12df4.tar.bz2
opensim-SC-e4c2b44e5cb756b957a96d13ad9a611dfba12df4.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs44
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}