From f4bf581b96347b8d7f115eca74fa84a644eb729c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 26 Sep 2009 21:00:51 -0700 Subject: Moved all HG1 operations to HGGridConnector.cs and HypergridServerConnector.cs/HypergridServiceConnector.cs, away from Region.Communications and HGNetworkServersInfo. Fixed small bugs with hyperlinked regions' map positions. --- .../Handlers/Grid/HypergridServerConnector.cs | 111 +++++++++++++++++++-- 1 file changed, 103 insertions(+), 8 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs index d2e791b..c47f652 100644 --- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs +++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs @@ -38,6 +38,7 @@ using OpenSim.Framework.Servers.HttpServer; using OpenSim.Server.Handlers.Base; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenMetaverse; using log4net; using Nwc.XmlRpc; @@ -50,11 +51,25 @@ namespace OpenSim.Server.Handlers.Grid MethodBase.GetCurrentMethod().DeclaringType); private List m_RegionsOnSim = new List(); + private IHyperlinkService m_HyperlinkService; - public HypergridServiceInConnector(IConfigSource config, IHttpServer server) : + public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) : base(config, server) { + m_HyperlinkService = hyperService; server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); + server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false); + } + + public void AddRegion(GridRegion rinfo) + { + m_RegionsOnSim.Add(rinfo); + } + + public void RemoveRegion(GridRegion rinfo) + { + if (m_RegionsOnSim.Contains(rinfo)) + m_RegionsOnSim.Remove(rinfo); } /// @@ -99,15 +114,95 @@ namespace OpenSim.Server.Handlers.Grid return response; } - public void AddRegion(GridRegion rinfo) + /// + /// Received from other HGrid nodes when a user wants to teleport here. This call allows + /// the region to prepare for direct communication from the client. Sends back an empty + /// xmlrpc response on completion. + /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of + /// registering the user in the local user cache. + /// + /// + /// + public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient) { - m_RegionsOnSim.Add(rinfo); - } + Hashtable requestData = (Hashtable)request.Params[0]; + ForeignUserProfileData userData = new ForeignUserProfileData(); - public void RemoveRegion(GridRegion rinfo) - { - if (m_RegionsOnSim.Contains(rinfo)) - m_RegionsOnSim.Remove(rinfo); + userData.FirstName = (string)requestData["firstname"]; + userData.SurName = (string)requestData["lastname"]; + userData.ID = new UUID((string)requestData["agent_id"]); + UUID sessionID = new UUID((string)requestData["session_id"]); + userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"]), + (float)Convert.ToDecimal((string)requestData["startpos_y"]), + (float)Convert.ToDecimal((string)requestData["startpos_z"])); + + userData.UserServerURI = (string)requestData["userserver_id"]; + userData.UserAssetURI = (string)requestData["assetserver_id"]; + userData.UserInventoryURI = (string)requestData["inventoryserver_id"]; + + m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}", + userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID); + + ulong userRegionHandle = 0; + int userhomeinternalport = 0; + if (requestData.ContainsKey("region_uuid")) + { + UUID uuid = UUID.Zero; + UUID.TryParse((string)requestData["region_uuid"], out uuid); + userData.HomeRegionID = uuid; + userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); + userData.UserHomeAddress = (string)requestData["home_address"]; + userData.UserHomePort = (string)requestData["home_port"]; + userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]); + + m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress + + "; home_port: " + userData.UserHomePort); + } + else + m_log.WarnFormat("[HGrid]: User has no home region information"); + + XmlRpcResponse resp = new XmlRpcResponse(); + + // Let's check if someone is trying to get in with a stolen local identity. + // The need for this test is a consequence of not having truly global names :-/ + bool comingHome = false; + if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false) + { + m_log.WarnFormat("[HGrid]: Access denied to foreign user."); + Hashtable respdata = new Hashtable(); + respdata["success"] = "FALSE"; + respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled."; + resp.Value = respdata; + return resp; + } + + // Finally, everything looks ok + //m_log.Debug("XXX---- EVERYTHING OK ---XXX"); + + if (!comingHome) + { + // We don't do this if the user is coming to the home grid + GridRegion home = new GridRegion(); + home.RegionID = userData.HomeRegionID; + home.ExternalHostName = userData.UserHomeAddress; + home.HttpPort = Convert.ToUInt32(userData.UserHomePort); + uint x = 0, y = 0; + Utils.LongToUInts(userRegionHandle, out x, out y); + home.RegionLocX = (int)x; + home.RegionLocY = (int)y; + home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport); + + m_HyperlinkService.AcceptUser(userData, home); + } + // else the user is coming to a non-home region of the home grid + // We simply drop this user information altogether + + Hashtable respdata2 = new Hashtable(); + respdata2["success"] = "TRUE"; + resp.Value = respdata2; + + return resp; } + } } -- cgit v1.1