diff options
author | Diva Canto | 2011-01-17 11:37:39 -0800 |
---|---|---|
committer | Diva Canto | 2011-01-17 11:37:39 -0800 |
commit | 479d72ac975fd34f43d76c0ab20f869cb07fb6fc (patch) | |
tree | 1b1dd2d12e932d7fb8d94ad4d79164e1e5cd5ddd | |
parent | Brute force debug for XFF issue (diff) | |
download | opensim-SC-479d72ac975fd34f43d76c0ab20f869cb07fb6fc.zip opensim-SC-479d72ac975fd34f43d76c0ab20f869cb07fb6fc.tar.gz opensim-SC-479d72ac975fd34f43d76c0ab20f869cb07fb6fc.tar.bz2 opensim-SC-479d72ac975fd34f43d76c0ab20f869cb07fb6fc.tar.xz |
Account for some component along the way lower-casing the HTTP header keys. (XFF header issue)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs | 21 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 23 |
2 files changed, 23 insertions, 21 deletions
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 | |||
215 | 215 | ||
216 | // We're behind a proxy | 216 | // We're behind a proxy |
217 | Hashtable headers = (Hashtable)request["headers"]; | 217 | Hashtable headers = (Hashtable)request["headers"]; |
218 | if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) | 218 | string xff = "X-Forwarded-For"; |
219 | { | 219 | if (headers.ContainsKey(xff.ToLower())) |
220 | m_log.DebugFormat("[HOME AGENT HANDLER]: XFF is {0}", headers["X-Forwarded-For"]); | 220 | xff = xff.ToLower(); |
221 | 221 | ||
222 | IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]); | 222 | if (!headers.ContainsKey(xff) || headers[xff] == null) |
223 | if (ep != null) | 223 | { |
224 | return ep.Address.ToString(); | 224 | m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); |
225 | return Util.GetCallerIP(request); | ||
225 | } | 226 | } |
226 | else | 227 | |
227 | m_log.WarnFormat("[HOME AGENT HANDLER]: No XFF header"); | 228 | m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]); |
229 | |||
230 | IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]); | ||
231 | if (ep != null) | ||
232 | return ep.Address.ToString(); | ||
228 | 233 | ||
229 | // Oops | 234 | // Oops |
230 | return Util.GetCallerIP(request); | 235 | 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 | |||
200 | 200 | ||
201 | // We're behind a proxy | 201 | // We're behind a proxy |
202 | Hashtable headers = (Hashtable)request["headers"]; | 202 | Hashtable headers = (Hashtable)request["headers"]; |
203 | string xff = "X-Forwarded-For"; | ||
204 | if (headers.ContainsKey(xff.ToLower())) | ||
205 | xff = xff.ToLower(); | ||
203 | 206 | ||
204 | foreach (object o in headers.Keys) | 207 | if (!headers.ContainsKey(xff) || headers[xff] == null) |
205 | { | 208 | { |
206 | if (o != null) | 209 | m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); |
207 | m_log.DebugFormat("[XXX] {0}", o.ToString()); | 210 | return Util.GetCallerIP(request); |
208 | } | 211 | } |
209 | 212 | ||
210 | if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) | 213 | m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]); |
211 | { | ||
212 | m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers["X-Forwarded-For"]); | ||
213 | |||
214 | IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]); | ||
215 | if (ep != null) | ||
216 | return ep.Address.ToString(); | ||
217 | } | ||
218 | else | ||
219 | m_log.WarnFormat("[AGENT HANDLER]: No XFF header"); | ||
220 | 214 | ||
215 | IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]); | ||
216 | if (ep != null) | ||
217 | return ep.Address.ToString(); | ||
221 | 218 | ||
222 | // Oops | 219 | // Oops |
223 | return Util.GetCallerIP(request); | 220 | return Util.GetCallerIP(request); |