GetRootAgentCount() public method

public GetRootAgentCount ( ) : int
return int
Ejemplo n.º 1
0
        protected void UpdateBroker(Scene scene)
        {
            if (String.IsNullOrEmpty(m_brokerURI))
                return;

            string uri = String.Format(m_brokerURI, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID);

            // create XML sniplet
            StringBuilder list = new StringBuilder();
            list.Append(String.Format("<avatars count=\"{0}\" region_name=\"{1}\" region_uuid=\"{2}\" timestamp=\"{3}\">\n",
                                          scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
                                          scene.RegionInfo.RegionID,
                                          DateTime.UtcNow.ToString("s")));
            scene.ForEachRootScenePresence(delegate(ScenePresence sp)
            {
                    list.Append(String.Format("    <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
                    list.Append("</avatars>");
            });
            string payload = list.ToString();

            // post via REST to broker
            HttpWebRequest updatePost = WebRequest.Create(uri) as HttpWebRequest;
            updatePost.Method = "POST";
            updatePost.ContentType = "text/xml";
            updatePost.ContentLength = payload.Length;
            updatePost.UserAgent = "OpenSim.Concierge";


            BrokerState bs = new BrokerState(uri, payload, updatePost);
            bs.Timer = new Timer(delegate(object state)
                                 {
                                     BrokerState b = state as BrokerState;
                                     b.Poster.Abort();
                                     b.Timer.Dispose();
                                     m_log.Debug("[Concierge]: async broker POST abort due to timeout");
                                 }, bs, m_brokerUpdateTimeout * 1000, Timeout.Infinite);

            try
            {
                updatePost.BeginGetRequestStream(UpdateBrokerSend, bs);
                m_log.DebugFormat("[Concierge] async broker POST to {0} started", uri);
            }
            catch (WebException we)
            {
                m_log.ErrorFormat("[Concierge] async broker POST to {0} failed: {1}", uri, we.Status);
            }
        }
Ejemplo n.º 2
0
        protected string RegionStats(OSHttpResponse httpResponse, Scene scene)
        {
            int users = scene.GetRootAgentCount();
            int objects = scene.Entities.Count - users;

            RestXmlWriter rxw = new RestXmlWriter(new StringWriter());

            rxw.WriteStartElement(String.Empty, "region", String.Empty);
            rxw.WriteStartElement(String.Empty, "stats", String.Empty);

            rxw.WriteStartElement(String.Empty, "users", String.Empty);
            rxw.WriteString(users.ToString());
            rxw.WriteEndElement();

            rxw.WriteStartElement(String.Empty, "objects", String.Empty);
            rxw.WriteString(objects.ToString());
            rxw.WriteEndElement();

            rxw.WriteEndDocument();

            return rxw.ToString();
        }
Ejemplo n.º 3
0
        public bool AllowTeleport(UUID userID, Scene scene, Vector3 Position, AgentCircuitData ACD, out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID);

            ScenePresence Sp = scene.GetScenePresence(userID);
            if (account == null)
            {
                reason = "Failed authentication.";
                return false; //NO!
            }

            //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.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 (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return false;
                    }
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            if (scene.RegionInfo.RegionSettings.AgentLimit < scene.GetRootAgentCount() + 1)
            {
                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 == userID)
                {
                    string banIP = ((System.Net.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
                        ES.Save();
                    }

                    reason = "Banned from this region.";
                    return false;
                }
                if (ban.BannedHostIPMask == ACD.IPAddress)
                {
                    //Ban the new user
                    ES.AddBan(new EstateBan()
                    {
                        EstateID = ES.EstateID,
                        BannedHostIPMask = ACD.IPAddress,
                        BannedUserID = userID,
                        BannedHostAddress = ACD.IPAddress,
                        BannedHostNameMask = ACD.IPAddress
                    });
                    ES.Save();

                    reason = "Banned from this region.";
                    return false;
                }
                i++;
            }
            
            //Estate owners/managers/access list people/access groups tp freely as well
            if (ES.EstateOwner == userID ||
                new List<UUID>(ES.EstateManagers).Contains(userID) ||
                new List<UUID>(ES.EstateAccess).Contains(userID) ||
                (Sp != null && new List<UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId)))
            {
                reason = "";
                return true;
            }

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

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

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

            long m_Day = 25 * 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.";
                return false;
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>();
            IAgentInfo agentInfo = null;
            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
                if (agentInfo == null)
                {
                    AgentConnector.CreateNewAgent(userID);
                    agentInfo = AgentConnector.GetAgent(userID);
                }
            }
            

            if (agentInfo != null && scene.RegionInfo.RegionSettings.Maturity > 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;
            }

            ILandObject ILO = scene.LandChannel.GetLandObject(Position.X, Position.Y);
            if (ILO == null) // Can't teleport into a parcel that doesn't exist
            {
                reason = "Failed authentication.";
                return false;
            }

            //parcel permissions
            if (ILO.IsEitherBannedOrRestricted(userID))
            {
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return true;
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                    //We found a place for them, but we don't need to check any further
                    return true;
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;
            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return true;
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                            //We found a place for them, but we don't need to check any further
                            return true;
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return true;
                    }
                    //All but the people on the access list are banned
                    if (!ILO.CreateAccessListArrayByFlag(AccessList.Access).Contains(Sp.UUID))
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                            //We found a place for them, but we don't need to check any further
                            return true;
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return true;
                    }
                    //All but the people on the pass/access list are banned
                    if (!ILO.CreateAccessListArrayByFlag(AccessList.Access).Contains(Sp.UUID))
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                            //We found a place for them, but we don't need to check any further
                            return true;
                }
            }

            //Move them to the nearest landing point
            if (!ES.AllowDirectTeleport)
            {
                Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID);
                if (telehub != null)
                {
                    if (telehub.SpawnPos.Count == 0)
                    {
                        newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                    }
                    else
                    {
                        int LastTelehubNum = 0;
                        if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            LastTelehubNum = 0;
                        newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        LastTelehubNum++;
                        if (LastTelehubNum == telehub.SpawnPos.Count)
                            LastTelehubNum = 0;
                        LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                    }
                }
                else
                {
                    reason = "Teleport has been blocked for this region.";
                    return false;
                }
            }
            else
            {
                //If they are owner, they don't have to have permissions checked
                if (!m_scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
                {
                    if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
                    {
                        //Find a new parcel for them
                        List<ILandObject> Parcels = m_scene.LandChannel.ParcelsNearPoint(Position);
                        if (Parcels.Count == 0)
                        {
                            ScenePresence SP;
                            scene.TryGetScenePresence(userID, out SP);
                            newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(SP);
                        }
                        else
                        {
                            bool found = false;
                            //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                            foreach (ILandObject Parcel in Parcels)
                            {
                                if (!Parcel.IsBannedFromLand(userID))
                                {
                                    //Now we have to check their userloc
                                    if (ILO.LandData.LandingType == 2)
                                        continue; //Blocked, check next one
                                    else if (ILO.LandData.LandingType == 1) //Use their landing spot
                                        newPosition = Parcel.LandData.UserLocation;
                                    else //They allow for anywhere, so dump them in the center at the ground
                                        newPosition = m_scene.LandChannel.GetParcelCenterAtGround(Parcel);
                                    found = true;
                                }
                            }
                            if (!found) //Dump them at the edge
                            {
                                if(Sp != null)
                                    newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(Sp);
                                else
                                {
                                    reason = "Banned from this parcel.";
                                    return true;
                                }
                            }
                        }
                    }
                    else if (ILO.LandData.LandingType == 1) //Move to tp spot
                        newPosition = ILO.LandData.UserLocation;
                }
            }

            //Can only enter prelude regions once!
            int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);
            //We assume that our own region isn't null....
            if (((flags & (int)OpenSim.Data.RegionFlags.Prelude) == (int)OpenSim.Data.RegionFlags.Prelude) && agentInfo != null)
            {
                if (((agentInfo.Flags & IAgentFlags.PastPrelude) == IAgentFlags.PastPrelude))
                {
                    reason = "You may not enter this region as you have already been to a prelude region.";
                    return false;
                }
                else
                {
                    agentInfo.Flags |= IAgentFlags.PastPrelude;
                    AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if ((account.UserFlags & (int)ProfileFlags.NoPaymentInfoOnFile) == (int)ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return false;
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return false;
                }
            }

            reason = "";
            return true;
        }
Ejemplo n.º 4
0
        public void OnClosingClient(UUID clientID, Scene scene)
        {
            //Clear out the auth speakers list
            lock (m_authorizedSpeakers)
            {
                if (m_authorizedSpeakers.Contains(clientID))
                    m_authorizedSpeakers.Remove(clientID);
            }

            ScenePresence presence = scene.GetScenePresence(clientID);
            //Announce the closing agent if enabled
            if (m_announceClosedAgents)
            {
                scene.ForEachScenePresence(delegate(ScenePresence SP)
                {
                    if (SP.UUID != clientID && !SP.IsChildAgent)
                    {
                        SP.ControllingClient.SendChatMessage(presence.Name + " has left the region. Total Agents: " + scene.GetRootAgentCount(), 1, SP.AbsolutePosition, "System",
                                                           UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully);
                    }
                }
                );
            }
        }