コード例 #1
0
        // TODO: logging
        public static async Task Ban(SausageConnection user)
        {
            try
            {
                if (!(user.Socket.Connected || MainSocket.Connected))
                {
                    return;
                }
                // user exists
                if (ConnectedUsers.Any(x => x.UserInfo.Guid == user.UserInfo.Guid))
                {
                    Blacklisted.Add(user.Ip.Address);
                    PacketFormat packet = new PacketFormat(PacketOption.UserBanned)
                    {
                        Guid    = user.UserInfo.Guid,
                        Content = "Place-holder reason"
                    };
                    Log(packet);
                    await Task.Delay(1000);

                    // delay for waiting on the client to recieve a message
                    user.Disconnect();
                    UiCtx.Send(x => ConnectedUsers.Remove(user));
                }
                else
                {
                    MessageBox.Show("User not found", "Ban result");
                }
            }
            catch (ArgumentNullException e)
            {
                MessageBox.Show($"User returned null {e}", "Exception Caught");
            }
        }
コード例 #2
0
 /// <summary> Replaces this instance's access permissions
 /// with a copy of the source's access permissions </summary>
 public void CloneAccess(AccessController source)
 {
     Min = source.Min;
     Max = source.Max;
     // TODO this sould be atomic
     Whitelisted.Clear(); Whitelisted.AddRange(source.Whitelisted);
     Blacklisted.Clear(); Blacklisted.AddRange(source.Blacklisted);
 }
コード例 #3
0
        private int onBlacklist(long handle, GoString goUrl, IntPtr categoriesPtr, int categoryLen)
        {
            int[] categories = new int[categoryLen];

            Marshal.Copy(categoriesPtr, categories, 0, categoryLen);
            Session session = new Session(handle, new Request(handle), new Response(handle));
            string  url     = goUrl.AsString;

            return(Blacklisted?.Invoke(session, url, categories) ?? 0);
        }
コード例 #4
0
        // TODO: Add user list
        public static void OnUserConnect(IAsyncResult ar)
        {
            SausageConnection user;

            try
            {
                user = new SausageConnection(MainSocket.EndAccept(ar));
            }
            catch (SocketException ex)
            {
                Close();
                return;
            }
            catch (ObjectDisposedException ex)
            {
                return;
            }
            if (!Blacklisted.Any(x => x == user.Ip.Address))
            {
                UiCtx.Send(x => ConnectedUsers.Add(user));
                UiCtx.Send(x => Vm.ConnectedUsers = SortUsersList());
                UiCtx.Send(x => Vm.Messages.Add(new ServerMessage($"{user} has connected")));
                UiCtx.Send(x => Mw.AddTextToDebugBox($"User connected on {user.Ip}\n"));
                // global packet for all the users to know the user has joined
                PacketFormat GlobalPacket = new PacketFormat(PacketOption.UserConnected)
                {
                    Guid    = user.UserInfo.Guid,
                    NewName = user.UserInfo.Name
                };
                // local packet for the user (who joined) to get his GUID
                PacketFormat LocalPacket = new PacketFormat(PacketOption.GetGuid)
                {
                    Guid      = user.UserInfo.Guid,
                    UsersList = UsersDictionary.ToArray()
                };
                UsersDictionary.Add(user.UserInfo);
                user.SendAsync(LocalPacket);
                Log(GlobalPacket, user);
            }
            else
            {
                // doesn't log if the user is blacklisted
                user.Disconnect();
            }
            MainSocket.BeginAccept(OnUserConnect, null);
        }
コード例 #5
0
        public AccessResult Check(string name, LevelPermission rank)
        {
            if (Blacklisted.CaselessContains(name))
            {
                return(AccessResult.Blacklisted);
            }
            if (Whitelisted.CaselessContains(name))
            {
                return(AccessResult.Whitelisted);
            }

            if (rank < Min)
            {
                return(AccessResult.BelowMinRank);
            }
            if (rank > Max && MaxCmd != null && !CommandExtraPerms.Find(MaxCmd, 1).UsableBy(rank))
            {
                return(AccessResult.AboveMaxRank);
            }
            return(AccessResult.Allowed);
        }
コード例 #6
0
        /// <summary> Returns the allowed state for the given player. </summary>
        public AccessResult Check(string name, Group rank)
        {
            if (Blacklisted.CaselessContains(name))
            {
                return(AccessResult.Blacklisted);
            }
            if (Whitelisted.CaselessContains(name))
            {
                return(AccessResult.Whitelisted);
            }

            if (rank.Permission < Min)
            {
                return(AccessResult.BelowMinRank);
            }
            if (rank.Permission > Max && MaxCmd != null && rank.Permission < CommandExtraPerms.MinPerm(MaxCmd))
            {
                return(AccessResult.AboveMaxRank);
            }
            return(AccessResult.Allowed);
        }
コード例 #7
0
        public bool Blacklist(Player p, LevelPermission plRank, Level lvl, string target)
        {
            if (!CheckList(p, plRank, target, false))
            {
                return(false);
            }
            if (Blacklisted.CaselessContains(target))
            {
                p.Message("{0} %Sis already blacklisted.", p.FormatNick(target));
                return(true);
            }

            bool removed = true;

            if (!Whitelisted.CaselessRemove(target))
            {
                Blacklisted.Add(target);
                removed = false;
            }
            OnListChanged(p, lvl, target, false, removed);
            return(true);
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            object Email1 = Session["username"];

            if (Email1 == null)
            {
                Response.Redirect("../Admin Login/adminLogin.aspx");
                return;
            }
            myDAL     objmyDAl = new myDAL();
            DataTable DT1      = new DataTable();
            DataTable DT2      = new DataTable();


            objmyDAl.display_Customers_info(ref DT1);
            objmyDAl.display_Blacklist_info(ref DT2);

            gridFeedback.DataSource = DT1;
            gridFeedback.DataBind();
            Blacklisted.DataSource = DT2;
            Blacklisted.DataBind();
        }
コード例 #9
0
        public bool Whitelist(Player p, LevelPermission plRank, Level lvl, string target)
        {
            if (!CheckList(p, plRank, target, true))
            {
                return(false);
            }
            if (Whitelisted.CaselessContains(target))
            {
                p.Message("{0} %Sis already whitelisted.", PlayerInfo.GetColoredName(p, target));
                return(true);
            }

            bool removed = true;

            if (!Blacklisted.CaselessRemove(target))
            {
                Whitelisted.Add(target);
                removed = false;
            }
            OnListChanged(p, lvl, target, true, removed);
            return(true);
        }
コード例 #10
0
        public bool Blacklist(Player p, string target)
        {
            if (!CheckList(p, target, false))
            {
                return(false);
            }
            if (Blacklisted.CaselessContains(target))
            {
                Player.Message(p, "{0} %Sis already blacklisted.", PlayerInfo.GetColoredName(p, target));
                return(true);
            }

            bool removed = true;

            if (!Whitelisted.CaselessRemove(target))
            {
                Blacklisted.Add(target);
                removed = false;
            }
            OnListChanged(p, target, false, removed);
            return(true);
        }
コード例 #11
0
 public int OnBlacklisted(Session session, string url, int[] categories)
 {
     return(Blacklisted?.Invoke(session, url, categories) ?? 0);
 }