当前位置: 首页>>代码示例>>Python>>正文


Python txtorlog.msg函数代码示例

本文整理汇总了Python中txtorcon.log.txtorlog.msg函数的典型用法代码示例。如果您正苦于以下问题:Python msg函数的具体用法?Python msg怎么用?Python msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: circuit_failed

 def circuit_failed(self, circuit, **kw):
     "ICircuitListener API"
     txtorlog.msg("circuit_failed", circuit, str(kw))
     circuit._when_built.fire(
         Failure(Exception("Circuit failed ('{}')".format(_extract_reason(kw))))
     )
     self.circuit_destroy(circuit)
开发者ID:felipedau,项目名称:txtorcon,代码行数:7,代码来源:torstate.py

示例2: _bootstrap

    def _bootstrap(self, *args):
        """
        The inlineCallbacks decorator allows us to make this method
        look synchronous; see the Twisted docs. Each yeild is for a
        Deferred after which the method continues. When this method
        finally exits, we're set up and do the post_bootstrap
        callback.
        """

        ## unfortunately I don't see a way to get this from the runing
        ## tor like the events...so this was taken from some version
        ## of the control-spec and must be kept up-to-date (or accpet
        ## any signal name and just wait for the reply?
        self.valid_signals = ["RELOAD", "DUMP", "DEBUG", "NEWNYM", "CLEARDNSCACHE"]

        self.version = yield self.get_info('version')
        self.version = self.version['version']
        txtorlog.msg("Connected to a Tor with VERSION", self.version)
        eventnames = yield self.get_info('events/names')
        eventnames = eventnames['events/names']
        self._set_valid_events(eventnames)

        yield self.queue_command('USEFEATURE EXTENDED_EVENTS')

        self.post_bootstrap.callback(self)
        self.post_bootstrap = None
        defer.returnValue(self)
开发者ID:hellais,项目名称:txtorcon,代码行数:27,代码来源:torcontrolprotocol.py

示例3: _bootstrap

    def _bootstrap(self, *args):
        """
        The inlineCallbacks decorator allows us to make this method
        look synchronous; see the Twisted docs. Each yeild is for a
        Deferred after which the method continues. When this method
        finally exits, we're set up and do the post_bootstrap
        callback.
        """

        try:
            self.valid_signals = yield self.get_info('signal/names')
            self.valid_signals = self.valid_signals['signal/names']
        except TorProtocolError:
            self.valid_signals = ["RELOAD", "DUMP", "DEBUG", "NEWNYM",
                                  "CLEARDNSCACHE"]

        self.version = yield self.get_info('version')
        self.version = self.version['version']
        txtorlog.msg("Connected to a Tor with VERSION", self.version)
        eventnames = yield self.get_info('events/names')
        eventnames = eventnames['events/names']
        self._set_valid_events(eventnames)

        yield self.queue_command('USEFEATURE EXTENDED_EVENTS')

        self.post_bootstrap.callback(self)
        defer.returnValue(self)
开发者ID:david415,项目名称:txtorcon,代码行数:27,代码来源:torcontrolprotocol.py

示例4: stream_attach

 def stream_attach(self, stream, circuit):
     """
     IStreamListener: the stream has been attached to a circuit. It
     seems you get an attach to None followed by an attach to real
     circuit fairly frequently. Perhaps related to __LeaveStreamsUnattached?
     """
     txtorlog.msg("stream_attach", stream.id, stream.target_host, " -> ", circuit)
开发者ID:aagbsn,项目名称:txtorcon,代码行数:7,代码来源:torstate.py

示例5: circuit_destroy

 def circuit_destroy(self, circuit):
     "Used by circuit_closed and circuit_failed (below)"
     txtorlog.msg("circuit_destroy:", circuit.id)
     circuit._when_built.fire(
         Failure(Exception("Destroying circuit; will never hit BUILT"))
     )
     del self.circuits[circuit.id]
开发者ID:meejah,项目名称:txtorcon,代码行数:7,代码来源:torstate.py

示例6: issue_stream_attach

        def issue_stream_attach(circ):
            txtorlog.msg("circuit:", circ)
            if circ is None or circ is TorState.DO_NOT_ATTACH:
                # tell Tor to do what it likes
                return self.protocol.queue_command(
                    u"ATTACHSTREAM {} 0".format(stream.id).encode("ascii")
                )

            else:
                # should get a Circuit instance; check it for suitability
                if not isinstance(circ, Circuit):
                    raise RuntimeError(
                        "IStreamAttacher.attach() must return a Circuit instance "
                        "(or None or DO_NOT_ATTACH): %s"
                    )
                if circ.id not in self.circuits:
                    raise RuntimeError(
                        "Attacher returned a circuit unknown to me."
                    )
                if circ.state != 'BUILT':
                    raise RuntimeError(
                        "Can only attach to BUILT circuits; %d is in %s." %
                        (circ.id, circ.state)
                    )
                # we've got a valid Circuit instance; issue the command
                return self.protocol.queue_command(
                    u"ATTACHSTREAM {} {}".format(stream.id, circ.id).encode("ascii")
                )
开发者ID:meejah,项目名称:txtorcon,代码行数:28,代码来源:torstate.py

示例7: circuit_built

 def circuit_built(self, circuit):
     "ICircuitListener API"
     txtorlog.msg(
         "circuit_built:", circuit.id,
         "->".join("%s.%s" % (x.name, x.location.countrycode) for x in circuit.path),
         circuit.streams
     )
开发者ID:ghtdak,项目名称:txtorcon,代码行数:7,代码来源:torstate.py

示例8: tor_connected

    def tor_connected(self, proto):
        txtorlog.msg("tor_connected %s" % proto)

        self.tor_protocol = proto
        if self.config is not None:
            self.config._update_proto(proto)
        self.tor_protocol.is_owned = self.transport.pid
        self.tor_protocol.post_bootstrap.addCallback(self.protocol_bootstrapped).addErrback(self.tor_connection_failed)
开发者ID:arlolra,项目名称:txtorcon,代码行数:8,代码来源:torconfig.py

示例9: stream_closed

    def stream_closed(self, stream, **kw):
        """
        IStreamListener: stream has been closed (won't be in
        controller's list anymore)
        """

        txtorlog.msg("stream_closed", stream.id)
        del self.streams[stream.id]
开发者ID:enriquefynn,项目名称:txtorcon,代码行数:8,代码来源:torstate.py

示例10: stream_failed

    def stream_failed(self, stream, **kw):
        """
        IStreamListener: stream failed for some reason (won't be in
        controller's list anymore)
        """

        txtorlog.msg("stream_failed", stream.id)
        del self.streams[stream.id]
开发者ID:enriquefynn,项目名称:txtorcon,代码行数:8,代码来源:torstate.py

示例11: protocol_bootstrapped

    def protocol_bootstrapped(self, proto):
        txtorlog.msg("Protocol is bootstrapped")

        self.tor_protocol.add_event_listener('STATUS_CLIENT', self.status_client)

        ## FIXME: should really listen for these to complete as well
        ## as bootstrap etc. For now, we'll be optimistic.
        self.tor_protocol.queue_command('TAKEOWNERSHIP')
        self.tor_protocol.queue_command('RESETCONF __OwningControllerProcess')
开发者ID:gsathya,项目名称:txtorcon,代码行数:9,代码来源:torconfig.py

示例12: _maybe_attach

    def _maybe_attach(self, stream):
        """
        If we've got a custom stream-attachment instance (see
        set_attacher) this will ask it for the appropriate
        circuit. Note that we ignore .exit URIs and let Tor deal with
        those (by passing circuit ID 0).

        The stream attacher is allowed to return a Deferred which will
        callback with the desired circuit.

        You may return the special object DO_NOT_ATTACH which will
        cause the circuit attacher to simply ignore the stream
        (neither attaching it, nor telling Tor to attach it).
        """

        if self.attacher:
            if stream.target_host is not None and ".exit" in stream.target_host:
                # we want to totally ignore .exit URIs as these are
                # used to specify a particular exit node, and trying
                # to do STREAMATTACH on them will fail with an error
                # from Tor anyway.
                txtorlog.msg("ignore attacher:", stream)
                return

            circ = self.attacher.attach_stream(stream, self.circuits)
            if circ is self.DO_NOT_ATTACH:
                return

            if circ is None:
                self.protocol.queue_command("ATTACHSTREAM %d 0" % stream.id)

            else:
                if isinstance(circ, defer.Deferred):

                    class IssueStreamAttach:
                        def __init__(self, state, streamid):
                            self.stream_id = streamid
                            self.state = state

                        def __call__(self, arg):
                            if arg is None:
                                return self.state.protocol.queue_command("ATTACHSTREAM %d 0" % stream.id)
                            else:
                                circid = arg.id
                                return self.state.protocol.queue_command(
                                    "ATTACHSTREAM %d %d" % (self.stream_id, circid)
                                )

                    circ.addCallback(IssueStreamAttach(self, stream.id))
                    circ.addErrback(log.err)

                else:
                    if circ.id not in self.circuits:
                        raise RuntimeError("Attacher returned a circuit unknown to me.")
                    if circ.state != "BUILT":
                        raise RuntimeError("Can only attach to BUILT circuits; %d is in %s." % (circ.id, circ.state))
                    self.protocol.queue_command("ATTACHSTREAM %d %d" % (stream.id, circ.id))
开发者ID:isislovecruft,项目名称:txtorcon,代码行数:57,代码来源:torstate.py

示例13: circuit_failed

 def circuit_failed(self, circuit, **kw):
     "ICircuitListener API"
     txtorlog.msg("circuit_failed", circuit, str(kw))
     circuit._when_built.fire(
         Failure(
             CircuitBuildFailedError(_extract_reason(kw))
         )
     )
     self.circuit_destroy(circuit)
开发者ID:meejah,项目名称:txtorcon,代码行数:9,代码来源:torstate.py

示例14: agent_for_socks_port

def agent_for_socks_port(reactor, torconfig, socks_config, pool=None):
    """
    This returns a Deferred that fires with an object that implements
    :class:`twisted.web.iweb.IAgent` and is thus suitable for passing
    to ``treq`` as the ``agent=`` kwarg. Of course can be used
    directly; see `using Twisted web cliet
    <http://twistedmatrix.com/documents/current/web/howto/client.html>`_. If
    you have a :class:`txtorcon.Tor` instance already, the preferred
    API is to call :meth:`txtorcon.Tor.web_agent` on it.

    :param torconfig: a :class:`txtorcon.TorConfig` instance.

    :param socks_config: anything valid for Tor's ``SocksPort``
        option. This is generally just a TCP port (e.g. ``9050``), but
        can also be a unix path like so ``unix:/path/to/socket`` (Tor
        has restrictions on the ownership/permissions of the directory
        containing ``socket``). If the given SOCKS option is not
        already available in the underlying Tor instance, it is
        re-configured to add the SOCKS option.
    """
    # :param tls: True (the default) will use Twisted's default options
    #     with the hostname in the URI -- that is, TLS verification
    #     similar to a Browser. Otherwise, you can pass whatever Twisted
    #     returns for `optionsForClientTLS
    #     <https://twistedmatrix.com/documents/current/api/twisted.internet.ssl.optionsForClientTLS.html>`_

    socks_config = str(socks_config)  # sadly, all lists are lists-of-strings to Tor :/
    if socks_config not in torconfig.SocksPort:
        txtorlog.msg("Adding SOCKS port '{}' to Tor".format(socks_config))
        torconfig.SocksPort.append(socks_config)
        try:
            yield torconfig.save()
        except Exception as e:
            raise RuntimeError(
                "Failed to reconfigure Tor with SOCKS port '{}': {}".format(
                    socks_config, str(e)
                )
            )

    if socks_config.startswith('unix:'):
        socks_ep = UNIXClientEndpoint(reactor, socks_config[5:])
    else:
        if ':' in socks_config:
            host, port = socks_config.split(':', 1)
        else:
            host = '127.0.0.1'
            port = int(socks_config)
        socks_ep = TCP4ClientEndpoint(reactor, host, port)

    returnValue(
        Agent.usingEndpointFactory(
            reactor,
            _AgentEndpointFactoryUsingTor(reactor, socks_ep),
            pool=pool,
        )
    )
开发者ID:meejah,项目名称:txtorcon,代码行数:56,代码来源:web.py

示例15: connectionLost

 def connectionLost(self, reason):
     "Protocol API"
     txtorlog.msg('connection terminated: ' + str(reason))
     if self.on_disconnect.callbacks:
         if reason.check(ConnectionDone):
             self.on_disconnect.callback(self)
         else:
             self.on_disconnect.errback(reason)
     self.on_disconnect = None
     return None
开发者ID:david415,项目名称:txtorcon,代码行数:10,代码来源:torcontrolprotocol.py


注:本文中的txtorcon.log.txtorlog.msg函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。