implement connections:tcp=disabled
This enables an I2P-only node, which disables TCP entirely (instead of mapping TCP to Tor, which was the only other option that reveal-IP-address=False would allow). closes ticket:2824
This commit is contained in:
parent
02ba2a05c3
commit
a638a97806
|
@ -357,7 +357,7 @@ set the ``tub.location`` option described below.
|
||||||
that defaults to AUTO)
|
that defaults to AUTO)
|
||||||
|
|
||||||
* ``[connections] tcp =`` is set to ``tcp`` (or left as the default),
|
* ``[connections] tcp =`` is set to ``tcp`` (or left as the default),
|
||||||
rather than being set to ``tor``
|
rather than being set to ``tor`` or ``disabled``
|
||||||
|
|
||||||
|
|
||||||
Connection Management
|
Connection Management
|
||||||
|
@ -415,6 +415,12 @@ To hide the Tahoe node's IP address from the servers that it uses, set the
|
||||||
[connections]
|
[connections]
|
||||||
tcp = tor
|
tcp = tor
|
||||||
|
|
||||||
|
You can also disable TCP hints entirely, which would be appropriate when
|
||||||
|
running an I2P-only node::
|
||||||
|
|
||||||
|
[connections]
|
||||||
|
tcp = disabled
|
||||||
|
|
||||||
(Note that I2P does not support connections to normal TCP ports, so
|
(Note that I2P does not support connections to normal TCP ports, so
|
||||||
``[connections] tcp = i2p`` is invalid)
|
``[connections] tcp = i2p`` is invalid)
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,9 @@ class Node(service.MultiService):
|
||||||
# then we remember the default mappings from tahoe.cfg
|
# then we remember the default mappings from tahoe.cfg
|
||||||
self._default_connection_handlers = {"tor": "tor", "i2p": "i2p"}
|
self._default_connection_handlers = {"tor": "tor", "i2p": "i2p"}
|
||||||
tcp_handler_name = self.get_config("connections", "tcp", "tcp").lower()
|
tcp_handler_name = self.get_config("connections", "tcp", "tcp").lower()
|
||||||
|
if tcp_handler_name == "disabled":
|
||||||
|
self._default_connection_handlers["tcp"] = None
|
||||||
|
else:
|
||||||
if tcp_handler_name not in handlers:
|
if tcp_handler_name not in handlers:
|
||||||
raise ValueError("'tahoe.cfg [connections] tcp='"
|
raise ValueError("'tahoe.cfg [connections] tcp='"
|
||||||
" uses unknown handler type '%s'"
|
" uses unknown handler type '%s'"
|
||||||
|
@ -308,7 +311,7 @@ class Node(service.MultiService):
|
||||||
self._default_connection_handlers["tcp"] = tcp_handler_name
|
self._default_connection_handlers["tcp"] = tcp_handler_name
|
||||||
|
|
||||||
if not self._reveal_ip:
|
if not self._reveal_ip:
|
||||||
if self._default_connection_handlers["tcp"] == "tcp":
|
if self._default_connection_handlers.get("tcp") == "tcp":
|
||||||
raise PrivacyError("tcp = tcp, must be set to 'tor'")
|
raise PrivacyError("tcp = tcp, must be set to 'tor'")
|
||||||
|
|
||||||
def set_tub_options(self):
|
def set_tub_options(self):
|
||||||
|
|
|
@ -219,6 +219,8 @@ class Connections(unittest.TestCase):
|
||||||
self.assertEqual(n._default_connection_handlers["tcp"], "tcp")
|
self.assertEqual(n._default_connection_handlers["tcp"], "tcp")
|
||||||
self.assertEqual(n._default_connection_handlers["tor"], "tor")
|
self.assertEqual(n._default_connection_handlers["tor"], "tor")
|
||||||
self.assertEqual(n._default_connection_handlers["i2p"], "i2p")
|
self.assertEqual(n._default_connection_handlers["i2p"], "i2p")
|
||||||
|
n.set_tub_options()
|
||||||
|
n._create_tub()
|
||||||
|
|
||||||
def test_tor(self):
|
def test_tor(self):
|
||||||
n = FakeNode(BASECONFIG+"[connections]\ntcp = tor\n")
|
n = FakeNode(BASECONFIG+"[connections]\ntcp = tor\n")
|
||||||
|
@ -242,6 +244,15 @@ class Connections(unittest.TestCase):
|
||||||
self.assertIn("'tahoe.cfg [connections] tcp='", str(e))
|
self.assertIn("'tahoe.cfg [connections] tcp='", str(e))
|
||||||
self.assertIn("uses unknown handler type 'unknown'", str(e))
|
self.assertIn("uses unknown handler type 'unknown'", str(e))
|
||||||
|
|
||||||
|
def test_tcp_disabled(self):
|
||||||
|
n = FakeNode(BASECONFIG+"[connections]\ntcp = disabled\n")
|
||||||
|
n.init_connections()
|
||||||
|
self.assertEqual(n._default_connection_handlers["tcp"], None)
|
||||||
|
self.assertEqual(n._default_connection_handlers["tor"], "tor")
|
||||||
|
self.assertEqual(n._default_connection_handlers["i2p"], "i2p")
|
||||||
|
n.set_tub_options()
|
||||||
|
n._create_tub()
|
||||||
|
|
||||||
class Privacy(unittest.TestCase):
|
class Privacy(unittest.TestCase):
|
||||||
def test_flag(self):
|
def test_flag(self):
|
||||||
n = FakeNode(BASECONFIG)
|
n = FakeNode(BASECONFIG)
|
||||||
|
@ -266,6 +277,14 @@ class Privacy(unittest.TestCase):
|
||||||
e = self.assertRaises(PrivacyError, n.init_connections)
|
e = self.assertRaises(PrivacyError, n.init_connections)
|
||||||
self.assertEqual(str(e), "tcp = tcp, must be set to 'tor'")
|
self.assertEqual(str(e), "tcp = tcp, must be set to 'tor'")
|
||||||
|
|
||||||
|
def test_connections_tcp_disabled(self):
|
||||||
|
n = FakeNode(BASECONFIG+
|
||||||
|
"[connections]\ntcp = disabled\n"+
|
||||||
|
"[node]\nreveal-IP-address = false\n")
|
||||||
|
n.check_privacy()
|
||||||
|
n.init_connections() # passes privacy check
|
||||||
|
self.assertEqual(n._default_connection_handlers["tcp"], None)
|
||||||
|
|
||||||
def test_tub_location_auto(self):
|
def test_tub_location_auto(self):
|
||||||
n = FakeNode(BASECONFIG+"[node]\nreveal-IP-address = false\n")
|
n = FakeNode(BASECONFIG+"[node]\nreveal-IP-address = false\n")
|
||||||
n._portnumfile = "missing"
|
n._portnumfile = "missing"
|
||||||
|
|
Loading…
Reference in New Issue