static void Main(string[] args) { ConfigHandler.WriteDefaultConfig(); Bans.CreateBanFile(); Encryption.GenerateRSAKeys(); Encryption.GenerateAESKeys(); AddCommands.Add(); ChannelHandler.CreateChannelDataFile(); bool quitNow = false; while (!quitNow) { Console.Title = "TCPChat - Server"; Console.WriteLine("Commands: \n"); Console.WriteLine("/server \n"); Console.WriteLine("/quit \n"); #if (DEVMODE) InputServerConfig(); #else string command = Console.ReadLine(); switch (command) { case "/server": InputServerConfig(); break; case "/quit": quitNow = true; break; } #endif } }
public static void Execute() { for (int i = 0; i < ServerHandler.activeClients.Count; i++) { bool parse = int.TryParse(Commands.CommandArguments[0], out int outNum); if (parse && ServerHandler.activeClients[i].ID == outNum) { string message = String.Format("({0}) {1} has been banned.", ServerHandler.activeClients[i].ID, ServerHandler.activeClients[i].Username); ServerMessage.ServerGlobalMessage(ConsoleColor.Yellow, message); Bans.AddNewBan(((IPEndPoint)ServerHandler.activeClients[i].TCPClient.Client.RemoteEndPoint).Address.ToString()); // Try / catch as an out of range solution. try { ServerHandler.activeClients[i].TCPClient.Close(); } catch (ArgumentOutOfRangeException) { } return; } } }