Skip to content

Commit

Permalink
remove circuit-specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Feb 1, 2017
1 parent 769e20b commit 1ed4dfc
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions txtorcon/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,11 @@ def endpointForURI(self, uri):
)


@implementer(IAgentEndpointFactory)
class _AgentEndpointFactoryForCircuit(object):
def __init__(self, reactor, tor_socks_endpoint, circ):
self._reactor = reactor
self._socks_ep = tor_socks_endpoint
self._circ = circ

def endpointForURI(self, uri):
"""IAgentEndpointFactory API"""

# we wire up got_source_port here, between TorSocksEndpoint
# and TorCircuitEndpoint, because this endpointForURI method
# can't return a Deferred. We need that because we must await
# knowing the source-port of the stream we're interested in --
# but the only async method we have available to use is
torsocks = TorSocksEndpoint(
self._socks_ep,
uri.host, uri.port,
tls=uri.scheme == b'https',
)
from txtorcon.circuit import TorCircuitEndpoint
return TorCircuitEndpoint(
self._reactor, self._circ._torstate, self._circ, torsocks,
)
# note to self: put circuit-specific agent back in after, and add
# "circuit=" kwarg too


def tor_agent(reactor, socks_endpoint, circuit=None, pool=None):
def tor_agent(reactor, socks_endpoint, pool=None):
"""
This is the low-level method used by
:meth:`txtorcon.Tor.web_agent` and
Expand All @@ -75,18 +53,13 @@ def tor_agent(reactor, socks_endpoint, circuit=None, pool=None):
:param torconfig: a :class:`txtorcon.TorConfig` instance
:param circuit: If supplied, a particular circuit to use
:param socks_endpoint: Deferred that fires w/
IStreamClientEndpoint (or IStreamClientEndpoint instance)
:param pool: passed on to the Agent (as ``pool=``)
"""

if circuit is not None:
factory = _AgentEndpointFactoryForCircuit(reactor, socks_endpoint, circuit)
else:
factory = _AgentEndpointFactoryUsingTor(reactor, socks_endpoint)
factory = _AgentEndpointFactoryUsingTor(reactor, socks_endpoint)
return Agent.usingEndpointFactory(reactor, factory, pool=pool)


Expand Down

0 comments on commit 1ed4dfc

Please sign in to comment.