Inheritance: Universe.Framework.Modules.IDataTransferable
コード例 #1
0
 /// <summary>
 ///     Add information about a new circuit so that later on we can authenticate a new client session.
 /// </summary>
 /// <param name="circuitCode"></param>
 /// <param name="agentData"></param>
 public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
 {
     lock (AgentCircuits)
     {
         AgentCircuits[circuitCode] = agentData;
     }
 }
コード例 #2
0
        public bool CreateAgent (GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
        {
            response = null;
            if (destination == null) {
                response = new CreateAgentResponse ();
                response.Reason = "Could not connect to destination";
                response.Success = false;
                return false;
            }
            CreateAgentRequest request = new CreateAgentRequest ();
            request.CircuitData = aCircuit;
            request.Destination = destination;
            request.TeleportFlags = teleportFlags;

            AutoResetEvent resetEvent = new AutoResetEvent (false);
            OSDMap result = null;
            MainConsole.Instance.DebugFormat ("[SimulationServiceConnector]: Sending Create Agent to " + destination.ServerURI);
            m_syncMessagePoster.Get (destination.ServerURI, request.ToOSD (), osdresp => {
                result = osdresp;
                resetEvent.Set ();
            });
            bool success = resetEvent.WaitOne (10000);
            if (!success || result == null) {
                response = new CreateAgentResponse ();
                response.Reason = "Could not connect to destination";
                response.Success = false;
                return false;
            }

            response = new CreateAgentResponse ();
            response.FromOSD (result);

            return response.Success;
        }
        /// <summary>
        /// Agent-related communications
        /// </summary>
        public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
        {
            response = new CreateAgentResponse();
            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (destination == null || Scene == null)
            {
                response.Reason = "Given destination was null";
                response.Success = false;
                return false;
            }

            if (Scene.RegionInfo.RegionID != destination.RegionID)
            {
                response.Reason = "Did not find region " + destination.RegionName;;
                response.Success = false;
                return false;
            }
            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                return transferModule.NewUserConnection(Scene, aCircuit, teleportFlags, out response);

            response.Reason = "Did not find region " + destination.RegionName;
            response.Success = false;
            return false;
        }
コード例 #4
0
        public static OSDMap ArrivedAtDestination(UUID AgentID, int DrawDistance, AgentCircuitData circuit, UUID requestingRegion)
        {
            OSDMap llsdBody = new OSDMap
                                  {
                                      {"AgentID", AgentID},
                                      {"DrawDistance", DrawDistance},
                                      {"Circuit", circuit.ToOSD()}
                                  };

            return buildEvent("ArrivedAtDestination", llsdBody, AgentID, requestingRegion);
        }
コード例 #5
0
 public bool IsAuthorizedForRegion(GridRegion region, AgentCircuitData agent, bool isRootAgent, out string reason)
 {
     ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
     IScene scene = manager == null ? null : manager.Scenes.Find((s) => s.RegionInfo.RegionID == region.RegionID);
     if (scene != null)
     {
         //Found the region, check permissions
         return scene.Permissions.AllowedIncomingAgent(agent, isRootAgent, out reason);
     }
     reason = "Not Authorized as region does not exist.";
     return false;
 }
コード例 #6
0
        public virtual bool CrossAgent(GridRegion crossingRegion, Vector3 pos,
            Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, UUID agentID,
            UUID requestingRegion, out string reason)
        {
            IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);
            IRegionClientCapsService requestingRegionCaps = clientCaps.GetCapsService(requestingRegion);
            ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>();
            IGridService GridService = m_registry.RequestModuleInterface<IGridService>();
            try
            {
                if (SimulationService != null && GridService != null)
                {
                    //Set the user in transit so that we block duplicate tps and reset any cancelations
                    if (!SetUserInTransit(agentID))
                    {
                        reason = "Already in a teleport";
                        SimulationService.FailedToTeleportAgent(requestingRegionCaps.Region, crossingRegion.RegionID,
                            agentID, reason, true);
                        return false;
                    }

                    bool result = false;

                    IRegionClientCapsService otherRegion = clientCaps.GetCapsService(crossingRegion.RegionID);

                    if (otherRegion == null)
                    {
                        //If we failed before, attempt again
                        if (!InformClientOfNeighbor(agentID, requestingRegion, circuit, ref crossingRegion, 0,
                                cAgent, out reason))
                        {
                            ResetFromTransit(agentID);
                            SimulationService.FailedToTeleportAgent(requestingRegionCaps.Region,
                                crossingRegion.RegionID,
                                agentID, reason, true);
                            return false;
                        }

                        otherRegion = clientCaps.GetCapsService(crossingRegion.RegionID);
                    }

                    //We need to get it from the grid service again so that we can get the simulation service urls correctly
                    // as regions don't get that info
                    crossingRegion = GridService.GetRegionByUUID(clientCaps.AccountInfo.AllScopeIDs,
                        crossingRegion.RegionID);
                    cAgent.IsCrossing = true;

                    if (!SimulationService.UpdateAgent(crossingRegion, cAgent))
                    {
                        MainConsole.Instance.Warn("[Agent Processing]: Failed to cross agent " + agentID +
                        " because region did not accept it. Resetting.");
                        reason = "Failed to update an agent";
                        SimulationService.FailedToTeleportAgent(requestingRegionCaps.Region, crossingRegion.RegionID,
                            agentID, reason, true);
                    }
                    else
                    {
                        IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>();

                        //Add this for the viewer, but not for the sim, seems to make the viewer happier
                        int XOffset = crossingRegion.RegionLocX - requestingRegionCaps.RegionX;
                        pos.X += XOffset;

                        int YOffset = crossingRegion.RegionLocY - requestingRegionCaps.RegionY;
                        pos.Y += YOffset;

                        //Tell the client about the transfer
                        EQService.CrossRegion(crossingRegion.RegionHandle, pos, velocity,
                            otherRegion.LoopbackRegionIP,
                            otherRegion.CircuitData.RegionUDPPort,
                            otherRegion.CapsUrl,
                            agentID,
                            circuit.SessionID,
                            crossingRegion.RegionSizeX,
                            crossingRegion.RegionSizeY,
                            requestingRegionCaps.Region.RegionID);

                        result = WaitForCallback(agentID);

                        if (!result)
                        {
                            MainConsole.Instance.Warn("[AgentProcessing]: Callback never came in crossing agent " +
                            circuit.AgentID +
                            ". Resetting.");
                            reason = "Crossing timed out";
                            SimulationService.FailedToTeleportAgent(requestingRegionCaps.Region, crossingRegion.RegionID,
                                agentID, reason, true);
                        }
                        else
                        {
                            // Next, let's close the child agent connections that are too far away.
                            //Fix the root agent status
                            otherRegion.RootAgent = true;
                            requestingRegionCaps.RootAgent = false;

                            CloseNeighborAgents(requestingRegionCaps.Region, crossingRegion, agentID);
                            reason = "";
                            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();

                            if (agentInfoService != null)
                                agentInfoService.SetLastPosition(agentID.ToString(), crossingRegion.RegionID,
                                    pos, Vector3.Zero, crossingRegion.ServerURI);
                            SimulationService.MakeChildAgent(agentID, requestingRegionCaps.Region, crossingRegion, true);
                        }
                    }

                    //All done
                    ResetFromTransit(agentID);
                    return result;
                }

                reason = "Could not find the SimulationService";
            }

            catch (Exception ex)
            {
                MainConsole.Instance.WarnFormat("[Agent Processing]: Failed to cross an agent into a new region. {0}", ex);
                if (SimulationService != null)
                    SimulationService.FailedToTeleportAgent(requestingRegionCaps.Region, crossingRegion.RegionID,
                        agentID, "Exception occurred", true);
            }

            ResetFromTransit(agentID);
            reason = "Exception occurred";
            return false;
        }
コード例 #7
0
        public virtual void EnableChildAgents(UUID agentID, UUID requestingRegion, int drawDistance, AgentCircuitData circuit)
        {
            Util.FireAndForget(o =>
            {
                int count = 0;
                IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);
                GridRegion ourRegion =
                    m_registry.RequestModuleInterface<IGridService>().GetRegionByUUID(
                        clientCaps.AccountInfo.AllScopeIDs, requestingRegion);

                if (ourRegion == null)
                {
                    MainConsole.Instance.Info(
                        "[Agent Processing]: Failed to inform neighbors about new agent, could not find our region.");
                    return;
                }

                List<GridRegion> neighbors = GetNeighbors(clientCaps.AccountInfo.AllScopeIDs, ourRegion, drawDistance);
                if (neighbors != null)
                {
                    //Fix the root agents dd
                    foreach (GridRegion neighbor in neighbors)
                    {
                        if (neighbor.RegionID != requestingRegion && clientCaps.GetCapsService(neighbor.RegionID) == null)
                        {
                            string reason;
                            AgentCircuitData regionCircuitData = clientCaps.GetRootCapsService().CircuitData.Copy();
                            GridRegion nCopy = neighbor;
                            regionCircuitData.IsChildAgent = true;
                            InformClientOfNeighbor(agentID, requestingRegion, regionCircuitData,
                                ref nCopy,
                                (uint)TeleportFlags.Default, null, out reason);
                        }

                        count++;
                    }
                }
            });
        }
コード例 #8
0
 public override void FromOSD(OSDMap map)
 {
     Success = map["Success"];
     if (map.ContainsKey("AgentData"))
     {
         AgentData = new AgentData();
         AgentData.FromOSD((OSDMap)map["AgentData"]);
     }
     if (map.ContainsKey("CircuitData"))
     {
         CircuitData = new AgentCircuitData();
         CircuitData.FromOSD((OSDMap)map["CircuitData"]);
     }
 }
コード例 #9
0
        bool CreateAgent(GridRegion region, IRegionClientCapsService regionCaps, ref AgentCircuitData aCircuit,
            ISimulationService SimulationService, List<UUID> friendsToInform, out CreateAgentResponse response)
        {
            CachedUserInfo info = new CachedUserInfo();
            IAgentConnector con = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector>();

            if (con != null)
                info.AgentInfo = con.GetAgent(aCircuit.AgentID);

            if (regionCaps != null)
                info.UserAccount = regionCaps.ClientCaps.AccountInfo;

            IGroupsServiceConnector groupsConn = Framework.Utilities.DataManager.RequestPlugin<IGroupsServiceConnector>();

            if (groupsConn != null)
            {
                info.ActiveGroup = groupsConn.GetGroupMembershipData(aCircuit.AgentID, UUID.Zero, aCircuit.AgentID);
                info.GroupMemberships = groupsConn.GetAgentGroupMemberships(aCircuit.AgentID, aCircuit.AgentID);
            }

            IOfflineMessagesConnector offlineMessConn =
                Framework.Utilities.DataManager.RequestPlugin<IOfflineMessagesConnector>();

            if (offlineMessConn != null)
                info.OfflineMessages = offlineMessConn.GetOfflineMessages(aCircuit.AgentID);

            IMuteListConnector muteConn = Framework.Utilities.DataManager.RequestPlugin<IMuteListConnector>();

            if (muteConn != null)
                info.MuteList = muteConn.GetMuteList(aCircuit.AgentID);

            IAvatarService avatarService = m_registry.RequestModuleInterface<IAvatarService>();

            if (avatarService != null)
                info.Appearance = avatarService.GetAppearance(aCircuit.AgentID);

            info.FriendOnlineStatuses = friendsToInform;
            IFriendsService friendsService = m_registry.RequestModuleInterface<IFriendsService>();

            if (friendsService != null)
                info.Friends = friendsService.GetFriends(aCircuit.AgentID);

            aCircuit.CachedUserInfo = info;
            return SimulationService.CreateAgent(region, aCircuit, aCircuit.TeleportFlags, out response);
        }
コード例 #10
0
        /// <summary>
        ///     Do the work necessary to initiate a new user connection for a particular scene.
        ///     At the moment, this consists of setting up the caps infrastructure
        ///     The return bool should allow for connections to be refused, but as not all calling paths
        ///     take proper notice of it let, we allowed banned users in still.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="agent">CircuitData of the agent who is connecting</param>
        /// <param name="response">
        ///     Outputs the reason for the false response on this string,
        ///     If the agent was accepted, this will be the Caps SEED for the region
        /// </param>
        /// <param name="teleportFlags"></param>
        /// <returns>
        ///     True if the region accepts this agent.  False if it does not.  False will
        ///     also return a rsponse.
        /// </returns>
        public bool NewUserConnection (IScene scene, AgentCircuitData agent, uint teleportFlags, out CreateAgentResponse response)
        {
            response = new CreateAgentResponse ();
            response.RequestedUDPPort = scene.RegionInfo.RegionPort;
            IScenePresence sp = scene.GetScenePresence (agent.AgentID);

            // Don't disable this log message - it's too helpful
            MainConsole.Instance.TraceFormat (
                "[Connection begin]: Region {0} told of incoming {1} agent {2} (circuit code {3}, teleportflags {4})",
                scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root", agent.AgentID,
                agent.CircuitCode, teleportFlags);

            CacheUserInfo (scene, agent.CachedUserInfo);

            string reason;
            if (!AuthorizeUser (scene, agent, out reason)) {
                response.Reason = reason;
                response.Success = false;
                return false;
            }

            if (sp != null && !sp.IsChildAgent) {
                // We have a zombie from a crashed session. 
                // Or the same user is trying to be root twice here, won't work.
                // Kill it.
                MainConsole.Instance.InfoFormat ("[Scene]: Zombie scene presence detected for {0} in {1}",
                                                 agent.AgentID, scene.RegionInfo.RegionName);
                //Tell everyone about it
                scene.UniverseEventManager.FireGenericEventHandler ("AgentIsAZombie", sp.UUID);
                //Send the killing message (DisableSimulator)
                scene.RemoveAgent (sp, true);
                sp = null;
            }

            response.CapsURIs = scene.EventManager.TriggerOnRegisterCaps (agent.AgentID);
            response.OurIPForClient = MainServer.Instance.HostName;

            scene.UniverseEventManager.FireGenericEventHandler ("NewUserConnection", agent);

            //Add the circuit at the end
            scene.AuthenticateHandler.AddNewCircuit (agent.CircuitCode, agent);

            MainConsole.Instance.InfoFormat (
                "[Connection begin]: Region {0} authenticated and authorized incoming {1} agent {2} (circuit code {3})",
                scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root", agent.AgentID,
                agent.CircuitCode);

            response.Success = true;
            return true;
        }
コード例 #11
0
        public virtual bool IncomingRetrieveRootAgent (IScene scene, UUID id, bool agentIsLeaving, out AgentData agent,
                                                      out AgentCircuitData circuitData)
        {
            agent = null;
            circuitData = null;
            IScenePresence sp = scene.GetScenePresence (id);
            if ((sp != null) && (!sp.IsChildAgent)) {
                AgentData data = new AgentData ();
                sp.CopyTo (data);
                agent = data;
                circuitData = BuildCircuitDataForPresence (sp, sp.AbsolutePosition);
                //if (agentIsLeaving)
                //    sp.SetAgentLeaving(null);//We aren't sure where they are going
                return true;
            }

            return false;
        }
コード例 #12
0
 protected bool TryFindGridRegionForAgentLogin(List<GridRegion> regions, UserAccount account,
                                               UUID session, UUID secureSession,
                                               uint circuitCode, Vector3 position,
                                               IPEndPoint clientIP, AgentCircuitData aCircuit, List<UUID> friendsToInform,
                                               out string seedCap, out string reason, out GridRegion destination)
 {
     LoginAgentArgs args = null;
     foreach (GridRegion r in regions)
     {
         if (r == null)
             continue;
         MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, r.RegionName, r.ServerURI);
         args = m_registry.RequestModuleInterface<IAgentProcessing>().
                           LoginAgent(r, aCircuit, friendsToInform);
         if (args.Success)
         {
             //aCircuit = MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
             MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
             destination = r;
             reason = args.Reason;
             seedCap = args.SeedCap;
             return true;
         }
         m_GridService.SetRegionUnsafe(r.RegionID);
     }
     if (args != null)
     {
         seedCap = args.SeedCap;
         reason = args.Reason;
     }
     else
     {
         seedCap = "";
         reason = "";
     }
     destination = null;
     return false;
 }
コード例 #13
0
        public virtual bool TeleportAgent(ref GridRegion destination, uint teleportFlags,
            AgentCircuitData circuit, AgentData agentData, UUID agentID,
            UUID requestingRegion,
            out string reason)
        {
            IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);
            IRegionClientCapsService regionCaps = clientCaps.GetCapsService(requestingRegion);
            ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>();

            if (regionCaps == null || !regionCaps.RootAgent)
            {
                reason = "";
                ResetFromTransit(agentID);
                return false;
            }

            bool result = false;
            try
            {
                bool callWasCanceled = false;

                if (SimulationService != null)
                {
                    //Set the user in transit so that we block duplicate tps and reset any cancelations
                    if (!SetUserInTransit(agentID))
                    {
                        reason = "Already in a teleport";
                        SimulationService.FailedToTeleportAgent(regionCaps.Region, destination.RegionID,
                                                                agentID, reason, false);
                        return false;
                    }

                    IGridService GridService = m_registry.RequestModuleInterface<IGridService>();
                    if (GridService != null)
                    {
                        //Inform the client of the neighbor if needed
                        circuit.IsChildAgent = false; //Force child status to the correct type
                        if (!InformClientOfNeighbor(agentID, requestingRegion, circuit, ref destination, teleportFlags,
                                                    agentData, out reason))
                        {
                            ResetFromTransit(agentID);
                            SimulationService.FailedToTeleportAgent(regionCaps.Region, destination.RegionID,
                                                                    agentID, reason, false);
                            return false;
                        }
                    }
                    else
                    {
                        reason = "Could not find the grid service";
                        ResetFromTransit(agentID);
                        SimulationService.FailedToTeleportAgent(regionCaps.Region, destination.RegionID,
                                                                agentID, reason, false);
                        return false;
                    }

                    IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>();

                    IRegionClientCapsService otherRegion = clientCaps.GetCapsService(destination.RegionID);

                    EQService.TeleportFinishEvent(destination.RegionHandle, destination.Access,
                                                  otherRegion.LoopbackRegionIP,
                                                  otherRegion.CircuitData.RegionUDPPort,
                                                  otherRegion.CapsUrl,
                                                  4, agentID, teleportFlags,
                                                  destination.RegionSizeX, destination.RegionSizeY,
                                                  otherRegion.Region.RegionID);

                    // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
                    // triggers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
                    // that the client contacted the destination before we send the attachments and close things here.

                    result = WaitForCallback(agentID, out callWasCanceled);
                    if (!result)
                    {
                        reason = !callWasCanceled ? "The teleport timed out" : "Cancelled";
                        if (!callWasCanceled)
                        {
                            MainConsole.Instance.Warn("[Agent Processing]: Callback never came for teleporting agent " +
                                                      agentID + ". Resetting.");
                            //Tell the region about it as well
                            SimulationService.FailedToTeleportAgent(regionCaps.Region, destination.RegionID, agentID, reason, false);
                        }
                        //Close the agent at the place we just created if it isn't a neighbor
                        {
                            SimulationService.CloseAgent(destination, agentID);
                            clientCaps.RemoveCAPS(destination.RegionID);
                        }
                    }
                    else
                    {
                        //Fix the root agent status
                        otherRegion.RootAgent = true;
                        regionCaps.RootAgent = false;

                        // Next, let's close the child agent connections that are too far away
                        //Why? OpenSim regions need closed too, even if the protocol is kind of stupid
                        CloseNeighborAgents(regionCaps.Region, destination, agentID);
                        IAgentInfoService agentInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
                        if (agentInfoService != null)
                            agentInfoService.SetLastPosition(agentID.ToString(), destination.RegionID,
                                                             agentData.Position, Vector3.Zero, destination.ServerURI);

                        SimulationService.MakeChildAgent(agentID, regionCaps.Region, destination, false);
                        reason = "";
                    }
                }
                else
                    reason = "No SimulationService found!";
            }
            catch (Exception ex)
            {
                MainConsole.Instance.WarnFormat("[Agent Processing]: Exception occurred during agent teleport, {0}", ex);
                reason = "Exception occurred.";

                if (SimulationService != null)
                    SimulationService.FailedToTeleportAgent(regionCaps.Region, destination.RegionID, agentID, reason, false);
            }
            //All done
            ResetFromTransit(agentID);
            return result;
        }
コード例 #14
0
        bool OnAllowedIncomingAgent(IScene scene, AgentCircuitData agent, bool isRootAgent, out string reason)
        {
            #region Incoming Agent Checks

            UserAccount account = scene.UserAccountService.GetUserAccount (scene.RegionInfo.AllScopeIDs, agent.AgentID);
            if (account == null)
            {
                reason = "No account exists";
                return false;
            }
            IScenePresence Sp = scene.GetScenePresence (agent.AgentID);

            if (loginsDisabled)
            {
                reason = "Logins are currently Disabled";
                return false;
            }

            //Check how long its been since the last TP
            if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent)
            {
                if (timeSinceLastTeleport.ContainsKey (Sp.Scene.RegionInfo.RegionID))
                {
                    if (timeSinceLastTeleport [Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch ())
                    {
                        reason = "Too many teleports. Please try again soon.";
                        return false; // Too soon since the last TP
                    }
                }
                timeSinceLastTeleport [Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch () +
                ((int)(secondsBeforeNextTeleport));
            }

            //Gods tp freely
            if ((Sp != null && Sp.GodLevel != 0) || (account != null && account.UserLevel != 0))
            {
                reason = "";
                return true;
            }

            //Check whether they fit any ban criteria
            if (Sp != null)
            {
                foreach (string banstr in banCriteria)
                {
                    if (Sp.Name.Contains (banstr))
                    {
                        reason = "You have been banned from this region.";
                        return false;
                    } else if (((IPEndPoint)Sp.ControllingClient.GetClientEP ()).Address.ToString ().Contains (banstr))
                    {
                        reason = "You have been banned from this region.";
                        return false;
                    }
                }
                //Make sure they exist in the grid right now
                IAgentInfoService presence = scene.RequestModuleInterface<IAgentInfoService> ();
                if (presence == null)
                {
                    reason = string.Format (
                        "Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.",
                        account.Name, scene.RegionInfo.RegionName);
                    return false;
                }

                UserInfo pinfo = presence.GetUserInfo (agent.AgentID.ToString ());

                if (pinfo == null || (!pinfo.IsOnline && ((agent.TeleportFlags & (uint)TeleportFlags.ViaLogin) == 0)))
                {
                    reason = string.Format (
                        "Failed to verify user presence in the grid for {0}, access denied to region {1}.",
                        account.Name, scene.RegionInfo.RegionName);
                    return false;
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule> ();
            if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit
                < entityCountModule.RootAgents + 1 &&
                scene.RegionInfo.RegionSettings.AgentLimit > 0)
            {
                reason = "Too many agents at this time. Please come back later.";
                return false;
            }

            List<EstateBan> EstateBans = new List<EstateBan> (ES.EstateBans);
            int i = 0;
            //Check bans
            foreach (EstateBan ban in EstateBans)
            {
                if (ban.BannedUserID == agent.AgentID)
                {
                    if (Sp != null)
                    {
                        string banIP = ((IPEndPoint)Sp.ControllingClient.GetClientEP ()).Address.ToString ();

                        if (ban.BannedHostIPMask != banIP) //If it changed, ban them again
                        {
                            //Add the ban with the new hostname
                            ES.AddBan (new EstateBan {
                                BannedHostIPMask = banIP,
                                BannedUserID = ban.BannedUserID,
                                EstateID = ban.EstateID,
                                BannedHostAddress = ban.BannedHostAddress,
                                BannedHostNameMask = ban.BannedHostNameMask
                            });
                            //Update the database
                            Framework.Utilities.DataManager.RequestPlugin<IEstateConnector> ().SaveEstateSettings (ES);
                        }
                    }

                    reason = "Banned from this region.";
                    return false;
                }
                if (Sp != null)
                {
                    bool banendpoint = false;
                    IPAddress endpoint = Sp.ControllingClient.EndPoint;
                    IPHostEntry rDNS = null;
                    if (endpoint != null) {
                        try {
                            rDNS = Dns.GetHostEntry (endpoint);
                        } catch (SocketException) {
                            MainConsole.Instance.WarnFormat ("[IP Ban] IP address \"{0}\" cannot be resolved via DNS", endpoint);
                            rDNS = null;
                        }
                        if (rDNS != null)
                            banendpoint = rDNS.HostName.Contains (ban.BannedHostIPMask);
                        if (!banendpoint)
                            banendpoint = endpoint.ToString ().StartsWith (ban.BannedHostIPMask, StringComparison.Ordinal);
                    }
                    if (ban.BannedHostIPMask == agent.IPAddress || banendpoint)
                    {
                        //Ban the new user
                        ES.AddBan (new EstateBan {
                            EstateID = ES.EstateID,
                            BannedHostIPMask = agent.IPAddress,
                            BannedUserID = agent.AgentID,
                            BannedHostAddress = agent.IPAddress,
                            BannedHostNameMask = agent.IPAddress
                        });
                        Framework.Utilities.DataManager.RequestPlugin<IEstateConnector> ().
                            SaveEstateSettings (ES);

                        reason = "Banned from this region.";
                        return false;
                    }
                }
                i++;
            }

            //Estate owners/managers/access list people/access groups tp freely as well
            if (ES.EstateOwner == agent.AgentID ||
                new List<UUID> (ES.EstateManagers).Contains (agent.AgentID) ||
                new List<UUID> (ES.EstateAccess).Contains (agent.AgentID) ||
                CheckEstateGroups (ES, agent))
            {
                reason = "";
                return true;
            }

            if (ES.DenyAnonymous &&
                ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) ==
                (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return false;
            }

            if (ES.DenyIdentified &&
                ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile) ==
                (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return false;
            }

            if (ES.DenyTransacted &&
                ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse) ==
                (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse))
            {
                reason = "You may not enter this region.";
                return false;
            }

            const long m_Day = 24 * 60 * 60; //Find out day length in seconds
            if (scene.RegionInfo.RegionSettings.MinimumAge != 0 &&
                (account.Created - Util.UnixTimeSinceEpoch ()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day))
            {
                reason = "You may not enter this region.";
                return false;
            }

            if (!ES.PublicAccess)
            {
                reason = "You may not enter this region, Public access has been turned off.";
                return false;
            }

            IAgentConnector agentConnector = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector> ();
            IAgentInfo agentInfo = null;
            if (agentConnector != null)
            {
                agentInfo = agentConnector.GetAgent (agent.AgentID);
                if (agentInfo == null)
                {
                    agentConnector.CreateNewAgent (agent.AgentID);
                    agentInfo = agentConnector.GetAgent (agent.AgentID);
                }
            }

            if (m_checkMaturityLevel)
            {
                if (agentInfo != null &&
                    scene.RegionInfo.AccessLevel > Util.ConvertMaturityToAccessLevel ((uint)agentInfo.MaturityRating))
                {
                    reason = "The region has too high of a maturity level. Blocking teleport.";
                    return false;
                }

                if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "The region has too high of a maturity level. Blocking teleport.";
                    return false;
                }
            }

            #endregion

            reason = "";
            return true;
        }
コード例 #15
0
        public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, Framework.Services.UserInfo pinfo,
            GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList,
            IInventoryService invService, ILibraryService libService,
            string where, string startlocation, Vector3 position, Vector3 lookAt,
            List<InventoryItemBase> gestures,
            GridRegion home, IPEndPoint clientIP, string AdultMax, string AdultRating,
            ArrayList eventValues, ArrayList eventNotificationValues, ArrayList classifiedValues,
            string seedCap, IConfigSource source,
            string DisplayName, string cofversion, IGridInfo info)
            : this()
        {
            m_source = source;
            m_gridInfo = info;
            SeedCapability = seedCap;

            FillOutInventoryData(invSkel, libService, invService);

            FillOutActiveGestures(gestures);

            CircuitCode = (int) aCircuit.CircuitCode;
            Lastname = account.LastName;
            Firstname = account.FirstName;
            this.DisplayName = DisplayName;
            AgentID = account.PrincipalID;
            SessionID = aCircuit.SessionID;
            SecureSessionID = aCircuit.SecureSessionID;
            BuddList = ConvertFriendListItem(friendsList);
            StartLocation = where;
            AgentAccessMax = AdultMax;
            AgentAccess = AdultRating;
            AgentRegionAccess = AgentRegionAccess;
            AOTransition = AOTransition;
            AgentFlag = AgentFlag;
            eventCategories = eventValues;
            eventNotifications = eventNotificationValues;
            classifiedCategories = classifiedValues;
            COFVersion = cofversion;

            FillOutHomeData(pinfo, home);
            LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);

            FillOutRegionData(aCircuit, destination);
            login = "******";
            ErrorMessage = "";
            ErrorReason = LoginResponseEnum.OK;
        }
コード例 #16
0
 bool CheckEstateGroups(EstateSettings ES, AgentCircuitData agent)
 {
     IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule> ();
     if (gm != null && ES.EstateGroups.Count > 0)
     {
         GroupMembershipData[] gmds = gm.GetMembershipData (agent.AgentID);
         return gmds.Any (gmd => ES.EstateGroups.Contains (gmd.GroupID));
     }
     return false;
 }
コード例 #17
0
 private void FillOutRegionData(AgentCircuitData circuitData, GridRegion destination)
 {
     IPEndPoint endPoint = destination.ExternalEndPoint;
     //We don't need this anymore, we set this from what we get from the region
     SimAddress = endPoint.Address.ToString();
     SimPort = (uint) circuitData.RegionUDPPort;
     RegionX = (uint) destination.RegionLocX;
     RegionY = (uint) destination.RegionLocY;
     RegionSizeX = destination.RegionSizeX;
     RegionSizeY = destination.RegionSizeY;
 }
コード例 #18
0
        public bool RetrieveAgent (GridRegion destination, UUID agentID, bool agentIsLeaving, out AgentData agentData,
                                  out AgentCircuitData circuitData)
        {
            agentData = null;
            circuitData = null;

            RetrieveAgentRequest request = new RetrieveAgentRequest ();
            request.AgentID = agentID;
            request.Destination = destination;
            request.AgentIsLeaving = agentIsLeaving;

            AutoResetEvent resetEvent = new AutoResetEvent (false);
            OSDMap result = null;
            m_syncMessagePoster.Get (destination.ServerURI, request.ToOSD (), osdresp => {
                result = osdresp;
                resetEvent.Set ();
            });
            bool success = resetEvent.WaitOne (10000) && result != null;
            if (!success) return false;

            RetrieveAgentResponse response = new RetrieveAgentResponse ();
            response.FromOSD (result);

            circuitData = response.CircuitData;
            agentData = response.AgentData;
            return response.Success;
        }
コード例 #19
0
        /// <summary>
        ///     Async component for informing client of which neighbors exist
        /// </summary>
        /// <remarks>
        ///     This needs to run asynchronously, as a network timeout may block the thread for a long while
        /// </remarks>
        /// <param name="agentID"></param>
        /// <param name="requestingRegion"></param>
        /// <param name="circuitData"></param>
        /// <param name="neighbor"></param>
        /// <param name="teleportFlags"></param>
        /// <param name="agentData"></param>
        /// <param name="reason"></param>
        public virtual bool InformClientOfNeighbor(UUID agentID, UUID requestingRegion, AgentCircuitData circuitData,
            ref GridRegion neighbor,
            uint teleportFlags, AgentData agentData, out string reason)
        {
            if (neighbor == null || neighbor.RegionHandle == 0)
            {
                reason = "Could not find neighbor to inform";
                return false;
            }

            MainConsole.Instance.Info("[Agent Processing]: Starting to inform client about neighbor " + neighbor.RegionName);

            //Notes on this method
            // 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed)
            //       a new Caps handler for it.
            // 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls
            // 3) This allows us to make the Caps on the grid server without telling any other regions about what the
            //       Urls are.

            ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>();
            if (SimulationService != null)
            {
                IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);

                IRegionClientCapsService oldRegionService = clientCaps.GetCapsService(neighbor.RegionID);

                //If its disabled, it should be removed, so kill it!
                if (oldRegionService != null && oldRegionService.Disabled)
                {
                    clientCaps.RemoveCAPS(neighbor.RegionID);
                    oldRegionService = null;
                }

                bool newAgent = oldRegionService == null;
                IRegionClientCapsService otherRegionService =
                    clientCaps.GetOrCreateCapsService(neighbor.RegionID,
                                                      CapsUtil.GetCapsSeedPath
                                                      (CapsUtil.GetRandomCapsObjectPath()),
                                                      circuitData, 0);

                if (!newAgent)
                {
                    //Note: if the agent is already there, send an agent update then
                    bool result = true;
                    if (agentData != null)
                    {
                        agentData.IsCrossing = false;
                        result = SimulationService.UpdateAgent(neighbor, agentData);
                    }

                    if (result)
                        oldRegionService.Disabled = false;
                    else
                    {
                        clientCaps.RemoveCAPS(neighbor.RegionID);//Kill the bad client!
                    }

                    reason = "";
                    return result;
                }

                int requestedPort = 0;
                CreateAgentResponse createAgentResponse;
                bool regionAccepted = CreateAgent(neighbor,
                                                  otherRegionService,
                                                  ref circuitData,
                                                  SimulationService,
                                                  new List<UUID>(),
                                                  out createAgentResponse);
                reason = createAgentResponse.Reason;
                if (regionAccepted)
                {
                    IPAddress ipAddress = neighbor.ExternalEndPoint.Address;
                    //If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not a Virtual Universe region, so don't touch it.
                    string ip = createAgentResponse.OurIPForClient;
                    if (!IPAddress.TryParse(ip, out ipAddress))
            #pragma warning disable 618
                        ipAddress = Dns.GetHostByName(ip).AddressList[0];
            #pragma warning restore 618
                    otherRegionService.AddCAPS(createAgentResponse.CapsURIs);

                    if (ipAddress == null)
                        ipAddress = neighbor.ExternalEndPoint.Address;
                    if (requestedPort == 0)
                        requestedPort = neighbor.ExternalEndPoint.Port;
                    otherRegionService = clientCaps.GetCapsService(neighbor.RegionID);
                    otherRegionService.LoopbackRegionIP = ipAddress;
                    otherRegionService.CircuitData.RegionUDPPort = requestedPort;
                    circuitData.RegionUDPPort = requestedPort; //Fix the port

                    IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>();

                    EQService.EnableSimulator(neighbor.RegionHandle,
                                              ipAddress.GetAddressBytes(),
                                              requestedPort, agentID,
                                              neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion);

                    // EnableSimulator makes the client send a UseCircuitCode message to the destination,
                    // which triggers a bunch of things there.
                    // So let's wait
                    Thread.Sleep(300);
                    EQService.EstablishAgentCommunication(agentID, neighbor.RegionHandle,
                                                          ipAddress.GetAddressBytes(),
                                                          requestedPort, otherRegionService.CapsUrl,
                                                          neighbor.RegionSizeX,
                                                          neighbor.RegionSizeY,
                                                          requestingRegion);

                    MainConsole.Instance.Info("[Agent Processing]: Completed inform client about neighbor " +
                                              neighbor.RegionName);
                }
                else
                {
                    clientCaps.RemoveCAPS(neighbor.RegionID);
                    reason = "Could not contact simulator";
                    MainConsole.Instance.Error("[Agent Processing]: Failed to inform client about neighbor " +
                                               neighbor.RegionName +
                                               ", reason: " + reason);
                    return false;
                }
                return true;
            }
            reason = "SimulationService does not exist";
            MainConsole.Instance.Error("[Agent Processing]: Failed to inform client about neighbor " +
                                       neighbor.RegionName +
                                       ", reason: " + reason + "!");
            return false;
        }
コード例 #20
0
        public virtual AgentCircuitData Copy()
        {
            AgentCircuitData Copy = new AgentCircuitData
            {
                AgentID = AgentID,
                IsChildAgent = IsChildAgent,
                CircuitCode = CircuitCode,
                IPAddress = IPAddress,
                SecureSessionID = SecureSessionID,
                SessionID = SessionID,
                StartingPosition = StartingPosition,
                TeleportFlags = TeleportFlags,
                CachedUserInfo = CachedUserInfo
            };

            return Copy;
        }
コード例 #21
0
        public virtual LoginAgentArgs LoginAgent(GridRegion region, AgentCircuitData aCircuit, List<UUID> friendsToInform)
        {
            bool success = false;
            string seedCap = "";
            string reason = "Could not find the simulation service";
            ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>();

            if (SimulationService != null)
            {
                // The client is in the region, we need to make sure it gets the right Caps
                // If CreateAgent is successful, it passes back a OSDMap of parameters that the client
                //    wants to inform us about, and it includes the Caps SEED url for the region
                IRegionClientCapsService regionClientCaps = null;
                IClientCapsService clientCaps = null;

                //?? if we do not have a capservice then probably we should not allow logins??
                // - greythane - 20160411
                if (m_capsService != null)
                {
                    //Remove any previous users
                    seedCap = m_capsService.CreateCAPS(aCircuit.AgentID,
                                                       CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()),
                                                       region.RegionID, true, aCircuit, 0);

                    clientCaps = m_capsService.GetClientCapsService(aCircuit.AgentID);
                    regionClientCaps = clientCaps.GetCapsService(region.RegionID);
                }

                int requestedUDPPort = 0;
                CreateAgentResponse createAgentResponse;
                // As we are creating the agent, we must also initialize the CapsService for the agent
                success = CreateAgent(region, regionClientCaps, ref aCircuit, SimulationService, friendsToInform,
                                      out createAgentResponse);

                reason = createAgentResponse.Reason;

                if (!success) // If it failed, do not set up any CapsService for the client
                {
                    //Delete the Caps!
                    IAgentProcessing agentProcessor = m_registry.RequestModuleInterface<IAgentProcessing>();

                    if (agentProcessor != null && m_capsService != null)
                        agentProcessor.LogoutAgent(regionClientCaps, true);
                    else if (m_capsService != null)
                        m_capsService.RemoveCAPS(aCircuit.AgentID);
                    return new LoginAgentArgs
                    {
                        Success = success,
                        CircuitData = aCircuit,
                        Reason = reason,
                        SeedCap = seedCap
                    };
                }

                requestedUDPPort = createAgentResponse.RequestedUDPPort;

                if (requestedUDPPort == 0)
                    requestedUDPPort = region.ExternalEndPoint.Port;
                aCircuit.RegionUDPPort = requestedUDPPort;

                IPAddress ipAddress = regionClientCaps.Region.ExternalEndPoint.Address;

                if (m_capsService != null)
                {
                    //If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not an Virtual Universe region, so don't touch it.
                    string ip = createAgentResponse.OurIPForClient;
                    if (!IPAddress.TryParse(ip, out ipAddress))
            #pragma warning disable 618
                        ipAddress = Dns.GetHostByName(ip).AddressList[0];
            #pragma warning restore 618
                    region.ExternalEndPoint.Address = ipAddress;
                    //Fix this so that it gets sent to the client that way
                    regionClientCaps.AddCAPS(createAgentResponse.CapsURIs);
                    regionClientCaps = clientCaps.GetCapsService(region.RegionID);

                    if (regionClientCaps != null)
                    {
                        regionClientCaps.LoopbackRegionIP = ipAddress;
                        regionClientCaps.CircuitData.RegionUDPPort = requestedUDPPort;
                        regionClientCaps.RootAgent = true;
                    }
                    else
                    {
                        success = false;
                        reason = "Timeout error";
                    }
                }
            }
            else
                MainConsole.Instance.ErrorFormat("[Agent Processing]: No simulation service found! Could not log in user!");

            return new LoginAgentArgs { Success = success, CircuitData = aCircuit, Reason = reason, SeedCap = seedCap };
        }
コード例 #22
0
 /// <summary>
 ///     Find, or create if one does not exist, a Caps Service for the given region
 /// </summary>
 /// <param name="regionID"></param>
 /// <param name="CAPSBase"></param>
 /// <param name="circuitData"></param>
 /// <param name="port"></param>
 /// <returns></returns>
 public IRegionClientCapsService GetOrCreateCapsService(UUID regionID, string CAPSBase,
     AgentCircuitData circuitData, uint port)
 {
     //If one already exists, don't add a new one
     if (m_RegionCapsServices.ContainsKey(regionID))
     {
         if (port == 0 || m_RegionCapsServices[regionID].Server.Port == port)
         {
             m_RegionCapsServices[regionID].InformModulesOfRequest();
             return m_RegionCapsServices[regionID];
         }
         else
             RemoveCAPS(regionID);
     }
     //Create a new one, and then call Get to find it
     AddCapsServiceForRegion(regionID, CAPSBase, circuitData, port);
     return GetCapsService(regionID);
 }
コード例 #23
0
        protected virtual OSDMap OnMessageReceived(OSDMap message)
        {
            if (!message.ContainsKey("Method"))
                return null;

            if (m_capsService == null)
                return null;

            string method = message["Method"].AsString();
            if (method != "RegionIsOnline" &&
                method != "LogoutRegionAgents" &&
                method != "ArrivedAtDestination" &&
                method != "CancelTeleport" &&
                method != "AgentLoggedOut" &&
                method != "SendChildAgentUpdate" &&
                method != "TeleportAgent" &&
                method != "CrossAgent")
                return null;

            UUID AgentID = message["AgentID"].AsUUID();
            UUID requestingRegion = message["RequestingRegion"].AsUUID();

            IClientCapsService clientCaps = m_capsService.GetClientCapsService(AgentID);

            IRegionClientCapsService regionCaps = null;
            if (clientCaps != null)
                regionCaps = clientCaps.GetCapsService(requestingRegion);

            if (method == "LogoutRegionAgents")
            {
                LogOutAllAgentsForRegion(requestingRegion);
            }
            else if (method == "RegionIsOnline")
            //This gets fired when the scene is fully finished starting up
            {
                //Log out all the agents first, then add any child agents that should be in this region
                //Don't do this, we don't need to kill all the clients right now
                IGridService GridService = m_registry.RequestModuleInterface<IGridService>();

                if (GridService != null)
                {
                    GridRegion requestingGridRegion = GridService.GetRegionByUUID(null, requestingRegion);
                    if (requestingGridRegion != null)
                        Util.FireAndForget(o => EnableChildAgentsForRegion(requestingGridRegion));
                }
            }
            else if (method == "ArrivedAtDestination")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                //Received a callback
                if (clientCaps.InTeleport) //Only set this if we are in a teleport,
                    //  otherwise (such as on login), this won't check after the first tp!
                    clientCaps.CallbackHasCome = true;

                regionCaps.Disabled = false;

                //The agent is getting here for the first time (eg. login)
                OSDMap body = ((OSDMap)message["Message"]);

                //Parse the OSDMap
                int DrawDistance = body["DrawDistance"].AsInteger();

                AgentCircuitData circuitData = new AgentCircuitData();
                circuitData.FromOSD((OSDMap)body["Circuit"]);

                //Now do the creation
                EnableChildAgents(AgentID, requestingRegion, DrawDistance, circuitData);
            }
            else if (method == "CancelTeleport")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                //Only the region the client is root in can do this
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    //The user has requested to cancel the teleport, stop them.
                    clientCaps.RequestToCancelTeleport = true;
                    regionCaps.Disabled = false;
                }
            }
            else if (method == "AgentLoggedOut")
            {
                //ONLY if the agent is root do we even consider it
                if (regionCaps != null && regionCaps.RootAgent)
                {
                    OSDMap body = ((OSDMap)message["Message"]);

                    AgentPosition pos = new AgentPosition();
                    pos.FromOSD((OSDMap)body["AgentPos"]);

                    regionCaps.Disabled = true;

                    Util.FireAndForget(o =>
                    {
                        LogoutAgent(regionCaps, false); //The root is killing itself
                        SendChildAgentUpdate(pos, regionCaps);
                    });
                }
            }
            else if (method == "SendChildAgentUpdate")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();

                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) //Has to be root
                {
                    OSDMap body = ((OSDMap)message["Message"]);

                    AgentPosition pos = new AgentPosition();
                    pos.FromOSD((OSDMap)body["AgentPos"]);

                    SendChildAgentUpdate(pos, regionCaps);
                    regionCaps.Disabled = false;
                }
            }
            else if (method == "TeleportAgent")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    OSDMap body = ((OSDMap)message["Message"]);

                    GridRegion destination = new GridRegion();
                    destination.FromOSD((OSDMap)body["Region"]);

                    uint TeleportFlags = body["TeleportFlags"].AsUInteger();

                    AgentCircuitData Circuit = new AgentCircuitData();
                    Circuit.FromOSD((OSDMap)body["Circuit"]);

                    AgentData AgentData = new AgentData();
                    AgentData.FromOSD((OSDMap)body["AgentData"]);
                    regionCaps.Disabled = false;

                    //Don't need to wait for this to finish on the main http thread
                    Util.FireAndForget(o =>
                    {
                        string reason;
                        TeleportAgent(ref destination, TeleportFlags,
                            Circuit, AgentData, AgentID, requestingRegion, out reason);
                    });
                    return null;
                }
            }
            else if (method == "CrossAgent")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps == null || rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    //This is a simulator message that tells us to cross the agent
                    OSDMap body = ((OSDMap)message["Message"]);

                    Vector3 pos = body["Pos"].AsVector3();
                    Vector3 Vel = body["Vel"].AsVector3();
                    GridRegion Region = new GridRegion();
                    Region.FromOSD((OSDMap)body["Region"]);
                    AgentCircuitData Circuit = new AgentCircuitData();
                    Circuit.FromOSD((OSDMap)body["Circuit"]);
                    AgentData AgentData = new AgentData();
                    AgentData.FromOSD((OSDMap)body["AgentData"]);
                    regionCaps.Disabled = false;

                    Util.FireAndForget(o =>
                    {
                        string reason;
                        CrossAgent(Region, pos, Vel, Circuit, AgentData,
                            AgentID, requestingRegion, out reason);
                    });

                    return null;
                }

                OSDMap result = new OSDMap();
                result["success"] = false;
                result["Note"] = false;
                return result;
            }

            return null;
        }
コード例 #24
0
        public virtual bool AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint,
                                         AgentCircuitData sessionInfo)
        {
            MainConsole.Instance.Debug("[LLUDP Server] AddClient-" + circuitCode + "-" + agentID + "-" + sessionID + "-" +
                                       remoteEndPoint + "-" + sessionInfo);
            IScenePresence SP;
            if (!m_scene.TryGetScenePresence(agentID, out SP))
            {
                // Create the LLUDPClient
                LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID,
                                                        remoteEndPoint, m_defaultRTO, m_maxRTO);
                // Create the LLClientView
                LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID,
                                                       sessionID, circuitCode);
                client.OnLogout += LogoutHandler;

                // Start the IClientAPI
                m_scene.AddNewClient(client, null);
                m_currentClients.Add(client);
            }
            else
            {
                MainConsole.Instance.DebugFormat(
                    "[LLUDP Server]: Ignoring a repeated UseCircuitCode ({0}) from {1} at {2} ",
                    circuitCode, agentID, remoteEndPoint);
            }
            return true;
        }
コード例 #25
0
        /// <summary>
        ///     Verify if the user can connect to this region.  Checks the banlist and ensures that the region is set for public access
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="agent">The circuit data for the agent</param>
        /// <param name="reason">outputs the reason to this string</param>
        /// <returns>
        ///     True if the region accepts this agent.  False if it does not.  False will
        ///     also return a reason.
        /// </returns>
        protected bool AuthorizeUser (IScene scene, AgentCircuitData agent, out string reason)
        {
            reason = string.Empty;

            IAuthorizationService AuthorizationService = scene.RequestModuleInterface<IAuthorizationService> ();
            if (AuthorizationService != null) {
                GridRegion ourRegion = new GridRegion (scene.RegionInfo);
                if (!AuthorizationService.IsAuthorizedForRegion (ourRegion, agent, !agent.IsChildAgent, out reason)) {
                    MainConsole.Instance.WarnFormat (
                        "[Connection begin]: Denied access to {0} at {1} because the user does not have access to the region, reason: {2}",
                        agent.AgentID, scene.RegionInfo.RegionName, reason);
                    reason = string.Format ("You do not have access to the region {0}, reason: {1}",
                                           scene.RegionInfo.RegionName, reason);
                    return false;
                }
            }

            return true;
        }
コード例 #26
0
 /// <summary>
 ///     Check to make sure this user has the ability to have an agent in this region.
 ///     This checks whether they exist in the grid, whether they are banned from the region and more.
 ///     It is called by the SimulationService in CreateAgent mainly.
 /// </summary>
 /// <param name="agent">The Agent that is coming in</param>
 /// <param name="isRootAgent">Whether this agent will be a root agent</param>
 /// <param name="reason">If it fails, this explains why they cannot enter</param>
 /// <returns>Whether this user is allowed to have an agent in this region</returns>
 public bool AllowedIncomingAgent(AgentCircuitData agent, bool isRootAgent, out string reason)
 {
     IncomingAgentHandler handler = OnAllowIncomingAgent;
     if (handler != null)
     {
         Delegate[] list = handler.GetInvocationList();
         foreach (IncomingAgentHandler h in list)
         {
             if (h(m_scene, agent, isRootAgent, out reason) == false)
                 return false;
         }
     }
     reason = "";
     return true;
 }
コード例 #27
0
 public override void FromOSD(OSDMap map)
 {
     Success = map["Success"];
     CircuitData = new AgentCircuitData();
     CircuitData.FromOSD((OSDMap) map["CircuitData"]);
     SeedCap = map["SeedCap"];
     Reason = map["Reason"];
 }
コード例 #28
0
 public override void FromOSD(OSDMap map)
 {
     Destination = new GridRegion();
     Destination.FromOSD((OSDMap)map["Destination"]);
     TeleportFlags = map["TeleportFlags"];
     CircuitData = new AgentCircuitData();
     CircuitData.FromOSD((OSDMap)map["CircuitData"]);
 }
コード例 #29
0
        /// <summary>
        ///     Add a new Caps Service for the given region if one does not already exist
        /// </summary>
        /// <param name="regionID"></param>
        /// <param name="CAPSBase"></param>
        /// <param name="circuitData"></param>
        /// <param name="port"></param>
        protected void AddCapsServiceForRegion(UUID regionID, string CAPSBase, AgentCircuitData circuitData,
            uint port)
        {
            if (!m_RegionCapsServices.ContainsKey(regionID))
            {
                //Now add this client to the region caps
                //Create if needed
                m_CapsService.AddCapsForRegion(regionID);
                IRegionCapsService regionCaps = m_CapsService.GetCapsForRegion(regionID);

                PerRegionClientCapsService regionClient = new PerRegionClientCapsService();
                regionClient.Initialise(this, regionCaps, CAPSBase, circuitData, port);
                m_RegionCapsServices[regionID] = regionClient;

                //Now get and add them
                regionCaps.AddClientToRegion(regionClient);
            }
        }
        public bool RetrieveAgent(GridRegion destination, UUID agentID, bool agentIsLeaving, out AgentData agentData,
            out AgentCircuitData circuitData)
        {
            agentData = null;
            circuitData = null;

            IScene Scene = destination == null ? null : GetScene(destination.RegionID);
            if (Scene == null || destination == null)
                return false;

            //MainConsole.Instance.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
            IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
            if (transferModule != null)
                return transferModule.IncomingRetrieveRootAgent(Scene, agentID, agentIsLeaving, out agentData,
                                                                out circuitData);
            return false;
            //MainConsole.Instance.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
        }