public void addClient(TcpClient client) { if (banned == null) { banned = NetworkBlock.getInstance(); } string ip = client.Client.RemoteEndPoint.ToString().Split(':')[0]; Console.WriteLine("connected " + ip); if (flood.ContainsKey(ip)) { if (flood[ip].CompareTo(DateTime.Now) == 1) { CLogger.warning("active flooder " + ip); client.Close(); return; } else { lock (flood) { flood.Remove(ip); } } } flood.Add(ip, DateTime.Now.AddMilliseconds(3000)); if (!banned.Allowed(ip)) { client.Close(); CLogger.error("NetworkBlock: connection attemp failed. " + ip + " banned."); return; } LoginClient lc = new LoginClient(client); if (_loggedClients.Contains(lc)) { return; } _loggedClients.Add(lc); }
public void AddClient(TcpClient client) { if (Banned == null) { Banned = NetworkBlock.Instance; } string ip = client.Client.RemoteEndPoint.ToString().Split(':')[0]; lock (Flood) { if (Flood.ContainsKey(ip)) { if (Flood[ip].CompareTo(DateTime.Now) == 1) { log.Warn($"Active flooder: {ip}"); client.Close(); return; } lock (Flood) Flood.Remove(ip); } } Flood.Add(ip, DateTime.Now.AddMilliseconds(3000)); if (!Banned.Allowed(ip)) { client.Close(); log.Error($"Connection attempt failed. {ip} banned."); return; } GameClient gc = new GameClient(_playerService, this, client, _gamePacketHandler); lock (Clients) Clients.Add(gc.Address.ToString(), gc); log.Info($"{Clients.Count} active connections"); }
public void addClient(TcpClient client) { if (_banned == null) { _banned = NetworkBlock.Instance; } string ip = client.Client.RemoteEndPoint.ToString().Split(':')[0]; if (_flood.ContainsKey(ip)) { if (_flood[ip].CompareTo(DateTime.Now) == 1) { CLogger.warning("active flooder " + ip); client.Close(); return; } else { lock (_flood) _flood.Remove(ip); } } _flood.Add(ip, DateTime.Now.AddMilliseconds(3000)); if (!_banned.Allowed(ip)) { client.Close(); CLogger.error("NetworkBlock: connection attemp failed. " + ip + " banned."); return; } GameClient gc = new GameClient(client); clients.Add(gc._address.ToString(), gc); CLogger.extra_info("NetController: " + clients.Count + " active connections"); }