/// <summary> /// Remove the client from the clients list on disconnect /// </summary> /// <param name="client"></param> public static void RemoveClient(Client Client) { if (Clients.Contains(Client)) { Clients.Remove(Client); } }
public static void AddOffense(Client Client, OffenseSeverity Severity) { Client.Suspicion += suspicionList[Severity]; WarnClient(Client, Severity); //check if we need to ban the client. if (Client.Suspicion >= 100) { //Client.Ban(); } }
public void Translate(Client client, byte packetId, PacketIn packet) { if (!Handlers.ContainsKey(packetId)) { ServerConsole.WriteLine("Unknown Packet Detected.", MessageLevel.Warning); PacketTranslator.DumpUnknown(client, packet); } else { try { Handlers[packetId](client, packet); } catch (Exception ex) { ServerConsole.WriteLine("Translator Error: {0} for packet {1}", MessageLevel.Error, ex.ToString(), packetId); } } }
private static void WarnClient(Client Client, OffenseSeverity Severity) { string message = ""; switch (Severity) { case OffenseSeverity.CooldownHacking: message += "It has been detected that your client is cooldown hacking, further warnings will result in a ban."; break; case OffenseSeverity.SpeedHacking: message += "It has been detected that your client is speed hacking, further warnings will result in a ban."; break; case OffenseSeverity.OutOfPlacePacket: message += "An out of place packet has been detected, this may be due to lag or bad programming, please restart your game and ensure you have the latest update."; break; case OffenseSeverity.IncorrectPacketDetails: message += "One or more of your packets containa invalid data, this may be due to lag or bad programming, please restart your game and ensure you have the latest update."; break; case OffenseSeverity.UndergroundHacking: message += "It has been detected that your client is underground hacking, further warnings will result in a ban."; break; } Client.Send(new Packets.Chat("Hackshield",message,new object[] {})); }
/// <summary> /// Callback that handles client connections /// </summary> /// <param name="ar"></param> private static void CallbackAccept(IAsyncResult ar) { ResetEvent.Set(); /// /// Listen for connections /// Socket listener = (Socket)ar.AsyncState; Socket handler = listener.EndAccept(ar); /// /// Client connected ! Creating client object. /// Client client = new Client(handler); Clients.Add(client); Thinker.Add(5, new DelegateThought.ThoughtCallback(Test), client); ServerConsole.WriteLine("Client #{0} connected from {1}",MessageLevel.Warning, Clients.Count, client.IP); /// /// Starts to listen for client input /// handler.BeginReceive( client.Buffer, 0, Client.BUFFERSIZE, 0, new AsyncCallback(client.OnReceive), null ); }