當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。