From 66f99ae2677c4cfc26d2376c1de9e8e5d7022dfd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 17 Jan 2011 11:03:46 -0800 Subject: More debug messages to help track the XFF header problem. --- OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs | 2 ++ OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 3 +++ 2 files changed, 5 insertions(+) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs index 0066bd4..814a8d9 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs @@ -223,6 +223,8 @@ namespace OpenSim.Server.Handlers.Hypergrid if (ep != null) return ep.Address.ToString(); } + else + m_log.WarnFormat("[HOME AGENT HANDLER]: No XFF header"); // Oops return Util.GetCallerIP(request); diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 9c41bcb..b572cb3 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -208,6 +208,9 @@ namespace OpenSim.Server.Handlers.Simulation if (ep != null) return ep.Address.ToString(); } + else + m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); + // Oops return Util.GetCallerIP(request); -- cgit v1.1 From 0aeb8981b2b147e2caf2614fbfe59bd7e4340aee Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 17 Jan 2011 11:19:20 -0800 Subject: Brute force debug for XFF issue --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index b572cb3..96821ec 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -200,6 +200,13 @@ namespace OpenSim.Server.Handlers.Simulation // We're behind a proxy Hashtable headers = (Hashtable)request["headers"]; + + foreach (object o in headers.Keys) + { + if (o != null) + m_log.DebugFormat("[XXX] {0}", o.ToString()); + } + if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) { m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers["X-Forwarded-For"]); -- cgit v1.1 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 ++++++++++++-------- .../Server/Handlers/Simulation/AgentHandlers.cs | 23 ++++++++++------------ 2 files changed, 23 insertions(+), 21 deletions(-) (limited to 'OpenSim/Server') 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); diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 96821ec..57672a8 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -200,24 +200,21 @@ namespace OpenSim.Server.Handlers.Simulation // We're behind a proxy Hashtable headers = (Hashtable)request["headers"]; + string xff = "X-Forwarded-For"; + if (headers.ContainsKey(xff.ToLower())) + xff = xff.ToLower(); - foreach (object o in headers.Keys) + if (!headers.ContainsKey(xff) || headers[xff] == null) { - if (o != null) - m_log.DebugFormat("[XXX] {0}", o.ToString()); + m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); + return Util.GetCallerIP(request); } - if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) - { - m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers["X-Forwarded-For"]); - - IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]); - if (ep != null) - return ep.Address.ToString(); - } - else - m_log.WarnFormat("[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