peer.py 文件源码

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

项目:unmessage 作者: AnemoneLabs 项目源码 文件源码
def _start_server(self, launch_tor):
        self._ui.notify_bootstrap(
            notifications.UnmessageNotification('Configuring local server'))

        endpoint = TCP4ServerEndpoint(self._twisted_reactor,
                                      self._port_local_server,
                                      interface=self._ip_local_server)
        self._twisted_server_endpoint = endpoint

        d = Deferred()

        def endpoint_listening(port):
            self._ui.notify_bootstrap(
                notifications.UnmessageNotification('Running local server'))

            if self._local_mode:
                d.callback(None)
            else:
                d_tor = self._start_tor(launch_tor)
                d_tor.addCallbacks(d.callback, d.errback)

        self._twisted_factory = _ConversationFactory(
            peer=self,
            connection_made=self._add_intro_manager)

        d_server = endpoint.listen(self._twisted_factory)
        d_server.addCallbacks(endpoint_listening, d.errback)

        def run_reactor():
            self._ui.notify_bootstrap(
                notifications.UnmessageNotification('Running reactor'))

            # TODO improve the way the reactor is run
            self._twisted_reactor.run(installSignalHandlers=0)
        thread.start_new_thread(run_reactor, ())

        return d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号