Skip to content

Commit

Permalink
better description
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Oct 8, 2018
1 parent 27e6698 commit 26838f6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/releases.rst
Expand Up @@ -21,7 +21,10 @@ unreleased

`git master <https://github.com/meejah/txtorcon>`_ *will likely become v19.0.0*

* `non_anonymous=` flag for :func:`txtorcon.launch`
* introduce `non_anonymous_mode=` kwarg in :func:`txtorcon.launch`
enabling Tor options making Onion Services non-anonymous for the
server (but they use a single hop instead of three to the
Introduction Point so they're slightly faster).


v18.3.0
Expand Down
43 changes: 43 additions & 0 deletions test/test_controller.py
Expand Up @@ -236,6 +236,20 @@ def test_launch_tor_unix_controlport_no_directory(self):
)
self.assertTrue("must exist" in str(ctx.exception))

@defer.inlineCallbacks
def test_launch_tor_non_anonymous_and_socks(self):
reactor = FakeReactor(self, Mock(), None, [9050])
with self.assertRaises(ValueError) as ctx:
yield launch(
reactor,
non_anonymous_mode=True,
socks_port=1234,
tor_binary="/bin/echo",
stdout=Mock(),
stderr=Mock(),
)
self.assertIn("Cannot use SOCKS", str(ctx.exception))

@patch('txtorcon.controller.find_tor_binary', return_value='/bin/echo')
@defer.inlineCallbacks
def test_launch_fails(self, ftb):
Expand Down Expand Up @@ -290,6 +304,35 @@ def foo(*args, **kw):
tor = yield launch(reactor, _tor_config=config)
self.assertTrue(isinstance(tor, Tor))

@patch('txtorcon.controller.find_tor_binary', return_value='/bin/echo')
@patch('txtorcon.controller.TorProcessProtocol')
@defer.inlineCallbacks
def test_successful_launch_non_anonymous(self, tpp, ftb):
trans = FakeProcessTransport()
reactor = FakeReactor(self, trans, lambda p: None, [1, 2, 3])
config = TorConfig()

def boot(arg=None):
config.post_bootstrap.callback(config)
config.__dict__['bootstrap'] = Mock(side_effect=boot)
config.__dict__['attach_protocol'] = Mock(return_value=defer.succeed(None))

def foo(*args, **kw):
rtn = Mock()
rtn.post_bootstrap = defer.succeed(None)
rtn.when_connected = Mock(return_value=defer.succeed(rtn))
return rtn
tpp.side_effect = foo

tor = yield launch(reactor, _tor_config=config, non_anonymous_mode=True)
self.assertTrue(isinstance(tor, Tor))
self.assertTrue(config.HiddenServiceNonAnonymousMode)

with self.assertRaises(Exception):
yield tor.web_agent()
with self.assertRaises(Exception):
yield tor.dns_resolve('meejah.ca')

@defer.inlineCallbacks
def test_quit(self):
tor = Tor(Mock(), Mock())
Expand Down

0 comments on commit 26838f6

Please sign in to comment.