예제 #1
0
 public static void usewl(string[] s)
 {
     if (s.Length == 2)
     {
         Console.WriteLine(Filemanager.toggleWhitelist((Boolean.Parse(s[1]))));
     }
     else
     {
         Console.WriteLine("Wrong number of arguments");
     }
 }
예제 #2
0
 public static void removefromwl(string[] s)
 {
     if (s.Length == 2)
     {
         Console.WriteLine(Filemanager.removefromwl(s[1]));
     }
     else
     {
         Console.WriteLine("Wrong number of arguments");
     }
 }
예제 #3
0
 public static void unban(string[] s)
 {
     if (s.Length == 2)
     {
         Console.WriteLine(Filemanager.removeFromBlacklist(s[1], ""));
     }
     else
     {
         Console.WriteLine("Wrong number of arguments");
     }
 }
예제 #4
0
 public static void ban(string[] s)
 {
     if (s.Length == 2)
     {
         Console.WriteLine(Filemanager.blacklist(s[1], ""));
         kick(s, 1);
     }
     else
     {
         Console.WriteLine("Wrong number of arguments");
     }
 }
예제 #5
0
        private void connectClient(string[] data, Message e)
        {
            try
            {
                string  username           = data[1];
                Boolean isAlreadyConnected = usernames.Contains(username);

                usernames.Add(username);
                if (isAlreadyConnected)
                {
                    e.ReplyLine($"$kck${username}$3");
                    return;
                }


                int    index = usernames.IndexOf(username);
                string ip    = Program.clients[index].Client.RemoteEndPoint.ToString().Split(':')[0];


                if (Filemanager.isBanned(username) || Filemanager.isIpBanned(ip))
                {
                    e.ReplyLine($"$kck${username}$1");
                    return;
                }
                else if (useWhitelist && !Filemanager.isOnWhitelist(username))
                {
                    e.ReplyLine($"$kck${username}$2");
                    return;
                }
                else
                {
                    if (Program.isFirstConnection)
                    {
                        //Console.WriteLine("First connection, fetching Data...");
                        e.ReplyLine("$gad");
                        Program.isFirstConnection = false;
                    }
                    else
                    {
                        //Console.WriteLine("Not first connection.");
                        e.ReplyLine("$rad");
                        sendAllData(e);
                    }

                    Console.WriteLine(currentTimeStamp() + " User connected: " + username);
                }
            }
            catch (Exception ex)
            {
                Consolemanager.error("connect client", ex);
            }
        }
예제 #6
0
 public static void listwl()
 {
     if (Filemanager.whitelistedUsers() == null)
     {
         Console.WriteLine("No users were whitelisted.");
     }
     else
     {
         foreach (string s in Filemanager.whitelistedUsers())
         {
             Console.WriteLine(s);
         }
     }
 }
예제 #7
0
        public static void listbanned()
        {
            var banned = Filemanager.bannedUsers();

            if (banned == null || banned.Length == 0)
            {
                Console.WriteLine("No users were banned.");
            }
            else
            {
                foreach (string s in Filemanager.bannedUsers())
                {
                    Console.WriteLine(s.Replace(";", " "));
                }
            }
        }
예제 #8
0
 public static void banip(string[] s)
 {
     if (s.Length == 2)
     {
         if (Program.manager.usernames.Contains(s[1]))
         {
             int    index = Program.manager.usernames.IndexOf(s[1]);
             string ip    = Program.clients[index].Client.RemoteEndPoint.ToString().Split(':')[0];
             Console.WriteLine(Filemanager.blacklist(s[1], ip));
             kick(s, 1);
         }
         else
         {
             Console.WriteLine($"User {s[1]} is not connected.");
         }
     }
     else
     {
         Console.WriteLine("Wrong number of arguments");
     }
 }