Esempio n. 1
0
 public void AddBan(string ip, string reason)
 {
     var newEntry = new BanEntry();
     newEntry.ip = ip;
     newEntry.reason = reason;
     newEntry.bannedAt = DateTime.Now;
     newEntry.tempBan = false;
     banlist.List.Add(newEntry);
     LogManager.Log("Ban Added: " + ip);
     Save();
 }
Esempio n. 2
0
 public void AddBan(string ip, string reason, TimeSpan time)
 {
     var newEntry = new BanEntry();
     newEntry.ip = ip;
     newEntry.reason = reason;
     newEntry.bannedAt = DateTime.Now;
     newEntry.expiresAt = DateTime.Now.Add(time);
     newEntry.tempBan = true;
     banlist.List.Add(newEntry);
     LogManager.Log("Ban Added: " + ip);
     Save();
 }
Esempio n. 3
0
 public void HandleAdminMessage(NetMessage adminMsgType, NetIncomingMessage messageBody)
 {
     switch (adminMsgType)
     {
         case NetMessage.RequestAdminLogin:
             UserInterfaceManager.DisposeAllComponents<AdminPasswordDialog>(); //Remove old ones.
             UserInterfaceManager.AddComponent(new AdminPasswordDialog(new Size(200, 50), NetworkManager,
                                                                       ResourceManager)); //Create a new one.
             break;
         case NetMessage.RequestAdminPlayerlist:
             UserInterfaceManager.DisposeAllComponents<AdminPlayerPanel>();
             UserInterfaceManager.AddComponent(new AdminPlayerPanel(new Size(600, 200), NetworkManager,
                                                                    ResourceManager, messageBody));
             break;
         case NetMessage.RequestBanList:
             var banList = new Banlist();
             int entriesCount = messageBody.ReadInt32();
             for (int i = 0; i < entriesCount; i++)
             {
                 string ipAddress = messageBody.ReadString();
                 string reason = messageBody.ReadString();
                 bool tempBan = messageBody.ReadBoolean();
                 uint minutesLeft = messageBody.ReadUInt32();
                 var entry = new BanEntry
                                 {
                                     ip = ipAddress,
                                     reason = reason,
                                     tempBan = tempBan,
                                     expiresAt = DateTime.Now.AddMinutes(minutesLeft)
                                 };
                 banList.List.Add(entry);
             }
             UserInterfaceManager.DisposeAllComponents<AdminUnbanPanel>();
             UserInterfaceManager.AddComponent(new AdminUnbanPanel(new Size(620, 200), banList, NetworkManager,
                                                                   ResourceManager));
             break;
     }
 }