def check_tor(self):
"""
Called only when we must start tor by director.start
"""
from ooni.utils.net import ConnectAndCloseProtocol, connectProtocol
incoherent = []
if not self.advanced.start_tor:
if self.tor.socks_port is None:
incoherent.append('tor:socks_port')
else:
socks_port_ep = TCP4ClientEndpoint(reactor,
"localhost",
self.tor.socks_port)
try:
yield connectProtocol(socks_port_ep, ConnectAndCloseProtocol())
except Exception:
incoherent.append('tor:socks_port')
if self.tor.control_port is not None:
if isinstance(self.tor.control_port, int):
control_port_ep = TCP4ClientEndpoint(reactor,
"localhost",
self.tor.control_port)
try:
yield connectProtocol(control_port_ep, ConnectAndCloseProtocol())
except Exception:
incoherent.append('tor:control_port')
else:
conf_unix_socket_path = self.tor.control_port.lstrip()
if conf_unix_socket_path.startswith("unix:"):
if os.path.exists(conf_unix_socket_path.lstrip("unix:")):
unix_socket_path = conf_unix_socket_path.lstrip("unix:")
else:
incoherent.append('tor:control_port')
else:
incoherent.append('tor:control_port')
self.log_incoherences(incoherent)
评论列表
文章目录