当前位置: 首页>>代码示例>>Python>>正文


Python rule.Rule类代码示例

本文整理汇总了Python中netfilter.rule.Rule的典型用法代码示例。如果您正苦于以下问题:Python Rule类的具体用法?Python Rule怎么用?Python Rule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Rule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMatchState

 def testMatchState(self):
     print('Running Test Match State...')
     rule = Rule(jump='ACCEPT')
     rule.matches.append(Match('state', '--state ESTABLISHED,RELATED'))
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.specbits(), ['-m', 'state', '--state', 'ESTABLISHED,RELATED', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:7,代码来源:test_netfilter.py

示例2: testMatchMultiportDports

 def testMatchMultiportDports(self):
     print('Running Test Match Mulitport Dports...')
     rule = Rule(jump='ACCEPT')
     rule.matches.append(Match('multiport', '--dports 20,21,22,80,25,1720'))
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.specbits(), ['-m', 'multiport', '--dports', '20,21,22,80,25,1720', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:7,代码来源:test_netfilter.py

示例3: testMatchTos

 def testMatchTos(self):
     print('Running Test Match TOS...')
     rule = Rule(jump='ACCEPT')
     rule.matches.append(Match('tos', '--tos 0x10'))
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.specbits(), ['-m', 'tos', '--tos', '0x10', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:7,代码来源:test_netfilter.py

示例4: testMatchTcpSport

 def testMatchTcpSport(self):
     print('Running Test Match TCP SPort...')
     rule = Rule(protocol='tcp', jump='ACCEPT')
     rule.matches.append(Match('tcp', '--sport 1234'))
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.specbits(), ['-p', 'tcp', '-m', 'tcp', '--sport', '1234', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:7,代码来源:test_netfilter.py

示例5: testMatchMark

 def testMatchMark(self):
     print('Running Test Match Mark...')
     rule = Rule(jump='ACCEPT')
     rule.matches.append(Match('mark', '--mark 0x64'))
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.specbits(), ['-m', 'mark', '--mark', '0x64', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:7,代码来源:test_netfilter.py

示例6: testMatchTcpFlags

 def testMatchTcpFlags(self):
     print('Running Test Match TCP Flags...')
     rule = Rule(protocol='tcp', jump='ACCEPT')
     rule.matches.append(Match('tcp', '--tcp-flags ACK,SYN ACK'))
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.specbits(), ['-p', 'tcp', '-m', 'tcp', '--tcp-flags', 'ACK,SYN', 'ACK', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:7,代码来源:test_netfilter.py

示例7: testInterfaces

 def testInterfaces(self):
     rule = Rule(in_interface="eth1", out_interface="eth2", jump="REJECT")
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, "eth1")
     self.assertEqual(rule.out_interface, "eth2")
     self.assertEqual(rule.source, None)
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.specbits(), ["-i", "eth1", "-o", "eth2", "-j", "REJECT"])
开发者ID:mankuthimma,项目名称:junXon,代码行数:8,代码来源:test.py

示例8: testInterfacesNegated

 def testInterfacesNegated(self):
     rule = Rule(in_interface='!eth1', out_interface='!eth2',
         jump='REJECT')
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, '!eth1')
     self.assertEqual(rule.out_interface, '!eth2')
     self.assertEqual(rule.source, None)
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.specbits(), ['!', '-i', 'eth1', '!', '-o', 'eth2', '-j', 'REJECT'])
开发者ID:hetgi,项目名称:python-netfilter,代码行数:9,代码来源:test_netfilter.py

示例9: testSourceDestinationProtocol

 def testSourceDestinationProtocol(self):
     rule = Rule(source="192.168.1.2", destination="192.168.1.3", protocol="tcp", jump="DROP")
     self.assertEqual(rule.protocol, "tcp")
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, "192.168.1.2")
     self.assertEqual(rule.destination, "192.168.1.3")
     self.assertEqual(rule.jump.name(), "DROP")
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ["-p", "tcp", "-s", "192.168.1.2", "-d", "192.168.1.3", "-j", "DROP"])
开发者ID:mankuthimma,项目名称:junXon,代码行数:10,代码来源:test.py

示例10: testSource

 def testSource(self):
     rule = Rule(source="192.168.1.2", jump="ACCEPT")
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, "192.168.1.2")
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.jump.name(), "ACCEPT")
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ["-s", "192.168.1.2", "-j", "ACCEPT"])
开发者ID:mankuthimma,项目名称:junXon,代码行数:10,代码来源:test.py

示例11: testInit

 def testInit(self):
     rule = Rule(jump=Target('ACCEPT'))
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, None)
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.jump.name(), 'ACCEPT')
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ['-j', 'ACCEPT'])
开发者ID:hetgi,项目名称:python-netfilter,代码行数:10,代码来源:test_netfilter.py

示例12: testSourceNegated

 def testSourceNegated(self):
     rule = Rule(source='! 192.168.1.2', jump='ACCEPT')
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, '! 192.168.1.2')
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.jump.name(), 'ACCEPT')
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ['!', '-s', '192.168.1.2', '-j', 'ACCEPT'])
开发者ID:hetgi,项目名称:python-netfilter,代码行数:10,代码来源:test_netfilter.py

示例13: testDestination

 def testDestination(self):
     rule = Rule(destination="192.168.1.3", jump="REJECT")
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, None)
     self.assertEqual(rule.destination, "192.168.1.3")
     self.assertEqual(rule.jump.name(), "REJECT")
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ["-d", "192.168.1.3", "-j", "REJECT"])
开发者ID:mankuthimma,项目名称:junXon,代码行数:10,代码来源:test.py

示例14: testDestinationNegated

 def testDestinationNegated(self):
     rule = Rule(destination='! 192.168.1.3', jump='REJECT')
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, None)
     self.assertEqual(rule.destination, '! 192.168.1.3')
     self.assertEqual(rule.jump.name(), 'REJECT')
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ['!', '-d', '192.168.1.3', '-j', 'REJECT'])
开发者ID:hetgi,项目名称:python-netfilter,代码行数:10,代码来源:test_netfilter.py

示例15: testSourceDestinationProtocol

 def testSourceDestinationProtocol(self):
     rule = Rule(source='192.168.1.2', destination='192.168.1.3',
         protocol='tcp', jump='DROP')
     self.assertEqual(rule.protocol, 'tcp')
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, '192.168.1.2')
     self.assertEqual(rule.destination, '192.168.1.3')
     self.assertEqual(rule.jump.name(), 'DROP')
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ['-p', 'tcp', '-s', '192.168.1.2', '-d', '192.168.1.3', '-j', 'DROP'])
开发者ID:hetgi,项目名称:python-netfilter,代码行数:11,代码来源:test_netfilter.py


注:本文中的netfilter.rule.Rule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。