public void TestRuleIp() { if (IsLinux) { Assert.AreEqual(0, IptcInterface.RefCount); String ip; int cidr; if (_ipVersion == 4) { ip = IPAddress.Loopback.ToString(); cidr = 32; } else { ip = "::1"; cidr = 128; } var rule = "-A test3 -s " + ip + "/" + cidr + " -p tcp -m tcp --dport 80 -j ACCEPT"; using (IptcInterface iptc = new IptcInterface("filter", _ipVersion)) { iptc.ExecuteCommand("ip6tables " + rule); var rules = iptc.GetRules("test3"); Assert.AreEqual(2, rules.Count); Assert.AreEqual(rule, iptc.GetRuleString("test3", rules[1])); } Assert.AreEqual(0, IptcInterface.RefCount); } }
public void TestRuleOutputModule() { if (IsLinux) { IptcInterface iptc = new IptcInterface("filter"); var rules = iptc.GetRules("test3"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test3 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test3", rules[0])); } }
public void TestRuleOutputSimple() { if (IsLinux) { IptcInterface iptc = new IptcInterface("filter"); var rules = iptc.GetRules("test"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test -j ACCEPT", iptc.GetRuleString("test", rules[0])); } }
public void TestRuleOutputModule() { if (IsLinux) { IptcInterface iptc = new IptcInterface("filter"); var rules = iptc.GetRules("test3"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test3 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test3", rules[0])); } }
public void TestRuleOutputSimple() { if (IsLinux) { IptcInterface iptc = new IptcInterface("filter"); var rules = iptc.GetRules("test"); Assert.AreEqual(1,rules.Count); Assert.AreEqual("-A test -j ACCEPT", iptc.GetRuleString("test",rules[0])); } }
public void TestRuleOutputSimple() { if (IsLinux) { Assert.AreEqual(0, IptcInterface.RefCount); using (IptcInterface iptc = new IptcInterface("filter", _ipVersion)) { var rules = iptc.GetRules("test"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test -j ACCEPT", iptc.GetRuleString("test", rules[0])); } Assert.AreEqual(0, IptcInterface.RefCount); } }
public void TestRuleOutputSimple() { if (IsLinux) { Assert.AreEqual(0, IptcInterface.RefCount); using (IptcInterface iptc = new IptcInterface("filter", _ipVersion)) { var rules = iptc.GetRules("test"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test -j ACCEPT", iptc.GetRuleString("test", rules[0])); } Assert.AreEqual(0, IptcInterface.RefCount); } }
public void TestRuleInput() { if (IsLinux) { Assert.AreEqual(0, IptcInterface.RefCount); using (IptcInterface iptc = new IptcInterface("filter", _ipVersion)) { var status = iptc.ExecuteCommand(_ipVersion == 4 ? "iptables -A test2 -d 1.1.1.1 -p tcp -m tcp --dport 80 -j ACCEPT" : "iptables -A test2 -d ::1 -p tcp -m tcp --dport 80 -j ACCEPT"); Assert.AreEqual(1, status, "Expected OK return value"); var rules = iptc.GetRules("test2"); Assert.AreEqual(1, rules.Count); Assert.AreEqual(_ipVersion == 4 ? "-A test2 -d 1.1.1.1/32 -p tcp -m tcp --dport 80 -j ACCEPT" : "-A test2 -d ::1/128 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test2", rules[0])); } Assert.AreEqual(0, IptcInterface.RefCount); } }
public void TestRuleIp() { if (IsLinux) { Assert.AreEqual(0, IptcInterface.RefCount); String ip; int cidr; if (_ipVersion == 4) { ip = IPAddress.Loopback.ToString(); cidr = 32; } else { ip = "::1"; cidr = 128; } var rule = "-A test3 -s " + ip + "/" + cidr + " -p tcp -m tcp --dport 80 -j ACCEPT"; using (IptcInterface iptc = new IptcInterface("filter", _ipVersion)) { iptc.ExecuteCommand("ip6tables " + rule); var rules = iptc.GetRules("test3"); Assert.AreEqual(2, rules.Count); Assert.AreEqual(rule, iptc.GetRuleString("test3", rules[1])); } Assert.AreEqual(0, IptcInterface.RefCount); } }
public void TestRuleInput() { if (IsLinux) { Assert.AreEqual(0, IptcInterface.RefCount); using (IptcInterface iptc = new IptcInterface("filter", _ipVersion)) { var status = iptc.ExecuteCommand(_ipVersion == 4 ? "iptables -A test2 -d 1.1.1.1 -p tcp -m tcp --dport 80 -j ACCEPT" : "iptables -A test2 -d ::1 -p tcp -m tcp --dport 80 -j ACCEPT"); Assert.AreEqual(1, status, "Expected OK return value"); var rules = iptc.GetRules("test2"); Assert.AreEqual(1, rules.Count); Assert.AreEqual(_ipVersion == 4 ? "-A test2 -d 1.1.1.1/32 -p tcp -m tcp --dport 80 -j ACCEPT" : "-A test2 -d ::1/128 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test2", rules[0])); } Assert.AreEqual(0, IptcInterface.RefCount); } }
public void TestRuleInput() { if (IsLinux) { IptcInterface iptc = new IptcInterface("filter"); var status = iptc.ExecuteCommand("iptables -A test2 -d 1.1.1.1 -p tcp -m tcp --dport 80 -j ACCEPT"); Assert.AreEqual(1, status, "Expected OK return value"); var rules = iptc.GetRules("test2"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test2 -d 1.1.1.1/32 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test2", rules[0])); } }
public void TestRuleInput() { if (IsLinux) { IptcInterface iptc = new IptcInterface("filter"); var status = iptc.ExecuteCommand("iptables -A test2 -d 1.1.1.1 -p tcp -m tcp --dport 80 -j ACCEPT"); Assert.AreEqual(1, status, "Expected OK return value"); var rules = iptc.GetRules("test2"); Assert.AreEqual(1, rules.Count); Assert.AreEqual("-A test2 -d 1.1.1.1/32 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test2", rules[0])); } }