Ejemplo n.º 1
0
 def test_port_src_and_dst_rule_all_fail(self):
     rule = IPPortRule(protocol='UDP', src_lo=0, src_hi=1, src_ip='127.0.0.0/24', dst_ip='127.0.0.0/24')
     packet = FakePacket(protocol=socket.IPPROTO_UDP, src_port=5, src_ip='128.0.0.0', dst_ip='128.0.0.0')
     self.assertFalse(rule.filter_condition(packet))
Ejemplo n.º 2
0
 def test_port_src_and_dst_rule_src_and_dst_fail(self):
     rule = IPPortRule(protocol='UDP', src_lo=0, src_hi=1, src_ip='127.0.0.0/24', dst_ip='127.0.0.0/24')
     packet = FakePacket(protocol=socket.IPPROTO_UDP, src_port=0, src_ip='128.0.0.0', dst_ip='128.0.0.0')
     self.assertFalse(rule.filter_condition(packet))
Ejemplo n.º 3
0
 def test_port_and_dst_rule_both_match(self):
     rule = IPPortRule(protocol='UDP', src_lo=0, src_hi=1, dst_ip='127.0.0.0/24')
     packet = FakePacket(protocol=socket.IPPROTO_UDP, src_port=0, dst_ip='127.0.0.0')
     self.assertTrue(rule.filter_condition(packet))
Ejemplo n.º 4
0
 def test_port_rule_only_match(self):
     rule = IPPortRule(protocol='UDP', src_lo=0, src_hi=1)
     packet = FakePacket(protocol=socket.IPPROTO_UDP, src_port=0)
     self.assertTrue(rule.filter_condition(packet))
Ejemplo n.º 5
0
 def test_port_and_src_rule_port_fails(self):
     rule = IPPortRule(protocol='UDP', src_lo=0, src_hi=1, src_ip='127.0.0.0/24')
     packet = FakePacket(protocol=socket.IPPROTO_TCP, src_port=0, src_ip='127.0.0.0')
     self.assertFalse(rule.filter_condition(packet))