Added XFF header processing. Untested, for lack of proxy.
parent
107052b23d
commit
8fc68c6d98
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
@ -737,6 +738,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
if (methodWasFound)
|
if (methodWasFound)
|
||||||
{
|
{
|
||||||
xmlRprcRequest.Params.Add(request.Url); // Param[2]
|
xmlRprcRequest.Params.Add(request.Url); // Param[2]
|
||||||
|
xmlRprcRequest.Params.Add(request.Headers.Get("X-Forwarded-For")); // Param[3]
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1495,5 +1495,33 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the client IP address
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xff"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IPEndPoint GetClientIPFromXFF(string xff)
|
||||||
|
{
|
||||||
|
if (xff == string.Empty)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
string[] parts = xff.Split(new char[] { ',' });
|
||||||
|
if (parts.Length > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new IPEndPoint(IPAddress.Parse(parts[0]), 0);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[UTIL]: Exception parsing XFF header {0}: {1}", xff, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,24 @@ namespace OpenSim.Server.Handlers.Login
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private ILoginService m_LocalService;
|
private ILoginService m_LocalService;
|
||||||
|
private bool m_Proxy;
|
||||||
|
|
||||||
public LLLoginHandlers(ILoginService service)
|
public LLLoginHandlers(ILoginService service, bool hasProxy)
|
||||||
{
|
{
|
||||||
m_LocalService = service;
|
m_LocalService = service;
|
||||||
|
m_Proxy = hasProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
|
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||||
{
|
{
|
||||||
Hashtable requestData = (Hashtable)request.Params[0];
|
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)
|
if (requestData != null)
|
||||||
{
|
{
|
||||||
|
@ -189,6 +198,7 @@ namespace OpenSim.Server.Handlers.Login
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace OpenSim.Server.Handlers.Login
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private ILoginService m_LoginService;
|
private ILoginService m_LoginService;
|
||||||
|
private bool m_Proxy;
|
||||||
|
|
||||||
public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
|
public LLLoginServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
|
||||||
base(config, server, String.Empty)
|
base(config, server, String.Empty)
|
||||||
|
@ -81,12 +82,14 @@ namespace OpenSim.Server.Handlers.Login
|
||||||
if (loginService == string.Empty)
|
if (loginService == string.Empty)
|
||||||
throw new Exception(String.Format("No LocalServiceModule for LoginService in config file"));
|
throw new Exception(String.Format("No LocalServiceModule for LoginService in config file"));
|
||||||
|
|
||||||
|
m_Proxy = serverConfig.GetBoolean("HasProxy", false);
|
||||||
|
|
||||||
return loginService;
|
return loginService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeHandlers(IHttpServer server)
|
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("login_to_simulator", loginHandlers.HandleXMLRPCLogin, false);
|
||||||
server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false);
|
server.AddXmlRPCHandler("set_login_level", loginHandlers.HandleXMLRPCSetLoginLevel, false);
|
||||||
server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin);
|
server.SetDefaultLLSDHandler(loginHandlers.HandleLLSDLogin);
|
||||||
|
|
|
@ -147,6 +147,9 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
||||||
WelcomeMessage = "Welcome, Avatar!"
|
WelcomeMessage = "Welcome, Avatar!"
|
||||||
AllowRemoteSetLoginLevel = "false"
|
AllowRemoteSetLoginLevel = "false"
|
||||||
|
|
||||||
|
; If you run this login server behind a proxy, set this to true
|
||||||
|
; HasProxy = true
|
||||||
|
|
||||||
; Defaults for the users, if none is specified in the useraccounts table entry (ServiceURLs)
|
; Defaults for the users, if none is specified in the useraccounts table entry (ServiceURLs)
|
||||||
; CHANGE THIS
|
; CHANGE THIS
|
||||||
HomeURI = "http://127.0.0.1:8002"
|
HomeURI = "http://127.0.0.1:8002"
|
||||||
|
|
Loading…
Reference in New Issue