def do_start(self):
"""
make this transport begin listening on the specified interface and UDP port
interface must be an IP address
"""
# save a TorConfig so we can later use it to send messages
self.torconfig = txtorcon.TorConfig(control=self.tor.protocol)
yield self.torconfig.post_bootstrap
hs_strings = []
if len(self.onion_unix_socket) == 0:
local_socket_endpoint_desc = "tcp:interface=%s:%s" % (self.onion_tcp_interface_ip, self.onion_tcp_port)
else:
local_socket_endpoint_desc = "unix:%s" % self.onion_unix_socket
onion_service_endpoint = endpoints.serverFromString(self.reactor, local_socket_endpoint_desc)
datagram_proxy_factory = OnionDatagramProxyFactory(received_handler=lambda x: self.datagram_received(x))
yield onion_service_endpoint.listen(datagram_proxy_factory)
if len(self.onion_unix_socket) == 0:
hs_strings.append("%s %s:%s" % (self.onion_port, self.onion_tcp_interface_ip, self.onion_tcp_port))
else:
hs_strings.append("%s unix:%s" % (self.onion_port, self.onion_unix_socket))
hs = txtorcon.torconfig.EphemeralHiddenService(hs_strings, key_blob_or_type=self.onion_key)
yield hs.add_to_tor(self.tor.protocol)
评论列表
文章目录