本文整理汇总了Python中txtorcon.TCPHiddenServiceEndpoint.system_tor方法的典型用法代码示例。如果您正苦于以下问题:Python TCPHiddenServiceEndpoint.system_tor方法的具体用法?Python TCPHiddenServiceEndpoint.system_tor怎么用?Python TCPHiddenServiceEndpoint.system_tor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.TCPHiddenServiceEndpoint
的用法示例。
在下文中一共展示了TCPHiddenServiceEndpoint.system_tor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_system_tor
# 需要导入模块: from txtorcon import TCPHiddenServiceEndpoint [as 别名]
# 或者: from txtorcon.TCPHiddenServiceEndpoint import system_tor [as 别名]
def test_system_tor(self):
from test_torconfig import FakeControlProtocol
def boom(*args):
# why does the new_callable thing need a callable that
# returns a callable? Feels like I must be doing something
# wrong somewhere...
def bam(*args, **kw):
return self.protocol
return bam
with patch('txtorcon.endpoints.launch_tor') as launch_mock:
with patch('txtorcon.endpoints.build_tor_connection', new_callable=boom) as btc:
client = clientFromString(
self.reactor,
"tcp:host=localhost:port=9050"
)
ep = yield TCPHiddenServiceEndpoint.system_tor(self.reactor,
client, 80)
port = yield ep.listen(NoOpProtocolFactory())
toa = port.getHost()
self.assertTrue(hasattr(toa, 'onion_uri'))
self.assertTrue(hasattr(toa, 'onion_port'))
port.startListening()
str(port)
port.tor_config
# system_tor should be connecting to a running one,
# *not* launching a new one.
self.assertFalse(launch_mock.called)
示例2: test_progress_updates_system_tor
# 需要导入模块: from txtorcon import TCPHiddenServiceEndpoint [as 别名]
# 或者: from txtorcon.TCPHiddenServiceEndpoint import system_tor [as 别名]
def test_progress_updates_system_tor(self, ftb):
control_ep = Mock()
control_ep.connect = Mock(return_value=defer.succeed(None))
directlyProvides(control_ep, IStreamClientEndpoint)
ep = TCPHiddenServiceEndpoint.system_tor(self.reactor, control_ep, 1234)
ep._tor_progress_update(40, "FOO", "foo to bar")
return ep
示例3: __test_progress_updates_system_tor
# 需要导入模块: from txtorcon import TCPHiddenServiceEndpoint [as 别名]
# 或者: from txtorcon.TCPHiddenServiceEndpoint import system_tor [as 别名]
def __test_progress_updates_system_tor(self):
ep = TCPHiddenServiceEndpoint.system_tor(self.reactor, 1234)
ep._tor_progress_update(40, "FOO", "foo to bar")
return ep