本文整理汇总了Python中txtorcon.TorConfig.ORPort方法的典型用法代码示例。如果您正苦于以下问题:Python TorConfig.ORPort方法的具体用法?Python TorConfig.ORPort怎么用?Python TorConfig.ORPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.TorConfig
的用法示例。
在下文中一共展示了TorConfig.ORPort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic_launch
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import ORPort [as 别名]
def test_basic_launch(self):
config = TorConfig()
config.ORPort = 1234
config.SOCKSPort = 9999
def connector(proto, trans):
proto._set_valid_events('STATUS_CLIENT')
proto.makeConnection(trans)
proto.post_bootstrap.callback(proto)
return proto.post_bootstrap
class OnProgress:
def __init__(self, test, expected):
self.test = test
self.expected = expected
def __call__(self, percent, tag, summary):
self.test.assertEqual(self.expected[0], (percent, tag, summary))
self.expected = self.expected[1:]
self.test.assertTrue('"' not in summary)
self.test.assertTrue(percent >= 0 and percent <= 100)
def on_protocol(proto):
proto.outReceived('Bootstrapped 100%\n')
proto.progress = OnProgress(self, [(90, 'circuit_create', 'Establishing a Tor circuit'),
(100, 'done', 'Done')])
trans = FakeProcessTransport()
trans.protocol = self.protocol
self.othertrans = trans
fakeout = StringIO()
fakeerr = StringIO()
creator = functools.partial(connector, self.protocol, self.transport)
d = launch_tor(config, FakeReactor(self, trans, on_protocol), connection_creator=creator, tor_binary='/bin/echo', stdout=fakeout, stderr=fakeerr)
d.addCallback(self.setup_complete_no_errors, config, fakeout, fakeerr)
return d