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.
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 2 ++
OpenSim/Framework/Util.cs | 28 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 95c3e6c..d20f8c9 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Net.Sockets;
@@ -737,6 +738,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (methodWasFound)
{
xmlRprcRequest.Params.Add(request.Url); // Param[2]
+ xmlRprcRequest.Params.Add(request.Headers.Get("X-Forwarded-For")); // Param[3]
try
{
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