Example #1
0
 public void AddBan(EstateBan ban)
 {
     if (ban == null)
     {
         return;
     }
     if (!IsBanned(ban.BannedUserID))
     {
         l_EstateBans.Add(ban);
     }
 }
Example #2
0
 public void AddBan(EstateBan ban)
 {
     if (ban == null)
     {
         return;
     }
     if (!IsBanned(ban.BannedUserID, 32)) //Ignore age-based bans
     {
         l_EstateBans.Add(ban);
     }
 }
 public void AddBan(EstateBan ban)
 {
     if (ban == null)
     {
         return;
     }
     if (!IsBanned(ban.BannedUserID, 32) &&
         (l_EstateBans.Count < (int)Constants.EstateAccessLimits.EstateBans)) //Ignore age-based bans
     {
         l_EstateBans.Add(ban);
     }
 }
Example #4
0
 public void AddBan(EstateBan ban)
 {
     if (ban == null)
         return;
     if (!IsBanned(ban.BannedUserID, 32)) //Ignore age-based bans
         l_EstateBans.Add(ban);
 }
Example #5
0
        private void LoadBanList(EstateSettings es)
        {
            es.ClearBans();

            string sql = "select bannedUUID from estateban where EstateID = @EstateID";

            using (AutoClosingSqlCommand cmd = _Database.Query(sql))
            {
                SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int);
                idParameter.Value = es.EstateID;
                cmd.Parameters.Add(idParameter);

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        EstateBan eb = new EstateBan();

                        eb.BannedUserID = new UUID((Guid)reader["bannedUUID"]); //uuid;
                        eb.BannedHostAddress = "0.0.0.0";
                        eb.BannedHostIPMask = "0.0.0.0";
                        es.AddBan(eb);
                    }
                }
            }
        }
Example #6
0
        private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
        {
            // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups..  etc.

            if (user == m_scene.RegionInfo.EstateSettings.EstateOwner)
                return; // never process EO
            if (user == m_scene.RegionInfo.MasterAvatarAssignedUUID)
                return; // never process owner

            switch (estateAccessType)
            {
                case 64:
                    if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
                    {
                        EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                        bool alreadyInList = false;

                        for (int i = 0; i < banlistcheck.Length; i++)
                        {
                            if (user == banlistcheck[i].BannedUserID)
                            {
                                alreadyInList = true;
                                break;
                            }

                        }
                        if (!alreadyInList)
                        {

                            EstateBan item = new EstateBan();

                            item.BannedUserID = user;
                            item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID;
                            item.BannedHostAddress = "0.0.0.0";
                            item.BannedHostIPMask = "0.0.0.0";

                            m_scene.RegionInfo.EstateSettings.AddBan(item);
                            m_scene.RegionInfo.EstateSettings.Save();

                            ScenePresence s = m_scene.GetScenePresence(user);
                            if (s != null)
                            {
                                if (!s.IsChildAgent)
                                {
                                    s.ControllingClient.SendTeleportLocationStart();
                                    m_scene.TeleportClientHome(user, s.ControllingClient);
                                }
                            }

                        }
                        else
                        {
                            remote_client.SendAlertMessage("User is already on the region ban list");
                        }
                        //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
                        remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
                    }
                    else
                    {
                        remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                    }
                    break;
                case 128:
                    if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
                    {
                        EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                        bool alreadyInList = false;
                        EstateBan listitem = null;

                        for (int i = 0; i < banlistcheck.Length; i++)
                        {
                            if (user == banlistcheck[i].BannedUserID)
                            {
                                alreadyInList = true;
                                listitem = banlistcheck[i];
                                break;
                            }

                        }
                        if (alreadyInList && listitem != null)
                        {
                            m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
                            m_scene.RegionInfo.EstateSettings.Save();
                        }
                        else
                        {
                            remote_client.SendAlertMessage("User is not on the region ban list");
                        }
                        //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
                        remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
                    }
                    else
                    {
                        remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                    }
                    break;
                case 256:

                    if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                    {
                        m_scene.RegionInfo.EstateSettings.AddEstateManager(user);
                        m_scene.RegionInfo.EstateSettings.Save();
                        remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
                    }
                    else
                    {
                        remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                    }

                    break;
                case 512:
                    if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                    {
                        m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
                        m_scene.RegionInfo.EstateSettings.Save();

                        remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
                    }
                    else
                    {
                        remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                    }
                    break;

                default:

                    m_log.ErrorFormat("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta: {0}", estateAccessType.ToString());
                    break;
            }
        }
Example #7
0
        public LSL_Integer llManageEstateAccess(int action, string avatar)
        {
            m_host.AddScriptLPS(1);
            EstateSettings estate = World.RegionInfo.EstateSettings;
            bool isAccount = false;
            bool isGroup = false;

            if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
                return 0;

            UUID id = new UUID();
            if (!UUID.TryParse(avatar, out id))
                return 0;

            UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, id);
            isAccount = account != null ? true : false;
            if (!isAccount)
            {
                IGroupsModule groups = World.RequestModuleInterface<IGroupsModule>();
                if (groups != null)
                {
                    GroupRecord group = groups.GetGroupRecord(id);
                    isGroup = group != null ? true : false;
                    if (!isGroup)
                        return 0;
                }
                else
                    return 0;
            }

            switch (action)
            {
                case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_ADD:
                    if (!isAccount) return 0;
                    if (estate.HasAccess(id)) return 1;
                    if (estate.IsBanned(id))
                        estate.RemoveBan(id);
                    estate.AddEstateUser(id);
                    break;
                case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_AGENT_REMOVE:
                    if (!isAccount || !estate.HasAccess(id)) return 0;
                    estate.RemoveEstateUser(id);
                    break;
                case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_ADD:
                    if (!isGroup) return 0;
                    if (estate.GroupAccess(id)) return 1;
                    estate.AddEstateGroup(id);
                    break;
                case ScriptBaseClass.ESTATE_ACCESS_ALLOWED_GROUP_REMOVE:
                    if (!isGroup || !estate.GroupAccess(id)) return 0;
                    estate.RemoveEstateGroup(id);
                    break;
                case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_ADD:
                    if (!isAccount) return 0;
                    if (estate.IsBanned(id)) return 1;
                    EstateBan ban = new EstateBan();
                    ban.EstateID = estate.EstateID;
                    ban.BannedUserID = id;
                    estate.AddBan(ban);
                    break;
                case ScriptBaseClass.ESTATE_ACCESS_BANNED_AGENT_REMOVE:
                    if (!isAccount || !estate.IsBanned(id)) return 0;
                    estate.RemoveBan(id);
                    break;
                default: return 0;
            }
            return 1;
        }
        private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
        {
            // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups..  etc.

            if (user == Scene.RegionInfo.EstateSettings.EstateOwner)
                return; // never process EO

            if ((estateAccessType & 4) != 0) // User add
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    if ((estateAccessType & 1) != 0) // All estates
                    {
                        List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                        EstateSettings estateSettings;

                        foreach (int estateID in estateIDs)
                        {
                            if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                estateSettings.AddEstateUser(user);
                                estateSettings.Save();
                            }
                        }
                    }

                    Scene.RegionInfo.EstateSettings.AddEstateUser(user);
                    Scene.RegionInfo.EstateSettings.Save();

                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }

            }

            if ((estateAccessType & 8) != 0) // User remove
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    if ((estateAccessType & 1) != 0) // All estates
                    {
                        List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                        EstateSettings estateSettings;

                        foreach (int estateID in estateIDs)
                        {
                            if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                estateSettings.RemoveEstateUser(user);
                                estateSettings.Save();
                            }
                        }
                    }

                    Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
                    Scene.RegionInfo.EstateSettings.Save();

                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }

            if ((estateAccessType & 16) != 0) // Group add
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    if ((estateAccessType & 1) != 0) // All estates
                    {
                        List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                        EstateSettings estateSettings;

                        foreach (int estateID in estateIDs)
                        {
                            if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                estateSettings.AddEstateGroup(user);
                                estateSettings.Save();
                            }
                        }
                    }

                    Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
                    Scene.RegionInfo.EstateSettings.Save();

                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }

            if ((estateAccessType & 32) != 0) // Group remove
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    if ((estateAccessType & 1) != 0) // All estates
                    {
                        List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                        EstateSettings estateSettings;

                        foreach (int estateID in estateIDs)
                        {
                            if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                estateSettings.RemoveEstateGroup(user);
                                estateSettings.Save();
                            }
                        }
                    }

                    Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
                    Scene.RegionInfo.EstateSettings.Save();

                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }

            if ((estateAccessType & 64) != 0) // Ban add
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
                {
                    EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;

                    bool alreadyInList = false;

                    for (int i = 0; i < banlistcheck.Length; i++)
                    {
                        if (user == banlistcheck[i].BannedUserID)
                        {
                            alreadyInList = true;
                            break;
                        }

                    }
                    if (!alreadyInList)
                    {

                        if ((estateAccessType & 1) != 0) // All estates
                        {
                            List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                            EstateSettings estateSettings;

                            foreach (int estateID in estateIDs)
                            {
                                if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                                {
                                    EstateBan bitem = new EstateBan();

                                    bitem.BannedUserID = user;
                                    bitem.EstateID = (uint)estateID;
                                    bitem.BannedHostAddress = "0.0.0.0";
                                    bitem.BannedHostIPMask = "0.0.0.0";

                                    estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                    estateSettings.AddBan(bitem);
                                    estateSettings.Save();
                                }
                            }
                        }

                        EstateBan item = new EstateBan();

                        item.BannedUserID = user;
                        item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
                        item.BannedHostAddress = "0.0.0.0";
                        item.BannedHostIPMask = "0.0.0.0";

                        Scene.RegionInfo.EstateSettings.AddBan(item);
                        Scene.RegionInfo.EstateSettings.Save();

                        TriggerEstateInfoChange();

                        ScenePresence s = Scene.GetScenePresence(user);
                        if (s != null)
                        {
                            if (!s.IsChildAgent)
                            {
                                if (!Scene.TeleportClientHome(user, s.ControllingClient))
                                {
                                    s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
                                    Scene.CloseAgent(s.UUID, false);
                                }
                            }
                        }

                    }
                    else
                    {
                        remote_client.SendAlertMessage("User is already on the region ban list");
                    }
                    //Scene.RegionInfo.regionBanlist.Add(Manager(user);
                    remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }

            if ((estateAccessType & 128) != 0) // Ban remove
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
                {
                    EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;

                    bool alreadyInList = false;
                    EstateBan listitem = null;

                    for (int i = 0; i < banlistcheck.Length; i++)
                    {
                        if (user == banlistcheck[i].BannedUserID)
                        {
                            alreadyInList = true;
                            listitem = banlistcheck[i];
                            break;
                        }
                    }
                    
                    if (alreadyInList && listitem != null)
                    {
                        if ((estateAccessType & 1) != 0) // All estates
                        {
                            List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                            EstateSettings estateSettings;

                            foreach (int estateID in estateIDs)
                            {
                                if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                                {
                                    estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                    estateSettings.RemoveBan(user);
                                    estateSettings.Save();
                                }
                            }
                        }

                        Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
                        Scene.RegionInfo.EstateSettings.Save();

                        TriggerEstateInfoChange();
                    }
                    else
                    {
                        remote_client.SendAlertMessage("User is not on the region ban list");
                    }
                    
                    //Scene.RegionInfo.regionBanlist.Add(Manager(user);
                    remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }

            if ((estateAccessType & 256) != 0) // Manager add
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    if ((estateAccessType & 1) != 0) // All estates
                    {
                        List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                        EstateSettings estateSettings;

                        foreach (int estateID in estateIDs)
                        {
                            if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                estateSettings.AddEstateManager(user);
                                estateSettings.Save();
                            }
                        }
                    }

                    Scene.RegionInfo.EstateSettings.AddEstateManager(user);
                    Scene.RegionInfo.EstateSettings.Save();

                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }

            if ((estateAccessType & 512) != 0) // Manager remove
            {
                if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    if ((estateAccessType & 1) != 0) // All estates
                    {
                        List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
                        EstateSettings estateSettings;

                        foreach (int estateID in estateIDs)
                        {
                            if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
                                estateSettings.RemoveEstateManager(user);
                                estateSettings.Save();
                            }
                        }
                    }

                    Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
                    Scene.RegionInfo.EstateSettings.Save();

                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
        }
        public EstateResult EstateBanUser(UUID AgentId, bool isBan)
        {
            if (AgentId == UUID.Zero)
                return EstateResult.InvalidReq; // not found
            if (AgentId == m_scene.RegionInfo.EstateSettings.EstateOwner)
                return EstateResult.InvalidReq; // never process EO
            if (m_scene.IsEstateOwnerPartner(AgentId))
                return EstateResult.InvalidReq; // never process EO
            if (AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID)
                return EstateResult.InvalidReq; // never process owner

            EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

            bool alreadyInList = false;

            for (int i = 0; i < banlistcheck.Length; i++)
            {
                if (AgentId == banlistcheck[i].BannedUserID)
                {
                    alreadyInList = true;
                    break;
                }
            }

            if (!isBan)
            {   // This is an unban.
                if (!alreadyInList)
                    return EstateResult.AlreadySet;
                m_scene.RegionInfo.EstateSettings.RemoveBan(AgentId);
                SaveEstateDataAndUpdateRegions((uint)EstateSettings.EstateSaveOptions.EstateSaveBans);
                return EstateResult.Success;
            }

            // This is a ban.
            
            // A user cannot be in both the banned and access lists.
            // if they are being banned, remove them from access.
            EstateAllowUser(AgentId, false);    
            if (alreadyInList)
                return EstateResult.AlreadySet;

            EstateBan item = new EstateBan();
            item.BannedUserID = AgentId;
            item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID;
            item.BannedHostAddress = "0.0.0.0";
            item.BannedHostIPMask = "0.0.0.0";
            m_scene.RegionInfo.EstateSettings.AddBan(item);
            SaveEstateDataAndUpdateRegions((uint)EstateSettings.EstateSaveOptions.EstateSaveBans);

            // Banned, now shoo them away.
            ScenePresence sp = m_scene.GetScenePresence(AgentId);
            if (sp != null)
            {
                if (!sp.IsChildAgent)
                {
                    UserProfileData UserProfile = m_scene.CommsManager.UserService.GetUserProfile(AgentId);
                    if ((UserProfile != null) && (UserProfile.HomeRegionID == m_scene.RegionInfo.RegionID))
                    {
                        // Can't send them to their home region, already there and now banned.
                        sp.ControllingClient.Kick("You have been banned from your Home location. You must login directly to a different region.");
                        System.Threading.Thread.Sleep(1000);
                        sp.Scene.IncomingCloseAgent(AgentId);
                    }
                    else
                    {
                        sp.ControllingClient.SendTeleportLocationStart();
                        m_scene.TeleportClientHome(AgentId, sp.ControllingClient);
                    }
                }
            }
            return EstateResult.Success;
        }
        public void T022_EstateSettingsBanList()
        {
            // Letting estate store generate rows to database for us
            EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);

            EstateBan estateBan1 = new EstateBan();
            estateBan1.BannedUserID = DataTestUtil.UUID_MIN;

            EstateBan estateBan2 = new EstateBan();
            estateBan2.BannedUserID = DataTestUtil.UUID_MAX;

            originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };

            // Saving settings.
            db.StoreEstateSettings(originalSettings);

            // Loading settings to another instance variable.
            EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);

            Assert.AreEqual(2, loadedSettings.EstateBans.Length);
            Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);

            Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);

        }
Example #11
0
        /// <summary>
        /// Add en entry into region banlist
        /// </summary>
        /// <param name="item"></param>
        public void AddToRegionBanlist(EstateBan item)
        {

        }
Example #12
0
        public void FromOSD(OSD v)
        {
            OSDMap values = (OSDMap) v;
            EstateID = (uint) values["EstateID"].AsInteger();
            EstateName = values["EstateName"].AsString();
            AbuseEmailToEstateOwner = values["AbuseEmailToEstateOwner"].AsInteger() == 1;
            DenyAnonymous = values["DenyAnonymous"].AsInteger() == 1;
            ResetHomeOnTeleport = values["ResetHomeOnTeleport"].AsInteger() == 1;
            FixedSun = values["FixedSun"].AsInteger() == 1;
            DenyTransacted = values["DenyTransacted"].AsInteger() == 1;
            BlockDwell = values["BlockDwell"].AsInteger() == 1;
            DenyIdentified = values["DenyIdentified"].AsInteger() == 1;
            AllowVoice = values["AllowVoice"].AsInteger() == 1;
            UseGlobalTime = values["UseGlobalTime"].AsInteger() == 1;
            PricePerMeter = values["PricePerMeter"].AsInteger();
            TaxFree = values["TaxFree"].AsInteger() == 1;
            AllowDirectTeleport = values["AllowDirectTeleport"].AsInteger() == 1;
            RedirectGridX = values["RedirectGridX"].AsInteger();
            RedirectGridY = values["RedirectGridY"].AsInteger();
            ParentEstateID = (uint) values["ParentEstateID"].AsInteger();
            SunPosition = values["SunPosition"].AsReal();
            EstateSkipScripts = values["EstateSkipScripts"].AsInteger() == 1;
            BillableFactor = (float) values["BillableFactor"].AsReal();
            PublicAccess = values["PublicAccess"].AsInteger() == 1;
            AbuseEmail = values["AbuseEmail"].AsString();
            EstateOwner = values["EstateOwner"].AsUUID();
            AllowLandmark = values["AllowLandmark"].AsInteger() == 1;
            AllowParcelChanges = values["AllowParcelChanges"].AsInteger() == 1;
            AllowSetHome = values["AllowSetHome"].AsInteger() == 1;
            DenyMinors = values["DenyMinors"].AsInteger() == 1;
            //We always try to pull this in if it exists
            if (values.ContainsKey("EstatePass"))
                EstatePass = values["EstatePass"].AsString();

            OSDMap Managers = values["EstateManagers"] as OSDMap;
#if (!ISWIN)
            List<UUID> list = new List<UUID>();
            foreach (OSD id in Managers.Values)
                list.Add(id.AsUUID());
            EstateManagers = list.ToArray();
#else
            EstateManagers = Managers.Values.Select(ID => ID.AsUUID()).ToArray();
#endif

            OSDMap Ban = values["EstateBans"] as OSDMap;
            List<EstateBan> NewBan = new List<EstateBan>();
            foreach (OSD BannedUser in Ban.Values)
            {
                EstateBan ban = new EstateBan();
                ban.FromOSD(BannedUser);
                NewBan.Add(ban);
            }
            EstateBans = NewBan.ToArray();

            OSDMap Access = values["EstateAccess"] as OSDMap;
#if (!ISWIN)
            List<UUID> list1 = new List<UUID>();
            foreach (OSD uuid in Access.Values)
                list1.Add(uuid.AsUUID());
            EstateAccess = list1.ToArray();
#else
            EstateAccess = Access.Values.Select(UUID => UUID.AsUUID()).ToArray();
#endif

            OSDMap Groups = values["EstateGroups"] as OSDMap;
#if (!ISWIN)
            List<UUID> list2 = new List<UUID>();
            foreach (OSD uuid in Groups.Values)
                list2.Add(uuid.AsUUID());
            EstateGroups = list2.ToArray();
#else
            EstateGroups = Groups.Values.Select(UUID => UUID.AsUUID()).ToArray();
#endif
        }
Example #13
0
        public EstateSettings(Dictionary <string, object> map)
        {
            foreach (KeyValuePair <string, object> kvp in map)
            {
                PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
                if (p == null)
                {
                    continue;
                }

                // EstateBans is a complex type, let's treat it as special
                if (p.Name == "EstateBans")
                {
                    continue;
                }

                if (p.PropertyType.IsArray)
                {
                    string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
                    UUID[]   uuids    = new UUID[elements.Length];
                    int      i        = 0;
                    foreach (string e in elements)
                    {
                        uuids[i++] = new UUID(e);
                    }
                    p.SetValue(this, uuids, null);
                }
                else
                {
                    object value = p.GetValue(this, null);
                    if (value is String)
                    {
                        p.SetValue(this, map[p.Name], null);
                    }
                    else if (value is UInt32)
                    {
                        p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
                    }
                    else if (value is Boolean)
                    {
                        p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
                    }
                    else if (value is UUID)
                    {
                        p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
                    }
                }
            }

            // EstateBans are special
            if (map.ContainsKey("EstateBans"))
            {
                var         banData = ((Dictionary <string, object>)map["EstateBans"]).Values;
                EstateBan[] bans    = new EstateBan[banData.Count];
                int         b       = 0;
                foreach (Dictionary <string, object> ban in banData)
                {
                    bans[b++] = new EstateBan(ban);
                }
                PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
                bansProperty.SetValue(this, bans, null);
            }
        }
Example #14
0
        public List<UUID> GetEstateRegions(uint estateID)
        {
            using (MySqlConnection conn = GetConnection())
            {
                using (MySqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "select RegionID from estate_map where EstateID = ?EstateID";
                    cmd.Parameters.AddWithValue("?EstateID", estateID);

                    IDataReader r = cmd.ExecuteReader();

                    List<UUID> regions = new List<UUID>();
                    while (r.Read())
                    {
                        EstateBan eb = new EstateBan();

                        UUID uuid = new UUID();
                        UUID.TryParse(r["RegionID"].ToString(), out uuid);

                        regions.Add(uuid);
                    }
                    r.Close();
                    return regions;
                }
            }
        }
        private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
        {
            // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups..  etc.

            if (user == m_scene.RegionInfo.EstateSettings.EstateOwner)
                return; // never process EO

            if ((estateAccessType & (int)AccessDeltaRequest.AddAllowedUser) != 0) // User add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estate.AddEstateUser (user);
                                estate.Save ();
                            }
                        }
                    }
                    m_scene.RegionInfo.EstateSettings.AddEstateUser(user);
                    if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                    {
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.RemoveAllowedUser) != 0) // User remove
            {
                IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                if ((estateAccessType & 1) != 0 && connector != null) // All estates
                {
                    List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                    foreach (EstateSettings estate in estateIDs)
                    {
                        if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                        {
                            estate.RemoveEstateUser (user);
                            estate.Save ();
                        }
                    }
                }
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
                    if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                    {
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.AddAllowedGroup) != 0) // Group add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estate.AddEstateGroup (user);
                                estate.Save ();
                            }
                        }
                    }
                    m_scene.RegionInfo.EstateSettings.AddEstateGroup(user);
                    if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                    {
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.RemoveAllowedGroup) != 0) // Group remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estate.RemoveEstateGroup (user);
                                estate.Save ();
                            }
                        }
                    }
                    m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
                    if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                    {
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.AddBannedUser) != 0) // Ban add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                EstateBan[] innerbanlistcheck = estate.EstateBans;

                                bool inneralreadyInList = false;

                                for (int i = 0; i < innerbanlistcheck.Length; i++)
                                {
                                    if (user == innerbanlistcheck[i].BannedUserID)
                                    {
                                        inneralreadyInList = true;
                                        break;
                                    }

                                }
                                if (!inneralreadyInList)
                                {
                                    EstateBan item = new EstateBan ();

                                    item.BannedUserID = user;
                                    item.EstateID = estate.EstateID;
                                    IScenePresence SP = m_scene.GetScenePresence (user);
                                    item.BannedHostAddress = (SP != null) ? ((System.Net.IPEndPoint)SP.ControllingClient.GetClientEP ()).Address.ToString () : "0.0.0.0";
                                    item.BannedHostIPMask = (SP != null) ? ((System.Net.IPEndPoint)SP.ControllingClient.GetClientEP ()).Address.ToString () : "0.0.0.0";
                                    item.BannedHostNameMask = (SP != null) ? ((System.Net.IPEndPoint)SP.ControllingClient.GetClientEP ()).Address.ToString () : "0.0.0.0";
                                    estate.AddBan (item);
                                    estate.Save ();
                                }
                            }
                        }
                    }
                    EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                    bool alreadyInList = false;

                    for (int i = 0; i < banlistcheck.Length; i++)
                    {
                        if (user == banlistcheck[i].BannedUserID)
                        {
                            alreadyInList = true;
                            break;
                        }

                    }
                    if (!alreadyInList)
                    {
                        EstateBan item = new EstateBan();

                        item.BannedUserID = user;
                        item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID;
                        item.BannedHostAddress = "0.0.0.0";
                        IScenePresence SP = m_scene.GetScenePresence (user);
                        item.BannedHostIPMask = (SP != null) ? ((System.Net.IPEndPoint)SP.ControllingClient.GetClientEP()).Address.ToString() : "0.0.0.0";

                        m_scene.RegionInfo.EstateSettings.AddBan(item);

                        //Trigger the event
                        m_scene.AuroraEventManager.FireGenericEventHandler("BanUser", user);

                        if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                        {
                            m_scene.RegionInfo.EstateSettings.Save();
                            TriggerEstateInfoChange();
                        }

                        if (SP != null)
                        {
                            if (!SP.IsChildAgent)
                            {
                                IEntityTransferModule transferModule = m_scene.RequestModuleInterface<IEntityTransferModule>();
                                if (transferModule != null)
                                    transferModule.TeleportHome(user, SP.ControllingClient);
                            }
                            else
                            {
                                //Close them in the sim
                                IEntityTransferModule transferModule = SP.Scene.RequestModuleInterface<IEntityTransferModule> ();
                                if (transferModule != null)
                                    transferModule.IncomingCloseAgent (SP.Scene, SP.UUID);
                            }
                        }
                    }
                    else
                    {
                        remote_client.SendAlertMessage("User is already on the region ban list");
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.RemoveBannedUser) != 0) // Ban remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                EstateBan[] innerbanlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                                bool inneralreadyInList = false;
                                EstateBan innerlistitem = null;

                                for (int i = 0; i < innerbanlistcheck.Length; i++)
                                {
                                    if (user == innerbanlistcheck[i].BannedUserID)
                                    {
                                        inneralreadyInList = true;
                                        innerlistitem = innerbanlistcheck[i];
                                        break;
                                    }

                                }

                                if (inneralreadyInList && innerlistitem != null)
                                {
                                    m_scene.RegionInfo.EstateSettings.RemoveBan (innerlistitem.BannedUserID);
                                }
                                estate.Save ();
                            }
                        }
                    }
                    EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                    bool alreadyInList = false;
                    EstateBan listitem = null;

                    for (int i = 0; i < banlistcheck.Length; i++)
                    {
                        if (user == banlistcheck[i].BannedUserID)
                        {
                            alreadyInList = true;
                            listitem = banlistcheck[i];
                            break;
                        }

                    }

                    //Trigger the event
                    m_scene.AuroraEventManager.FireGenericEventHandler("UnBanUser", user);

                    if (alreadyInList && listitem != null)
                    {
                        m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
                        if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                        {
                            m_scene.RegionInfo.EstateSettings.Save();
                            TriggerEstateInfoChange();
                        }
                    }
                    else
                    {
                        remote_client.SendAlertMessage("User is not on the region ban list");
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.AddEstateManager) != 0) // Manager add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estate.AddEstateManager (user);
                                estate.Save ();
                            }
                        }
                    }
                    m_scene.RegionInfo.EstateSettings.AddEstateManager(user);
                    if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                    {
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.RemoveEstateManager) != 0) // Manager remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    IEstateConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector> ();
                    if ((estateAccessType & 1) != 0 && connector != null) // All estates
                    {
                        List<EstateSettings> estateIDs = connector.GetEstates (remote_client.AgentId);
                        foreach (EstateSettings estate in estateIDs)
                        {
                            if (estate.EstateID != m_scene.RegionInfo.EstateSettings.EstateID)
                            {
                                estate.RemoveEstateManager (user);
                                estate.Save ();
                            }
                        }
                    }
                    m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
                    if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
                    {
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & (int)AccessDeltaRequest.MoreToCome) == 0) //1024 means more than one is being sent
            {
                remote_client.SendEstateList(invoice, (int)EstateTools.EstateAccessReplyDelta.AllowedUsers, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID);
                remote_client.SendEstateList(invoice, (int)EstateTools.EstateAccessReplyDelta.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID);
                remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
                remote_client.SendEstateList(invoice, (int)EstateTools.EstateAccessReplyDelta.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
            }
        }
Example #16
0
        public EstateSettings(Dictionary<string, object> map)
        {
            foreach (KeyValuePair<string, object> kvp in map)
            {
                PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
                if (p == null)
                    continue;

                // EstateBans is a complex type, let's treat it as special
                if (p.Name == "EstateBans")
                    continue;

                if (p.PropertyType.IsArray)
                {
                    string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
                    UUID[] uuids = new UUID[elements.Length];
                    int i = 0;
                    foreach (string e in elements)
                        uuids[i++] = new UUID(e);
                    p.SetValue(this, uuids, null);
                }
                else
                {
                    object value = p.GetValue(this, null);
                    if (value is String)
                        p.SetValue(this, map[p.Name], null);
                    else if (value is UInt32)
                        p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
                    else if (value is Boolean)
                        p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
                    else if (value is UUID)
                        p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
                }
            }

            // EstateBans are special
            if (map.ContainsKey("EstateBans"))
            {
                var banData = ((Dictionary<string, object>)map["EstateBans"]).Values;
                EstateBan[] bans = new EstateBan[banData.Count];
                int b = 0;
                foreach (Dictionary<string, object> ban in banData)
                    bans[b++] = new EstateBan(ban);
                PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
                bansProperty.SetValue(this, bans, null);
            }
        }
Example #17
0
 public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
 {
     throw new System.NotImplementedException();
 }
Example #18
0
        /// <summary>
        /// remove an entry from the region banlist
        /// </summary>
        /// <param name="item"></param>
        public void RemoveFromRegionBanlist(EstateBan item)
        {

        }
        private void LoadBanList(EstateSettings es)
		{
			es.ClearBans();

            List<string> query = null;
            try
            {
                query = GD.Query(new string[] { "ID", "`Key`" }, new object[] { es.EstateID, "EstateBans" }, "estates", "Value");
            }
            catch
            {
            }
            if (query == null || query.Count == 0)
                return; //Couldn't find it, return then.

            OSDMap estateInfo = (OSDMap)OSDParser.DeserializeLLSDXml(query[0]);
            foreach (OSD map in estateInfo.Values)
            {
                OSDMap estateBan = (OSDMap)map;
				EstateBan eb = new EstateBan();

                eb.BannedUserID = estateBan["BannedUserID"].AsUUID();
                eb.BannedHostAddress = estateBan["BannedHostAddress"].AsString();
                eb.BannedHostIPMask = estateBan["BannedHostIPMask"].AsString();
				es.AddBan(eb);
			}
		}
Example #20
0
 public void AddBan(EstateBan ban)
 {
     if (ban == null)
         return;
     if (!IsBanned(ban.BannedUserID))
         l_EstateBans.Add(ban);
 }
Example #21
0
 public void SendBannedUserList(OpenMetaverse.UUID invoice, EstateBan[] banlist, uint estateID)
 {
 }
        private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
        {
            // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups..  etc.

            if (user == m_scene.RegionInfo.EstateSettings.EstateOwner)
                return; // never process EO

            if ((estateAccessType & 4) != 0) // User add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.AddEstateUser(user);
                    m_scene.RegionInfo.EstateSettings.Save();
                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }

            }
            if ((estateAccessType & 8) != 0) // User remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
                    m_scene.RegionInfo.EstateSettings.Save();
                    TriggerEstateInfoChange();

                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & 16) != 0) // Group add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.AddEstateGroup(user);
                    m_scene.RegionInfo.EstateSettings.Save();
                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & 32) != 0) // Group remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
                    m_scene.RegionInfo.EstateSettings.Save();
                    TriggerEstateInfoChange();

                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & 64) != 0) // Ban add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
                {
                    EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                    bool alreadyInList = false;

                    for (int i = 0; i < banlistcheck.Length; i++)
                    {
                        if (user == banlistcheck[i].BannedUserID)
                        {
                            alreadyInList = true;
                            break;
                        }

                    }
                    if (!alreadyInList)
                    {

                        EstateBan item = new EstateBan();

                        item.BannedUserID = user;
                        item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID;
                        item.BannedHostAddress = "0.0.0.0";
                        item.BannedHostIPMask = "0.0.0.0";

                        m_scene.RegionInfo.EstateSettings.AddBan(item);
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();

                        ScenePresence s = m_scene.GetScenePresence(user);
                        if (s != null)
                        {
                            if (!s.IsChildAgent)
                            {
                                m_scene.TeleportClientHome(user, s.ControllingClient);
                            }
                        }

                    }
                    else
                    {
                        remote_client.SendAlertMessage("User is already on the region ban list");
                    }
                    //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
                    remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & 128) != 0) // Ban remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
                {
                    EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;

                    bool alreadyInList = false;
                    EstateBan listitem = null;

                    for (int i = 0; i < banlistcheck.Length; i++)
                    {
                        if (user == banlistcheck[i].BannedUserID)
                        {
                            alreadyInList = true;
                            listitem = banlistcheck[i];
                            break;
                        }

                    }
                    if (alreadyInList && listitem != null)
                    {
                        m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
                        m_scene.RegionInfo.EstateSettings.Save();
                        TriggerEstateInfoChange();
                    }
                    else
                    {
                        remote_client.SendAlertMessage("User is not on the region ban list");
                    }
                    //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
                    remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & 256) != 0) // Manager add
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.AddEstateManager(user);
                    m_scene.RegionInfo.EstateSettings.Save();
                    TriggerEstateInfoChange();
                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
            if ((estateAccessType & 512) != 0) // Manager remove
            {
                if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
                {
                    m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
                    m_scene.RegionInfo.EstateSettings.Save();
                    TriggerEstateInfoChange();

                    remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
                }
                else
                {
                    remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
                }
            }
        }
Example #23
0
 protected void SetRegionInfoOption(string[] cmdparams)
 {
     IScene scene = MainConsole.Instance.ConsoleScene;
     if (scene == null)
         scene = m_scenes[0];
     #region 3 Params needed
     if (cmdparams.Length < 4)
     {
         m_log.Warn("Not enough parameters!");
         return;
     }
     if (cmdparams[2] == "Maturity")
     {
         if (cmdparams[3] == "PG")
         {
             scene.RegionInfo.AccessLevel = Util.ConvertMaturityToAccessLevel(0);
         }
         else if (cmdparams[3] == "Mature")
         {
             scene.RegionInfo.AccessLevel = Util.ConvertMaturityToAccessLevel(1);
         }
         else if (cmdparams[3] == "Adult")
         {
             scene.RegionInfo.AccessLevel = Util.ConvertMaturityToAccessLevel(2);
         }
         else
         {
             m_log.Warn("Your parameter did not match any existing parameters. Try PG, Mature, or Adult");
             return;
         }
         scene.RegionInfo.RegionSettings.Save();
         //Tell the grid about the changes
         IGridRegisterModule gridRegModule = scene.RequestModuleInterface<IGridRegisterModule>();
         if (gridRegModule != null)
             gridRegModule.UpdateGridRegion(scene);
     }
     #endregion
     #region 4 Params needed
     if (cmdparams.Length < 4)
     {
         m_log.Warn("Not enough parameters!");
         return;
     }
     if (cmdparams[2] == "AddEstateBan".ToLower())
     {
         EstateBan EB = new EstateBan();
         EB.BannedUserID = m_scenes[0].UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID;
         scene.RegionInfo.EstateSettings.AddBan(EB);
     }
     if (cmdparams[2] == "AddEstateManager".ToLower ())
     {
         scene.RegionInfo.EstateSettings.AddEstateManager(m_scenes[0].UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "AddEstateAccess".ToLower ())
     {
         scene.RegionInfo.EstateSettings.AddEstateUser(m_scenes[0].UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "RemoveEstateBan".ToLower ())
     {
         scene.RegionInfo.EstateSettings.RemoveBan(m_scenes[0].UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "RemoveEstateManager".ToLower ())
     {
         scene.RegionInfo.EstateSettings.RemoveEstateManager(m_scenes[0].UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "RemoveEstateAccess".ToLower ())
     {
         scene.RegionInfo.EstateSettings.RemoveEstateUser(m_scenes[0].UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     #endregion
     scene.RegionInfo.RegionSettings.Save();
     scene.RegionInfo.EstateSettings.Save();
 }
Example #24
0
 public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
 {
 }
        private void LoadBanList(EstateSettings es)
        {
            es.ClearBans();

            string sql = "select \"bannedUUID\" from estateban where \"EstateID\" = :EstateID";

            using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
            using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
            {
                NpgsqlParameter idParameter = new NpgsqlParameter("EstateID", DbType.Int32);
                idParameter.Value = es.EstateID;
                cmd.Parameters.Add(idParameter);
                conn.Open();
                using (NpgsqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        EstateBan eb = new EstateBan();

                        eb.BannedUserID = new UUID((Guid)reader["bannedUUID"]); //uuid;
                        eb.BannedHostAddress = "0.0.0.0";
                        eb.BannedHostIPMask = "0.0.0.0";
                        es.AddBan(eb);
                    }
                }
            }
        }
        private void LoadBanList(EstateSettings es)
        {
            es.ClearBans();

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {
                dbcon.Open();

                using (MySqlCommand cmd = dbcon.CreateCommand())
                {
                    cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
                    cmd.Parameters.AddWithValue("?EstateID", es.EstateID);

                    using (IDataReader r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            EstateBan eb = new EstateBan();

                            UUID uuid = new UUID();
                            UUID.TryParse(r["bannedUUID"].ToString(), out uuid);

                            eb.BannedUserID = uuid;
                            eb.BannedHostAddress = "0.0.0.0";
                            eb.BannedHostIPMask = "0.0.0.0";
                            es.AddBan(eb);
                        }
                    }
                }
            }
        }
        private void LoadBanList(EstateSettings es)
        {
            es.ClearBans();

            SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();

            cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
            cmd.Parameters.AddWithValue(":EstateID", es.EstateID);

            IDataReader r = cmd.ExecuteReader();

            while (r.Read())
            {
                EstateBan eb = new EstateBan();

                UUID uuid = new UUID();
                UUID.TryParse(r["bannedUUID"].ToString(), out uuid);

                eb.BannedUserID = uuid;
                eb.BannedHostAddress = "0.0.0.0";
                eb.BannedHostIPMask = "0.0.0.0";
                es.AddBan(eb);
            }
            r.Close();
        }
        public EstateSettings(Dictionary <string, object> map)
        {
            foreach (KeyValuePair <string, object> kvp in map)
            {
                PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
                if (p == null)
                {
                    continue;
                }

                // EstateBans is a complex type, let's treat it as special
                if (p.Name == "EstateBans")
                {
                    continue;
                }

                if (p.PropertyType.IsArray)
                {
                    string[] elements = ((string)map[p.Name]).Split(new char[] { ',' });
                    UUID[]   uuids    = new UUID[elements.Length];
                    int      i        = 0;
                    foreach (string e in elements)
                    {
                        uuids[i++] = new UUID(e);
                    }
                    p.SetValue(this, uuids, null);
                }
                else
                {
                    object value = p.GetValue(this, null);
                    if (value is String)
                    {
                        p.SetValue(this, map[p.Name], null);
                    }
                    else if (value is UInt32)
                    {
                        p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
                    }
                    else if (value is Boolean)
                    {
                        p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
                    }
                    else if (value is UUID)
                    {
                        p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
                    }
                }
            }

            // EstateBans are special
            if (map.ContainsKey("EstateBans"))
            {
                if (map["EstateBans"] is string)
                {
                    // JSON encoded bans map
                    Dictionary <string, EstateBan> bdata = new Dictionary <string, EstateBan>();
                    try
                    {
                        // bypass libovm, we dont need even more useless high level maps
                        // this should only be called once.. but no problem, i hope
                        // (other uses may need more..)
                        LitJson.JsonMapper.RegisterImporter <string, UUID>((input) => new UUID(input));
                        bdata = LitJson.JsonMapper.ToObject <Dictionary <string, EstateBan> >((string)map["EstateBans"]);
                    }
                    //                   catch(Exception e)
                    catch
                    {
                        return;
                    }
                    EstateBan[] jbans = new EstateBan[bdata.Count];
                    bdata.Values.CopyTo(jbans, 0);

                    PropertyInfo jbansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
                    jbansProperty.SetValue(this, jbans, null);
                }
                else
                {
                    var         banData = ((Dictionary <string, object>)map["EstateBans"]).Values;
                    EstateBan[] bans    = new EstateBan[banData.Count];

                    int b = 0;
                    foreach (Dictionary <string, object> ban in banData)
                    {
                        bans[b++] = new EstateBan(ban);
                    }
                    PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
                    bansProperty.SetValue(this, bans, null);
                }
            }
        }
Example #29
0
 protected void SetRegionInfoOption(string module, string[] cmdparams)
 {
     Scene scene = m_scene.ConsoleScene();
     if (scene == null)
         scene = m_scene;
     #region 3 Params needed
     if (cmdparams.Length < 4)
     {
         m_log.Warn("Not enough parameters!");
         return;
     }
     if (cmdparams[2] == "Maturity")
     {
         if (cmdparams[3] == "PG")
         {
             scene.RegionInfo.RegionSettings.Maturity = 0;
         }
         else if (cmdparams[3] == "Mature")
         {
             scene.RegionInfo.RegionSettings.Maturity = 1;
         }
         else if (cmdparams[3] == "Adult")
         {
             scene.RegionInfo.RegionSettings.Maturity = 2;
         }
         else
         {
             m_log.Warn("Your parameter did not match any existing parameters. Try PG, Mature, or Adult");
             return;
         }
         scene.RegionInfo.RegionSettings.Save();
         scene.UpdateGridRegion();
     }
     #endregion
     #region 4 Params needed
     if (cmdparams.Length < 4)
     {
         m_log.Warn("Not enough parameters!");
         return;
     }
     if (cmdparams[2] == "AddEstateBan")
     {
         EstateBan EB = new EstateBan();
         EB.BannedUserID = m_scene.UserAccountService.GetUserAccount(UUID.Zero,cmdparams[3],cmdparams[4]).PrincipalID;
         scene.RegionInfo.EstateSettings.AddBan(EB);
     }
     if (cmdparams[2] == "AddEstateManager")
     {
         scene.RegionInfo.EstateSettings.AddEstateManager(m_scene.UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "AddEstateAccess")
     {
         scene.RegionInfo.EstateSettings.AddEstateUser(m_scene.UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "RemoveEstateBan")
     {
         scene.RegionInfo.EstateSettings.RemoveBan(m_scene.UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "RemoveEstateManager")
     {
         scene.RegionInfo.EstateSettings.RemoveEstateManager(m_scene.UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     if (cmdparams[2] == "RemoveEstateAccess")
     {
         scene.RegionInfo.EstateSettings.RemoveEstateUser(m_scene.UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]).PrincipalID);
     }
     #endregion
     scene.RegionInfo.RegionSettings.Save();
     scene.RegionInfo.EstateSettings.Save();
 }