From 8fc68c6d9810a0d229e94a0cefb35086c65dec36 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 3 Sep 2010 17:18:53 -0700 Subject: Added XFF header processing. Untested, for lack of proxy. --- OpenSim/Framework/Util.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index b5d025f..2ac4eb1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1495,5 +1495,33 @@ namespace OpenSim.Framework } } + /// + /// Gets the client IP address + /// + /// + /// + public static IPEndPoint GetClientIPFromXFF(string xff) + { + if (xff == string.Empty) + return null; + + string[] parts = xff.Split(new char[] { ',' }); + if (parts.Length > 0) + { + try + { + return new IPEndPoint(IPAddress.Parse(parts[0]), 0); + } + catch (Exception e) + { + m_log.WarnFormat("[UTIL]: Exception parsing XFF header {0}: {1}", xff, e.Message); + } + } + + return null; + } + + + } } -- cgit v1.1