本文整理汇总了Python中twisted.internet.protocol.Protocol.onion方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.onion方法的具体用法?Python Protocol.onion怎么用?Python Protocol.onion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.onion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reconnector
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import onion [as 别名]
def reconnector(self, onion):
protocol = Protocol()
protocol.onion = onion
protocol.connectionLost = lambda failure: self.handleLostConnection(failure, onion)
tor_endpoint = clientFromString(self.reactor, "tor:%s.onion:8060" % onion)
self.onion_pending_map[onion] = connectProtocol(tor_endpoint, protocol)
self.onion_pending_map[onion].addCallback(lambda protocol: self.connection_ready(onion, protocol))
self.onion_pending_map[onion].addErrback(lambda failure: self.connectFail(failure, onion))
示例2: getOnionConnection
# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import onion [as 别名]
def getOnionConnection(self, onion):
""" getOnionConnection returns a deferred which fires
with a client connection to an onion address.
"""
if onion in self.pool:
log.msg("Found onion connection in pool to %s.onion" % onion)
return defer.succeed(self.pool[onion])
else:
log.msg("Did not find connection to %s.onion in pool" % onion)
tor_endpoint = clientFromString(
self.reactor, "tor:%s.onion:80" % onion)
print(tor_endpoint)
p = Protocol()
p.onion = onion
d = connectProtocol(tor_endpoint, p)
def add_to_pool(result):
self.pool[onion] = result
d.addCallback(add_to_pool)
return d