private void DumpUserData(ForeignUserProfileData userData) { m_log.Info(" ------------ User Data Dump ----------"); m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName); m_log.Info(" >> HomeID: " + userData.HomeRegionID); m_log.Info(" >> HomeHandle: " + userData.HomeRegion); m_log.Info(" >> HomeX: " + userData.HomeRegionX); m_log.Info(" >> HomeY: " + userData.HomeRegionY); m_log.Info(" >> UserServer: " + userData.UserServerURI); m_log.Info(" >> InvServer: " + userData.UserInventoryURI); m_log.Info(" >> AssetServer: " + userData.UserAssetURI); m_log.Info(" ------------ -------------- ----------"); }
/// <summary> /// 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. /// </summary> /// <param name="request"></param> /// <returns></returns> public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; ForeignUserProfileData userData = new ForeignUserProfileData(); userData.FirstName = (string)requestData["firstname"]; userData.SurName = (string)requestData["lastname"]; userData.ID = new UUID((string)requestData["agent_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"]; UUID rootID = UUID.Zero; UUID.TryParse((string)requestData["root_folder_id"], out rootID); userData.RootInventoryFolderID = rootID; UUID uuid = UUID.Zero; UUID.TryParse((string)requestData["region_uuid"], out uuid); userData.HomeRegionID = uuid; // not quite comfortable about this... ulong userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); //userData.HomeRegion = userRegionHandle; userData.UserHomeAddress = (string)requestData["home_address"]; userData.UserHomePort = (string)requestData["home_port"]; int userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]); userData.UserHomeRemotingPort = (string)requestData["home_remoting"]; m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}", userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID); m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress + "; home_port: " + userData.UserHomePort + "; remoting: " + userData.UserHomeRemotingPort); 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 :-/ CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(userData.ID); if ((uinfo != null) && !(uinfo.UserProfile is ForeignUserProfileData)) { m_log.WarnFormat("[HGrid]: Foreign user trying to get in with local identity. Access denied."); Hashtable respdata = new Hashtable(); respdata["success"] = "FALSE"; respdata["reason"] = "Foreign user has the same ID as a local user."; resp.Value = respdata; return(resp); } if (!RegionLoginsEnabled) { m_log.InfoFormat( "[HGrid]: Denying access for user {0} {1} because region login is currently disabled", userData.FirstName, userData.SurName); Hashtable respdata = new Hashtable(); respdata["success"] = "FALSE"; respdata["reason"] = "region login currently disabled"; resp.Value = respdata; } else { // Finally, everything looks ok //m_log.Debug("XXX---- EVERYTHING OK ---XXX"); // 1 - Preload the user data m_userProfileCache.PreloadUserCache(userData); if (m_knownRegions.ContainsKey(userData.ID)) { // This was left here when the user departed m_knownRegions.Remove(userData.ID); } // 2 - Load the region info into list of known regions RegionInfo rinfo = new RegionInfo(); rinfo.RegionID = userData.HomeRegionID; rinfo.ExternalHostName = userData.UserHomeAddress; rinfo.HttpPort = Convert.ToUInt32(userData.UserHomePort); rinfo.RemotingPort = Convert.ToUInt32(userData.UserHomeRemotingPort); rinfo.RegionID = userData.HomeRegionID; // X=0 on the map rinfo.RegionLocX = 0; rinfo.RegionLocY = (uint)(random.Next(0, Int32.MaxValue)); //(uint)m_knownRegions.Count; rinfo.regionSecret = userRegionHandle.ToString(); //m_log.Debug("XXX--- Here: handle = " + rinfo.regionSecret); try { rinfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport); } catch (Exception e) { m_log.Warn("[HGrid]: Exception while constructing internal endpoint: " + e); } rinfo.RemotingAddress = rinfo.ExternalEndPoint.Address.ToString(); //userData.UserHomeAddress; if (!IsComingHome(userData)) { // Change the user's home region here!!! userData.HomeRegion = rinfo.RegionHandle; } if (!m_knownRegions.ContainsKey(userData.ID)) { m_knownRegions.Add(userData.ID, rinfo); } // 3 - Send the reply Hashtable respdata = new Hashtable(); respdata["success"] = "TRUE"; resp.Value = respdata; DumpUserData(userData); DumpRegionData(rinfo); } return(resp); }
protected bool IsComingHome(ForeignUserProfileData userData) { return(userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI); }