Exemplo n.º 1
0
 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(" >> UserServer: " + userData.UserServerURI);
     m_log.Info(" >> InvServer: " + userData.UserInventoryURI);
     m_log.Info(" >> AssetServer: " + userData.UserAssetURI);
     m_log.Info(" ------------ -------------- ----------");
 }
Exemplo n.º 2
0
 protected bool IsComingHome(ForeignUserProfileData userData)
 {
     return (userData.UserServerURI == LocalUserServerURI);
 }
Exemplo n.º 3
0
        public void AcceptUser(ForeignUserProfileData user, GridRegion home)
        {
            m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user);
            ulong realHandle = home.RegionHandle;
            // Change the local coordinates
            // X=0 on the map
            home.RegionLocX = 0;
            home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize;
            
            AddHyperlinkHomeRegion(user.ID, home, realHandle);

            DumpUserData(user);
            DumpRegionData(home);

        }
        /// <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"]);
            UUID sessionID = new UUID((string)requestData["session_id"]);
            userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"], Culture.NumberFormatInfo),
                                  (float)Convert.ToDecimal((string)requestData["startpos_y"], Culture.NumberFormatInfo),
                                  (float)Convert.ToDecimal((string)requestData["startpos_z"], Culture.NumberFormatInfo));

            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;
        }
Exemplo n.º 5
0
 protected bool IsComingHome(ForeignUserProfileData userData)
 {
     return (userData.UserServerURI == HGNetworkServersInfo.Singleton.LocalUserServerURI);
 }
Exemplo n.º 6
0
        /// <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;
        }