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. --- OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | 12 +++++++++++- OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Handlers') diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs index 5bb529c..30dc65e 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs @@ -52,15 +52,24 @@ namespace OpenSim.Server.Handlers.Login private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private ILoginService m_LocalService; + private bool m_Proxy; - public LLLoginHandlers(ILoginService service) + public LLLoginHandlers(ILoginService service, bool hasProxy) { m_LocalService = service; + m_Proxy = hasProxy; } public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; + if (m_Proxy && request.Params[3] != null) + { + IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]); + if (ep != null) + // Bang! + remoteClient = ep; + } if (requestData != null) { @@ -189,6 +198,7 @@ namespace OpenSim.Server.Handlers.Login return map; } + } } diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs index 67e8392..16c93c8 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs @@ -43,6 +43,7 @@ namespace OpenSim.Server.Handlers.Login private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private ILoginService m_LoginService; + private bool m_Proxy; public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : base(config, server, String.Empty) @@ -81,12 +82,14 @@ namespace OpenSim.Server.Handlers.Login if (loginService == string.Empty) throw new Exception(String.Format("No LocalServiceModule for LoginService in config file")); + m_Proxy = serverConfig.GetBoolean("HasProxy", false); + return loginService; } private void InitializeHandlers(IHttpServer server) { - LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService); + LLLoginHandlers loginHandlers = new LLLoginHandlers(m_LoginService, m_Proxy); server.AddXmlRPCHandler("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false); server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false); server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin); -- cgit v1.1