本文整理汇总了Python中txtorcon.router.Router.policy方法的典型用法代码示例。如果您正苦于以下问题:Python Router.policy方法的具体用法?Python Router.policy怎么用?Python Router.policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.router.Router
的用法示例。
在下文中一共展示了Router.policy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_policy_error
# 需要导入模块: from txtorcon.router import Router [as 别名]
# 或者: from txtorcon.router.Router import policy [as 别名]
def test_policy_error(self):
router = Router(object())
try:
router.policy = 'foo 123'
self.fail()
except Exception, e:
self.assertTrue("Don't understand" in str(e))
示例2: test_policy_accept
# 需要导入模块: from txtorcon.router import Router [as 别名]
# 或者: from txtorcon.router.Router import policy [as 别名]
def test_policy_accept(self):
controller = object()
router = Router(controller)
router.update("foo",
"AHhuQ8zFQJdT8l42Axxc6m6kNwI",
"MAANkj30tnFvmoh7FsjVFr+cmcs",
"2011-12-16 15:11:34",
"77.183.225.114",
"24051", "24052")
router.policy = "accept 25,128-256".split()
self.assertTrue(router.accepts_port(25))
for x in range(128, 256):
self.assertTrue(router.accepts_port(x))
self.assertTrue(not router.accepts_port(26))
self.assertEqual(router.policy, 'accept 25,128-256')
示例3: test_policy_reject
# 需要导入模块: from txtorcon.router import Router [as 别名]
# 或者: from txtorcon.router.Router import policy [as 别名]
def test_policy_reject(self):
controller = object()
router = Router(controller)
router.update("foo",
"AHhuQ8zFQJdT8l42Axxc6m6kNwI",
"MAANkj30tnFvmoh7FsjVFr+cmcs",
"2011-12-16 15:11:34",
"77.183.225.114",
"24051", "24052")
router.policy = "reject 500-600,655,7766".split()
for x in range(1, 500):
self.assertTrue(router.accepts_port(x))
for x in range(500, 601):
self.assertTrue(not router.accepts_port(x))
self.assertEqual(router.policy, 'reject 500-600,655,7766')