From 479d72ac975fd34f43d76c0ab20f869cb07fb6fc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 17 Jan 2011 11:37:39 -0800 Subject: Account for some component along the way lower-casing the HTTP header keys. (XFF header issue) --- .../Server/Handlers/Hypergrid/HomeAgentHandlers.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs') diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs index 814a8d9..968c1e6 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs @@ -215,16 +215,21 @@ namespace OpenSim.Server.Handlers.Hypergrid // We're behind a proxy Hashtable headers = (Hashtable)request["headers"]; - if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) - { - m_log.DebugFormat("[HOME AGENT HANDLER]: XFF is {0}", headers["X-Forwarded-For"]); + string xff = "X-Forwarded-For"; + if (headers.ContainsKey(xff.ToLower())) + xff = xff.ToLower(); - IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]); - if (ep != null) - return ep.Address.ToString(); + if (!headers.ContainsKey(xff) || headers[xff] == null) + { + m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); + return Util.GetCallerIP(request); } - else - m_log.WarnFormat("[HOME AGENT HANDLER]: No XFF header"); + + m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]); + + IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]); + if (ep != null) + return ep.Address.ToString(); // Oops return Util.GetCallerIP(request); -- cgit v1.1