reenable TorManager
This commit is contained in:
parent
4234e79161
commit
9ca657a7c6
|
@ -30,6 +30,7 @@ class Boss(object):
|
||||||
_welcome_handler = attrib() # TODO: validator: callable
|
_welcome_handler = attrib() # TODO: validator: callable
|
||||||
_reactor = attrib()
|
_reactor = attrib()
|
||||||
_journal = attrib(validator=provides(_interfaces.IJournal))
|
_journal = attrib(validator=provides(_interfaces.IJournal))
|
||||||
|
_tor_manager = attrib() # TODO: ITorManager or None
|
||||||
_timing = attrib(validator=provides(_interfaces.ITiming))
|
_timing = attrib(validator=provides(_interfaces.ITiming))
|
||||||
m = MethodicalMachine()
|
m = MethodicalMachine()
|
||||||
@m.setTrace()
|
@m.setTrace()
|
||||||
|
@ -44,7 +45,7 @@ class Boss(object):
|
||||||
self._R = Receive(self._side, self._timing)
|
self._R = Receive(self._side, self._timing)
|
||||||
self._RC = RendezvousConnector(self._url, self._appid, self._side,
|
self._RC = RendezvousConnector(self._url, self._appid, self._side,
|
||||||
self._reactor, self._journal,
|
self._reactor, self._journal,
|
||||||
self._timing)
|
self._tor_manager, self._timing)
|
||||||
self._L = Lister()
|
self._L = Lister()
|
||||||
self._C = Code(self._timing)
|
self._C = Code(self._timing)
|
||||||
self._T = Terminator()
|
self._T = Terminator()
|
||||||
|
|
|
@ -27,6 +27,8 @@ class ITerminator(Interface):
|
||||||
|
|
||||||
class ITiming(Interface):
|
class ITiming(Interface):
|
||||||
pass
|
pass
|
||||||
|
class ITorManager(Interface):
|
||||||
|
pass
|
||||||
|
|
||||||
class IJournal(Interface): # TODO: this needs to be public
|
class IJournal(Interface): # TODO: this needs to be public
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -69,6 +69,7 @@ class RendezvousConnector(object):
|
||||||
_side = attrib(validator=instance_of(type(u"")))
|
_side = attrib(validator=instance_of(type(u"")))
|
||||||
_reactor = attrib()
|
_reactor = attrib()
|
||||||
_journal = attrib(validator=provides(_interfaces.IJournal))
|
_journal = attrib(validator=provides(_interfaces.IJournal))
|
||||||
|
_tor_manager = attrib() # TODO: ITorManager or None
|
||||||
_timing = attrib(validator=provides(_interfaces.ITiming))
|
_timing = attrib(validator=provides(_interfaces.ITiming))
|
||||||
|
|
||||||
def __attrs_post_init__(self):
|
def __attrs_post_init__(self):
|
||||||
|
@ -88,7 +89,8 @@ class RendezvousConnector(object):
|
||||||
self._trace(old_state="", input=what, new_state="")
|
self._trace(old_state="", input=what, new_state="")
|
||||||
|
|
||||||
def _make_endpoint(self, hostname, port):
|
def _make_endpoint(self, hostname, port):
|
||||||
# TODO: Tor goes here
|
if self._tor_manager:
|
||||||
|
return self._tor_manager.get_endpoint_for(hostname, port)
|
||||||
return endpoints.HostnameEndpoint(self._reactor, hostname, port)
|
return endpoints.HostnameEndpoint(self._reactor, hostname, port)
|
||||||
|
|
||||||
def wire(self, boss, nameplate, mailbox, code, lister, terminator):
|
def wire(self, boss, nameplate, mailbox, code, lister, terminator):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import sys, re
|
import sys, re
|
||||||
import six
|
import six
|
||||||
|
from zope.interface import implementer
|
||||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
from twisted.internet.error import ConnectError
|
from twisted.internet.error import ConnectError
|
||||||
from twisted.internet.endpoints import clientFromString
|
from twisted.internet.endpoints import clientFromString
|
||||||
|
@ -14,9 +15,12 @@ except ImportError:
|
||||||
TorClientEndpoint = None
|
TorClientEndpoint = None
|
||||||
DEFAULT_VALUE = "DEFAULT_VALUE"
|
DEFAULT_VALUE = "DEFAULT_VALUE"
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
from . import _interfaces
|
||||||
from .timing import DebugTiming
|
from .timing import DebugTiming
|
||||||
from .transit import allocate_tcp_port
|
from .transit import allocate_tcp_port
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(_interfaces.ITorManager)
|
||||||
class TorManager:
|
class TorManager:
|
||||||
def __init__(self, reactor, launch_tor=False, tor_control_port=None,
|
def __init__(self, reactor, launch_tor=False, tor_control_port=None,
|
||||||
timing=None, stderr=sys.stderr):
|
timing=None, stderr=sys.stderr):
|
||||||
|
|
|
@ -276,7 +276,8 @@ def create(appid, relay_url, reactor, delegate=None, journal=None,
|
||||||
w = _DelegatedWormhole(delegate)
|
w = _DelegatedWormhole(delegate)
|
||||||
else:
|
else:
|
||||||
w = _DeferredWormhole()
|
w = _DeferredWormhole()
|
||||||
b = Boss(w, side, relay_url, appid, welcome_handler, reactor, journal, timing)
|
b = Boss(w, side, relay_url, appid, welcome_handler, reactor, journal,
|
||||||
|
tor_manager, timing)
|
||||||
w._set_boss(b)
|
w._set_boss(b)
|
||||||
b.start()
|
b.start()
|
||||||
return w
|
return w
|
||||||
|
|
Loading…
Reference in New Issue
Block a user