public override void DeleteRule(String table, String chainName, int position) { String command = "-D " + chainName + " " + position; if (!String.IsNullOrEmpty(table) && table != "filter") { command += " -t " + table; } ExecutionHelper.ExecuteIptables(_system, command, _iptablesBinary); }
public override void DeleteChain(string table, string chainName, bool flush = false) { String arguments; if (flush) { arguments = String.Format("-t {0} -F {1}", table, chainName); ExecutionHelper.ExecuteIptables(_system, arguments, _iptablesBinary); } arguments = String.Format("-t {0} -X {1}", table, chainName); ExecutionHelper.ExecuteIptables(_system, arguments, _iptablesBinary); }
public override bool HasChain(string table, string chainName) { String command = String.Format("-L {0} -t {1}", chainName, table); try { ExecutionHelper.ExecuteIptables(_system, command, _iptablesBinary); return(true); } catch (IpTablesNetException) { return(false); } }
public Version GetIptablesVersion() { var versionProcess = ExecutionHelper.ExecuteIptables(_system, "-V", _iptablesBinary); var versionOutput = versionProcess.StandardOutput.ReadToEnd(); Regex r = new Regex(@"iptables v([0-9]+\.[0-9]+\.[0-9]+)"); if (!r.IsMatch(versionOutput)) { throw new IpTablesNetException("Unable to get version string"); } var match = r.Match(versionOutput); return(new Version(match.Groups[1].Value)); }
public Version GetIptablesVersion() { String versionOutput, error; ExecutionHelper.ExecuteIptables(_system, "-V", _iptablesBinary, out versionOutput, out error); Regex r = new Regex(@"iptables v([0-9]+\.[0-9]+\.[0-9]+)"); if (!r.IsMatch(versionOutput)) { throw new IpTablesNetException("Unable to get version string"); } var match = r.Match(versionOutput); return(new Version(match.Groups[1].Value)); }
public override void AddChain(string table, string chainName) { String command = String.Format("-t {0} -N {1}", table, chainName); ExecutionHelper.ExecuteIptables(_system, command, _iptablesBinary); }
public override void AddRule(IpTablesRule rule) { String command = rule.GetActionCommand(); ExecutionHelper.ExecuteIptables(_system, command, _iptablesBinary); }
public void AddRule(String command) { ExecutionHelper.ExecuteIptables(_system, command, _iptablesBinary); }