mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -54,9 +54,12 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private IUserAgentService m_UserAgentService;
|
||||
|
||||
public HomeAgentHandler(IUserAgentService userAgentService)
|
||||
private string m_LoginServerIP;
|
||||
|
||||
public HomeAgentHandler(IUserAgentService userAgentService, string loginServerIP)
|
||||
{
|
||||
m_UserAgentService = userAgentService;
|
||||
m_LoginServerIP = loginServerIP;
|
||||
}
|
||||
|
||||
public Hashtable Handler(Hashtable request)
|
||||
@@ -120,6 +123,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
string regionname = string.Empty;
|
||||
string gatekeeper_host = string.Empty;
|
||||
int gatekeeper_port = 0;
|
||||
IPEndPoint client_ipaddress = null;
|
||||
|
||||
if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
|
||||
gatekeeper_host = args["gatekeeper_host"].AsString();
|
||||
@@ -144,6 +148,24 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
if (args.ContainsKey("destination_name") && args["destination_name"] != null)
|
||||
regionname = args["destination_name"].ToString();
|
||||
|
||||
if (args.ContainsKey("client_ip") && args["client_ip"] != null)
|
||||
{
|
||||
string ip_str = args["client_ip"].ToString();
|
||||
try
|
||||
{
|
||||
string callerIP = Util.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);
|
||||
else
|
||||
m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_log.DebugFormat("[HOME AGENT HANDLER]: Exception parsing client ip address from {0}", ip_str);
|
||||
}
|
||||
}
|
||||
|
||||
GridRegion destination = new GridRegion();
|
||||
destination.RegionID = uuid;
|
||||
destination.RegionLocX = x;
|
||||
@@ -166,7 +188,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
OSDMap resp = new OSDMap(2);
|
||||
string reason = String.Empty;
|
||||
|
||||
bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason);
|
||||
bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, client_ipaddress, out reason);
|
||||
|
||||
resp["reason"] = OSD.FromString(reason);
|
||||
resp["success"] = OSD.FromBoolean(result);
|
||||
|
||||
@@ -66,13 +66,15 @@ namespace OpenSim.Server.Handlers.Hypergrid
|
||||
if (m_HomeUsersService == null)
|
||||
throw new Exception("UserAgent server connector cannot proceed because of missing service");
|
||||
|
||||
string loginServerIP = gridConfig.GetString("LoginServerIP", "127.0.0.1");
|
||||
|
||||
server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
|
||||
server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
|
||||
server.AddXmlRPCHandler("verify_agent", VerifyAgent, false);
|
||||
server.AddXmlRPCHandler("verify_client", VerifyClient, false);
|
||||
server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
|
||||
|
||||
server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService).Handler);
|
||||
server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP).Handler);
|
||||
}
|
||||
|
||||
public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||
resp["reason"] = OSD.FromString(reason);
|
||||
resp["success"] = OSD.FromBoolean(result);
|
||||
// Let's also send out the IP address of the caller back to the caller (HG 1.5)
|
||||
resp["your_ip"] = OSD.FromString(GetCallerIP(request));
|
||||
resp["your_ip"] = OSD.FromString(Util.GetCallerIP(request));
|
||||
|
||||
// TODO: add reason if not String.Empty?
|
||||
responsedata["int_response_code"] = HttpStatusCode.OK;
|
||||
@@ -378,23 +378,6 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||
m_SimulationService.ReleaseAgent(regionID, id, "");
|
||||
}
|
||||
|
||||
private string GetCallerIP(Hashtable req)
|
||||
{
|
||||
if (req.ContainsKey("headers"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Hashtable headers = (Hashtable)req["headers"];
|
||||
if (headers.ContainsKey("remote_addr") && headers["remote_addr"] != null)
|
||||
return headers["remote_addr"].ToString();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[AGENT HANDLER]: exception in GetCallerIP: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user