private static void LoadSettings() { using (var a = new Api(null)) { var setting = a.ExecuteString("global_getvar ban_maxfails"); if (!String.IsNullOrEmpty(setting)) MaxFails = int.Parse(setting); setting = a.ExecuteString("global_getvar ban_failminutes"); if (!String.IsNullOrEmpty(setting)) FailMinutes = int.Parse(setting); setting = a.ExecuteString("global_getvar ban_banminutes"); if (!String.IsNullOrEmpty(setting)) BanMinutes = int.Parse(setting); } }
public static void Ban(String ipAddress) { Log.WriteLine(LogLevel.Critical, "FTP Banning IP Address {0}", ipAddress); if (ActiveBans.ContainsKey(ipAddress)) return; // it's already banned so f-it var bi = new BanInfo(); ActiveBans.Add(ipAddress, bi); // Execute the ban API callback here var acmd = String.Format(BanApi, bi.FirewallRuleName, ipAddress); Log.WriteLine(LogLevel.Critical, "FTB: api command: {0}", acmd); using (var a = new Api(null)) a.ExecuteString(acmd); }
public static void Unban(String ipAddress) { Log.WriteLine(LogLevel.Critical, "FTB: Unbanning ip address {0}", ipAddress); if (!ActiveBans.ContainsKey(ipAddress)) return; // nothing to do, it's not banned var bi = ActiveBans[ipAddress]; // get the ban info // Execute the unban API var acmd = String.Format(UnBanApi, bi.FirewallRuleName); Log.WriteLine(LogLevel.Critical, "FTB: api command: {0}", acmd); using (var a = new Api(null)) a.ExecuteString(acmd); ActiveBans.Remove(ipAddress); }