diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 95c3e6ca5f..d20f8c9b25 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Net.Sockets;
@@ -737,6 +738,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (methodWasFound)
{
xmlRprcRequest.Params.Add(request.Url); // Param[2]
+ xmlRprcRequest.Params.Add(request.Headers.Get("X-Forwarded-For")); // Param[3]
try
{
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index b5d025fbbd..2ac4eb1d14 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1495,5 +1495,33 @@ namespace OpenSim.Framework
}
}
+ ///
+ /// Gets the client IP address
+ ///
+ ///
+ ///
+ 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;
+ }
+
+
+
}
}
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
index 5bb529c89e..30dc65e5e8 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 67e83924d0..16c93c8e2c 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);
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index b74029787b..3f9bc19c9d 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -104,7 +104,7 @@ namespace OpenSim.Services.LLLoginService
m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty);
m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty);
m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
-
+
// These are required; the others aren't
if (accountService == string.Empty || authService == string.Empty)
throw new Exception("LoginService is missing service specifications");
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example
index 554d00f86b..9aaa46bf35 100644
--- a/bin/Robust.HG.ini.example
+++ b/bin/Robust.HG.ini.example
@@ -147,6 +147,9 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
WelcomeMessage = "Welcome, Avatar!"
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)
; CHANGE THIS
HomeURI = "http://127.0.0.1:8002"