Added XFF header processing. Untested, for lack of proxy.

This commit is contained in:
Diva Canto
2010-09-03 17:18:53 -07:00
parent 107052b23d
commit 8fc68c6d98
6 changed files with 49 additions and 3 deletions

View File

@@ -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;
}
}
}

View File

@@ -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);