settings.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:ooniprobe-debian 作者: TheTorProject 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号