From 9fd98368416ce9514e0926301a1fc20648d9ad59 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 4 Sep 2010 16:39:03 -0700 Subject: Make User Agent Service and Login Service separable. --- .../Server/Handlers/Hypergrid/HomeAgentHandlers.cs | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs') diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs index e50481a..d10d6fc 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs @@ -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); -- cgit v1.1