コード例 #1
0
        public SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val)
        {
            Scene sogScene = sog.m_scene;
            IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface<IEntityTransferModule>();

            Vector3 newpos = Vector3.Zero;
            OpenSim.Services.Interfaces.GridRegion destination = null;

            if (sog.RootPart.DIE_AT_EDGE)
            {               
                try
                {
                    sogScene.DeleteSceneObject(sog, false);
                }
                catch (Exception)
                {
                    m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border.");
                }
                return sog;
            }

            if (sog.RootPart.RETURN_AT_EDGE)
            {
                // We remove the object here
                try
                {
                    List<uint> localIDs = new List<uint>();
                    localIDs.Add(sog.RootPart.LocalId);
                    sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition,
                        "Returned at region cross");
                    sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero);                   
                }
                catch (Exception)
                {
                    m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border.");
                }
                return sog;
            }

            if (sog.m_rootPart.KeyframeMotion != null)
                sog.m_rootPart.KeyframeMotion.StartCrossingCheck();

            if (entityTransfer == null)
                return sog;

            destination = entityTransfer.GetObjectDestination(sog, val, out newpos);
            if (destination == null)
                return sog;

            if (sog.m_sittingAvatars.Count == 0)
            {
                entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, true);
                return sog;
            }

            string reason = String.Empty;
            EntityTransferContext ctx = new EntityTransferContext();

            foreach (ScenePresence av in sog.m_sittingAvatars)
            {
                // We need to cross these agents. First, let's find
                // out if any of them can't cross for some reason.
                // We have to deny the crossing entirely if any
                // of them are banned. Alternatively, we could
                // unsit banned agents....

                // We set the avatar position as being the object
                // position to get the region to send to
                if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, ctx, out reason))
                {
                    return sog;
                }
                m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
            }

            // We unparent the SP quietly so that it won't
            // be made to stand up

            List<avtocrossInfo> avsToCross = new List<avtocrossInfo>();

            foreach (ScenePresence av in sog.m_sittingAvatars)
            {
                byte cflags = 1;

                avtocrossInfo avinfo = new avtocrossInfo();
                SceneObjectPart parentPart = sogScene.GetSceneObjectPart(av.ParentID);
                if (parentPart != null)
                {
                    av.ParentUUID = parentPart.UUID;
                    if(parentPart.SitTargetAvatar == av.UUID)
                        cflags = 7; // low 3 bits set
                    else
                        cflags = 3;
                }

                // 1 is crossing
                // 2 is sitting
                // 4 is sitting at sittarget
                av.crossingFlags = cflags;

                avinfo.av = av;
                avinfo.ParentID = av.ParentID;
                avsToCross.Add(avinfo);

                av.PrevSitOffset = av.OffsetPosition;
                av.ParentID = 0;
            }

            if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, false))
            {
                foreach (avtocrossInfo avinfo in avsToCross)
                {
                    ScenePresence av = avinfo.av;
                    if (!av.IsInTransit) // just in case...
                    {
                        m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);

                        av.IsInTransit = true;

//                        CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync;
//                        d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d);
                        entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, av.Flying, ctx);
                        if (av.IsChildAgent)
                        {
                            // avatar crossed do some extra cleanup
                            if (av.ParentUUID != UUID.Zero)
                            {
                                av.ClearControls();
                                av.ParentPart = null;
                            }
                        }
                        else
                        {
                            // avatar cross failed we need do dedicated standUp
                            // part of it was done at CrossAgentToNewRegionAsync
                            // so for now just remove the sog controls
                            // this may need extra care 
                            av.UnRegisterSeatControls(sog.UUID);
                        }

                        av.ParentUUID = UUID.Zero;
                        // In any case
                        av.IsInTransit = false;
                        av.crossingFlags = 0;
                        m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname);
                    }
                    else
                        m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar already in transit {0} to {1}", av.Name, val);
                }
                avsToCross.Clear();
                sog.RemoveScriptInstances(true);
                sog.Clear();
                return sog;
            }
            else // cross failed, put avas back ??
            {
                foreach (avtocrossInfo avinfo in avsToCross)
                {
                    ScenePresence av = avinfo.av;
                    av.ParentUUID = UUID.Zero;
                    av.ParentID = avinfo.ParentID;
                    av.crossingFlags = 0;
                }
            }
            avsToCross.Clear();

            return sog;
        }
コード例 #2
0
ファイル: LLLoginService.cs プロジェクト: CassieEllen/opensim
        private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, TeleportFlags flags, out string reason)
        {
            EntityTransferContext ctx = new EntityTransferContext();

            if (!simConnector.QueryAccess(
                    region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
                return false;

            return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, ctx, out reason);
        }
コード例 #3
0
 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, EntityTransferContext ctx, out Vector3 newpos)
 {
     string r = String.Empty;
     return GetDestination(scene, agentID, pos, ctx, out newpos, out r);
 }
コード例 #4
0
        public ScenePresence CrossAsync(ScenePresence agent, bool isFlying)
        {
            uint x;
            uint y;
            Vector3 newpos;
            EntityTransferContext ctx = new EntityTransferContext();
            string failureReason;

            Vector3 pos = agent.AbsolutePosition + agent.Velocity;

            GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, pos,
                                                            ctx, out newpos, out failureReason);
            if (neighbourRegion == null)
            {
                if (failureReason != String.Empty)
                    agent.ControllingClient.SendAlertMessage(failureReason);
                return agent;
            }

//            agent.IsInTransit = true;

            CrossAgentToNewRegionAsync(agent, newpos, neighbourRegion, isFlying, ctx);
            agent.IsInTransit = false;
            return agent;
        }
コード例 #5
0
        public bool UpdateAgent(GridRegion destination, AgentData cAgentData, EntityTransferContext ctx)
        {
            if (destination == null)
                return false;

            // Try local first
            if (m_localBackend.IsLocalRegion(destination.RegionID))
                return m_localBackend.UpdateAgent(destination, cAgentData, ctx);

            return m_remoteConnector.UpdateAgent(destination, cAgentData, ctx);
        }
コード例 #6
0
        /**
         * Agent-related communications
         */

        public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, EntityTransferContext ctx, out string reason)
        {
            if (destination == null)
            {
                reason = "Given destination was null";
                m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination");
                return false;
            }

            // Try local first
            if (m_localBackend.CreateAgent(source, destination, aCircuit, teleportFlags, ctx, out reason))
                return true;

            // else do the remote thing
            if (!m_localBackend.IsLocalRegion(destination.RegionID))
            {
                return m_remoteConnector.CreateAgent(source, destination, aCircuit, teleportFlags, ctx, out reason);
            }
            return false;
        }
コード例 #7
0
        public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion,
            bool isFlying, EntityTransferContext ctx)
        {
            agent.ControllingClient.RequestClientInfo();

            string agentcaps;
            if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
            {
                m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
                                 neighbourRegion.RegionHandle);
                return;
            }

            // No turning back
            agent.IsChildAgent = true;

            string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);

            m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);

            Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0);

            if (m_eqModule != null)
            {
                m_eqModule.CrossRegion(
                    neighbourRegion.RegionHandle, pos + agent.Velocity, vel2 /* agent.Velocity */,
                    neighbourRegion.ExternalEndPoint,
                    capsPath, agent.UUID, agent.ControllingClient.SessionId,
                    neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
            }
            else
            {
                m_log.ErrorFormat("{0} Using old CrossRegion packet. Varregion will not work!!", LogHeader);
                agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos + agent.Velocity, agent.Velocity, neighbourRegion.ExternalEndPoint,
                                            capsPath);
            }

            // SUCCESS!
            m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);

            // Unlike a teleport, here we do not wait for the destination region to confirm the receipt.
            m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);

            agent.MakeChildAgent();

            // FIXME: Possibly this should occur lower down after other commands to close other agents,
            // but not sure yet what the side effects would be.
            m_entityTransferStateMachine.ResetFromTransit(agent.UUID);

            // now we have a child agent in this region. Request all interesting data about other (root) agents
            agent.SendOtherAgentsAvatarDataToClient();
            agent.SendOtherAgentsAppearanceToClient();

            // TODO: Check since what version this wasn't needed anymore. May be as old as 0.6
/*
            // Backwards compatibility. Best effort
            if (version == 0f)
            {
                m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one...");
                Thread.Sleep(3000); // wait a little now that we're not waiting for the callback
                CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
            }
*/
            // Next, let's close the child agent connections that are too far away.
            uint neighbourx;
            uint neighboury;
            Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury);

            agent.CloseChildAgents(neighbourx, neighboury);

            AgentHasMovedAway(agent, false);

            // the user may change their profile information in other region,
            // so the userinfo in UserProfileCache is not reliable any more, delete it
            // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
//            if (agent.Scene.NeedSceneCacheClear(agent.UUID))
//            {
//                m_log.DebugFormat(
//                    "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
//            }

            //m_log.Debug("AFTER CROSS");
            //Scene.DumpChildrenSeeds(UUID);
            //DumpKnownRegions();

            return;
        }
コード例 #8
0
        public bool Cross(ScenePresence agent, bool isFlying)
        {
            Vector3 newpos;
            EntityTransferContext ctx = new EntityTransferContext();
            string failureReason;

            GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition,
                                                            ctx, out newpos, out failureReason);
            if (neighbourRegion == null)
            {
                agent.ControllingClient.SendAlertMessage(failureReason);
                return false;
            }

            agent.IsInTransit = true;

            CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
            d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, ctx, CrossAgentToNewRegionCompleted, d);

            Scene.EventManager.TriggerCrossAgentToNewRegion(agent, isFlying, neighbourRegion);

            return true;
        }
コード例 #9
0
        public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion destination, out string reason)
        {
            reason = string.Empty;

            string authURL = string.Empty;
            if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
                authURL = aCircuit.ServiceURLs["HomeURI"].ToString();

            m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9}, Teleport Flags: {10}. From region {11}",
                aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionID,
                aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, (TeleportFlags)aCircuit.teleportFlags,
                (source == null) ? "Unknown" : string.Format("{0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI));

            string curViewer = Util.GetViewerName(aCircuit);

            //
            // Check client
            //
            if (m_AllowedClients != string.Empty)
            {
                Regex arx = new Regex(m_AllowedClients);
                Match am = arx.Match(curViewer);

                if (!am.Success)
                {
                    m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
                    return false;
                }
            }

            if (m_DeniedClients != string.Empty)
            {
                Regex drx = new Regex(m_DeniedClients);
                Match dm = drx.Match(curViewer);

                if (dm.Success)
                {
                    m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
                    return false;
                }
            }

            //
            // Authenticate the user
            //
            if (!Authenticate(aCircuit))
            {
                reason = "Unable to verify identity";
                m_log.InfoFormat("[GATEKEEPER SERVICE]: Unable to verify identity of agent {0} {1}. Refusing service.", aCircuit.firstname, aCircuit.lastname);
                return false;
            }
            m_log.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} {1} @ {2}", aCircuit.firstname, aCircuit.lastname, authURL);
            
            //
            // Check for impersonations
            //
            UserAccount account = null;
            if (m_UserAccountService != null)
            {
                // Check to see if we have a local user with that UUID
                account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
                if (account != null)
                {
                    // Make sure this is the user coming home, and not a foreign user with same UUID as a local user
                    if (m_UserAgentService != null)
                    {
                        if (!m_UserAgentService.IsAgentComingHome(aCircuit.SessionID, m_ExternalName))
                        {
                            // Can't do, sorry
                            reason = "Unauthorized";
                            m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.",
                                aCircuit.firstname, aCircuit.lastname);
                            return false;

                        }
                    }
                }
            }

            //
            // Foreign agents allowed? Exceptions?
            //
            if (account == null)
            {
                bool allowed = m_ForeignAgentsAllowed;

                if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions))
                    allowed = false;

                if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions))
                    allowed = true;

                if (!allowed)
                {
                    reason = "Destination does not allow visitors from your world";
                    m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1} @ {2}. Refusing service.",
                        aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs["HomeURI"]);
                    return false;
                }
            }

            //
            // Is the user banned?
            // This uses a Ban service that's more powerful than the configs
            //
            string uui = (account != null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit));
            if (m_BansService != null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL))
            {
                reason = "You are banned from this world";
                m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: user {0} is banned", uui);
                return false;
            }

            m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name);

            bool isFirstLogin = false;
            //
            // Login the presence, if it's not there yet (by the login service)
            //
            PresenceInfo presence = m_PresenceService.GetAgent(aCircuit.SessionID);
            if (presence != null) // it has been placed there by the login service
                isFirstLogin = true;

            else
            {
                if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
                {
                    reason = "Unable to login presence";
                    m_log.InfoFormat("[GATEKEEPER SERVICE]: Presence login failed for foreign agent {0} {1}. Refusing service.",
                        aCircuit.firstname, aCircuit.lastname);
                    return false;
                }

                m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);

                // Also login foreigners with GridUser service
                if (m_GridUserService != null && account == null)
                {
                    string userId = aCircuit.AgentID.ToString();
                    string first = aCircuit.firstname, last = aCircuit.lastname;
                    if (last.StartsWith("@"))
                    {
                        string[] parts = aCircuit.firstname.Split('.');
                        if (parts.Length >= 2)
                        {
                            first = parts[0];
                            last = parts[1];
                        }
                    }

                    userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
                    m_GridUserService.LoggedIn(userId);
                }
            }

            //
            // Get the region
            //
            destination = m_GridService.GetRegionByUUID(m_ScopeID, destination.RegionID);
            if (destination == null)
            {
                reason = "Destination region not found";
                return false;
            }

            m_log.DebugFormat(
                "[GATEKEEPER SERVICE]: Destination {0} is ok for {1}", destination.RegionName, aCircuit.Name);

            //
            // Adjust the visible name
            //
            if (account != null)
            {
                aCircuit.firstname = account.FirstName;
                aCircuit.lastname = account.LastName;
            }
            if (account == null)
            {
                if (!aCircuit.lastname.StartsWith("@"))
                    aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname;
                try
                {
                    Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString());
                    aCircuit.lastname = "@" + uri.Authority;
                }
                catch
                {
                    m_log.WarnFormat("[GATEKEEPER SERVICE]: Malformed HomeURI (this should never happen): {0}", aCircuit.ServiceURLs["HomeURI"]);
                    aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString();
                }
            }

            //
            // Finally launch the agent at the destination
            //
            Constants.TeleportFlags loginFlag = isFirstLogin ? Constants.TeleportFlags.ViaLogin : Constants.TeleportFlags.ViaHGLogin;

            // Preserve our TeleportFlags we have gathered so-far
            loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags;

            m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0}, Teleport Flags: {1}", aCircuit.Name, loginFlag);

            EntityTransferContext ctx = new EntityTransferContext();

            if (!m_SimulationService.QueryAccess(
                destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(), 
                true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
                return false;

            return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason);
        }
コード例 #10
0
        public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> features, EntityTransferContext ctx, out string reason)
        {
            reason = "Communications failure";

            if (destination == null)
                return false;

            // Try local first
            if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, features, ctx, out reason))
                return true;

            // else do the remote thing
            if (!m_localBackend.IsLocalRegion(destination.RegionID))
                return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, features, ctx, out reason);

            return false;
        }
コード例 #11
0
        public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> features, EntityTransferContext ctx, out string reason)
        {
            reason = "Communications failure";
            if (destination == null)
                return false;

            if (m_scenes.ContainsKey(destination.RegionID))
            {
            //                    m_log.DebugFormat(
            //                        "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
            //                        s.RegionInfo.RegionName, destination.RegionHandle);
                uint sizeX = m_scenes[destination.RegionID].RegionInfo.RegionSizeX;
                uint sizeY = m_scenes[destination.RegionID].RegionInfo.RegionSizeY;

                // Var regions here, and the requesting simulator is in an older version.
                // We will forbide this, because it crashes the viewers
                if (ctx.OutboundVersion < 0.3f && (sizeX != 256 || sizeY != 256))
                {
                    reason = "Destination is a variable-sized region, and source is an old simulator. Consider upgrading.";
                    m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Request to access this variable-sized region from older simulator was denied");
                    return false;

                }

                return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, features, out reason);
            }

            //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
            return false;
        }
コード例 #12
0
ファイル: OSSL_Api.cs プロジェクト: nebadon2025/opensimulator
        protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
        {
            IAvatarFactoryModule appearanceModule = World.RequestModuleInterface<IAvatarFactoryModule>();

            if (appearanceModule != null)
            {
                appearanceModule.SaveBakedTextures(sp.UUID);
                EntityTransferContext ctx = new EntityTransferContext();
                OSDMap appearancePacked = sp.Appearance.Pack(ctx);

                TaskInventoryItem item
                    = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);

                return new LSL_Key(item.AssetID.ToString());
            }
            else
            {
                return new LSL_Key(UUID.Zero.ToString());
            }
        }
コード例 #13
0
        public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason)
        {
            string tmp = String.Empty;

            return(CreateAgent(source, destination, aCircuit, flags, ctx, out tmp, out reason));
        }