Make User Agent Service and Login Service separable.
parent
c0b16f09bf
commit
9fd9836841
|
@ -1521,7 +1521,23 @@ namespace OpenSim.Framework
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static 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("[UTIL]: exception in GetCallerIP: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -179,7 +179,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;
|
||||
|
@ -355,23 +355,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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,16 +70,29 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
|||
|
||||
public UserAgentServiceConnector(IConfigSource config)
|
||||
{
|
||||
IConfig serviceConfig = config.Configs["UserAgentService"];
|
||||
if (serviceConfig == null)
|
||||
{
|
||||
m_log.Error("[USER AGENT CONNECTOR]: UserAgentService missing from ini");
|
||||
throw new Exception("UserAgent connector init error");
|
||||
}
|
||||
|
||||
string serviceURI = serviceConfig.GetString("UserAgentServerURI",
|
||||
String.Empty);
|
||||
|
||||
if (serviceURI == String.Empty)
|
||||
{
|
||||
m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService");
|
||||
throw new Exception("UserAgent connector init error");
|
||||
}
|
||||
m_ServerURL = serviceURI;
|
||||
|
||||
m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
|
||||
}
|
||||
|
||||
public bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint ipaddress, out string reason)
|
||||
{
|
||||
// not available over remote calls
|
||||
reason = "Method not available over remote calls";
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
|
||||
// The Login service calls this interface with a non-null [client] ipaddress
|
||||
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason)
|
||||
{
|
||||
reason = String.Empty;
|
||||
|
||||
|
@ -90,7 +103,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
|||
return false;
|
||||
}
|
||||
|
||||
string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/";
|
||||
string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/";
|
||||
|
||||
Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri);
|
||||
|
||||
|
@ -102,7 +115,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
|||
//AgentCreateRequest.Headers.Add("Authorization", authKey);
|
||||
|
||||
// Fill it in
|
||||
OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination);
|
||||
OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
|
||||
|
||||
string strBuffer = "";
|
||||
byte[] buffer = new byte[1];
|
||||
|
@ -199,7 +212,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
|||
|
||||
}
|
||||
|
||||
protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination)
|
||||
|
||||
// The simulators call this interface
|
||||
public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
|
||||
{
|
||||
return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason);
|
||||
}
|
||||
|
||||
protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
|
||||
{
|
||||
OSDMap args = null;
|
||||
try
|
||||
|
@ -217,6 +237,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
|||
args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
|
||||
args["destination_name"] = OSD.FromString(destination.RegionName);
|
||||
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
|
||||
if (ipaddress != null)
|
||||
args["client_ip"] = OSD.FromString(ipaddress.Address.ToString());
|
||||
|
||||
return args;
|
||||
}
|
||||
|
|
|
@ -220,6 +220,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
|||
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||
GatekeeperService = "OpenSim.Services.HypergridService.dll:GatekeeperService"
|
||||
|
||||
;; 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"
|
||||
|
||||
; * The interface that local users get when they are in other grids.
|
||||
; * This restricts the inventory operations while in other grids.
|
||||
; * Still not completely safe, especially if users perform inventory operations
|
||||
|
|
Loading…
Reference in New Issue