public async Task HttpServer() { Mono.Net.HttpListener listener = new Mono.Net.HttpListener(); listener.Prefixes.Add(Statics.Config.IniReadValue("http-server")); listener.Start(); while (true) { Mono.Net.HttpListenerContext client = await listener.GetContextAsync(); if (Statics.RedisDb.Bans.Any(x => x.IpBan == client.Request.UserHostAddress)) { Ban ban = Statics.RedisDb.Bans.First(x => x.IpBan == client.Request.UserHostAddress); if ((DateTime.Now - ban.Begin).Minutes > ban.Minutes) { AcceptHttpClient(client); Statics.RedisDb.Remove(ban); } else { Logger.Log(Logger.LogLevel.General, "Reject ban client from ip {0}", client.Request.UserHostAddress); } } else { AcceptHttpClient(client); } } }
public async Task HttpServer() { var listener = new HttpListener(); listener.Prefixes.Add(Program.Configuration.IniReadValue("http-server")); listener.Start(); while (true) { var client = await listener.GetContextAsync(); if (Program.RedisPoolDatabase.Bans.Any(x => x.IpBan == client.Request.UserHostAddress)) { var ban = Program.RedisPoolDatabase.Bans.First(x => x.IpBan == client.Request.UserHostAddress); if ((DateTime.Now - ban.Begin).Minutes > ban.Minutes) { AcceptHttpClient(client); Program.RedisPoolDatabase.Remove(ban); } else { Logger.Log(Logger.LogLevel.General, "Reject ban client from ip {0}", client.Request.UserHostAddress); } } else { AcceptHttpClient(client); } } }