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); } }
internal static HandleRef getCPtr(Api obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
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); }
public static string api_exec(String cmd, String args) { if (API == null) API = new Api(); return API.Execute(cmd, args); }
static void bgWorker_DoWork(object sender, DoWorkEventArgs e) { current_exec = (BGArgs)e.Argument; if (BGAPI == null) BGAPI = new Api(); e.Result = BGAPI.Execute(current_exec.cmd, current_exec.args); current_exec = null; }