Made the home agent handler check for xff if behind a proxy.
parent
934ae03d44
commit
37231e0941
|
@ -55,11 +55,13 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
private IUserAgentService m_UserAgentService;
|
||||
|
||||
private string m_LoginServerIP;
|
||||
private bool m_Proxy = false;
|
||||
|
||||
public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP)
|
||||
public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP, bool proxy)
|
||||
{
|
||||
m_UserAgentService = userAgentService;
|
||||
m_LoginServerIP = loginServerIP;
|
||||
m_Proxy = proxy;
|
||||
}
|
||||
|
||||
public Hashtable Handler(Hashtable request)
|
||||
|
@ -153,7 +155,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
string ip_str = args["client_ip"].ToString();
|
||||
try
|
||||
{
|
||||
string callerIP = Util.GetCallerIP(request);
|
||||
string callerIP = GetCallerIP(request);
|
||||
// Verify if this caller has authority to send the client IP
|
||||
if (callerIP == m_LoginServerIP)
|
||||
client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0);
|
||||
|
@ -198,6 +200,23 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
|
||||
}
|
||||
|
||||
private string GetCallerIP(Hashtable request)
|
||||
{
|
||||
if (!m_Proxy)
|
||||
return Util.GetCallerIP(request);
|
||||
|
||||
// We're behind a proxy
|
||||
Hashtable headers = (Hashtable)request["headers"];
|
||||
if (headers.ContainsKey("X-Forwarded-For") && headers["X-Forwarded-For"] != null)
|
||||
{
|
||||
IPEndPoint ep = Util.GetClientIPFromXFF((string)headers["X-Forwarded-For"]);
|
||||
if (ep != null)
|
||||
return ep.Address.ToString();
|
||||
}
|
||||
|
||||
// Oops
|
||||
return Util.GetCallerIP(request);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
throw new Exception("UserAgent server connector cannot proceed because of missing service");
|
||||
|
||||
string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1");
|
||||
bool proxy = gridConfig.GetBoolean("HasProxy", false);
|
||||
|
||||
server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
|
||||
server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
|
||||
|
@ -74,7 +75,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
|||
server.AddXmlRPCHandler("verify_client", VerifyClient, false);
|
||||
server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
|
||||
|
||||
server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP).Handler);
|
||||
server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler);
|
||||
}
|
||||
|
||||
public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
|
|
|
@ -224,6 +224,9 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
|||
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||
GatekeeperService = "OpenSim.Services.HypergridService.dll:GatekeeperService"
|
||||
|
||||
; If you run this user agent server behind a proxy, set this to true
|
||||
; HasProxy = true
|
||||
|
||||
;; If you separate the UserAgentService from the LoginService, set this to
|
||||
;; the IP address of the machine where your LoginService is
|
||||
;LoginServerIP = "127.0.0.1"
|
||||
|
|
Loading…
Reference in New Issue