• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rule.Rule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testInterfacesNegated

 def testInterfacesNegated(self):
     print('Running Test Interfaces Negated...')
     rule = Rule(in_interface='!eth0', out_interface='!eth2',
                 jump='REJECT')
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, '!eth0')
     self.assertEqual(rule.out_interface, '!eth2')
     self.assertEqual(rule.source, None)
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.specbits(), ['!', '-i', 'eth0', '!', '-o', 'eth2', '-j', 'REJECT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:12,代码来源:test_netfilter.py


示例17: testDestinationNegated

 def testDestinationNegated(self):
     print('Running Test Destination Negated...')
     rule = Rule(destination='! 192.168.1.3', jump='REJECT')
     print('\tRule: ' + str(rule))
     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'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:13,代码来源:test_netfilter.py


示例18: testSourceNegated

 def testSourceNegated(self):
     print('Running Test Source Negated...')
     rule = Rule(source='! 104.236.221.27', jump='ACCEPT')
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.protocol, None)
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, '! 104.236.221.27')
     self.assertEqual(rule.destination, None)
     self.assertEqual(rule.jump.name(), 'ACCEPT')
     self.assertEqual(rule.jump.options(), {})
     self.assertEqual(rule.specbits(), ['!', '-s', '104.236.221.27', '-j', 'ACCEPT'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:13,代码来源:test_netfilter.py


示例19: testInit

 def testInit(self):
     print('Rule Test Case Set:\nRunning Test Inital...')
     rule = Rule(jump=Target('ACCEPT'))
     print('\tRule: ' + str(rule))
     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'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:13,代码来源:test_netfilter.py


示例20: testSourceDestinationProtocol

 def testSourceDestinationProtocol(self):
     print('Running Test Source Destination Protocol...')
     rule = Rule(source='104.236.221.27', destination='192.168.1.3',
                 protocol='tcp', jump='DROP')
     print('\tRule: ' + str(rule))
     self.assertEqual(rule.protocol, 'tcp')
     self.assertEqual(rule.in_interface, None)
     self.assertEqual(rule.out_interface, None)
     self.assertEqual(rule.source, '104.236.221.27')
     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', '104.236.221.27', '-d', '192.168.1.3', '-j', 'DROP'])
     print('...Done')
开发者ID:zach-,项目名称:cisc_230_project,代码行数:14,代码来源:test_netfilter.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python netfilterqueue.NetfilterQueue类代码示例发布时间:2022-05-27
下一篇:
Python event_manager.emit函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap