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


Python Rule.specbits方法代码示例

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


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

示例1: testMatchState

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:9,代码来源:test_netfilter.py

示例2: testMatchMultiportDports

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:9,代码来源:test_netfilter.py

示例3: testMatchTos

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:9,代码来源:test_netfilter.py

示例4: testMatchTcpSport

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:9,代码来源:test_netfilter.py

示例5: testMatchMark

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:9,代码来源:test_netfilter.py

示例6: testMatchTcpFlags

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:9,代码来源:test_netfilter.py

示例7: testInterfaces

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:10,代码来源:test.py

示例8: testInterfacesNegated

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:11,代码来源:test_netfilter.py

示例9: testSourceDestinationProtocol

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:12,代码来源:test.py

示例10: testSource

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:12,代码来源:test.py

示例11: testInit

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:12,代码来源:test_netfilter.py

示例12: testSourceNegated

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:12,代码来源:test_netfilter.py

示例13: testDestination

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:12,代码来源:test.py

示例14: testDestinationNegated

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:12,代码来源:test_netfilter.py

示例15: testSourceDestinationProtocol

# 需要导入模块: from netfilter.rule import Rule [as 别名]
# 或者: from netfilter.rule.Rule import specbits [as 别名]
 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,代码行数:13,代码来源:test_netfilter.py


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