diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Simulation/AgentHandlers.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 42ea296..26516ab 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -52,6 +52,8 @@ namespace OpenSim.Server.Handlers.Simulation | |||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | private ISimulationService m_SimulationService; | 53 | private ISimulationService m_SimulationService; |
54 | 54 | ||
55 | protected bool m_Proxy = false; | ||
56 | |||
55 | public AgentHandler() { } | 57 | public AgentHandler() { } |
56 | 58 | ||
57 | public AgentHandler(ISimulationService sim) | 59 | public AgentHandler(ISimulationService sim) |
@@ -184,13 +186,31 @@ namespace OpenSim.Server.Handlers.Simulation | |||
184 | resp["reason"] = OSD.FromString(reason); | 186 | resp["reason"] = OSD.FromString(reason); |
185 | resp["success"] = OSD.FromBoolean(result); | 187 | resp["success"] = OSD.FromBoolean(result); |
186 | // Let's also send out the IP address of the caller back to the caller (HG 1.5) | 188 | // Let's also send out the IP address of the caller back to the caller (HG 1.5) |
187 | resp["your_ip"] = OSD.FromString(Util.GetCallerIP(request)); | 189 | resp["your_ip"] = OSD.FromString(GetCallerIP(request)); |
188 | 190 | ||
189 | // TODO: add reason if not String.Empty? | 191 | // TODO: add reason if not String.Empty? |
190 | responsedata["int_response_code"] = HttpStatusCode.OK; | 192 | responsedata["int_response_code"] = HttpStatusCode.OK; |
191 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); | 193 | responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); |
192 | } | 194 | } |
193 | 195 | ||
196 | private string GetCallerIP(Hashtable request) | ||
197 | { | ||
198 | if (!m_Proxy) | ||
199 | return Util.GetCallerIP(request); | ||
200 | |||
201 | // We're behind a proxy | ||
202 | Hashtable headers = (Hashtable)request["headers"]; | ||
203 | if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null) | ||
204 | { | ||
205 | IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]); | ||
206 | if (ep != null) | ||
207 | return ep.Address.ToString(); | ||
208 | } | ||
209 | |||
210 | // Oops | ||
211 | return Util.GetCallerIP(request); | ||
212 | } | ||
213 | |||
194 | // subclasses can override this | 214 | // subclasses can override this |
195 | protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | 215 | protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) |
196 | { | 216 | { |