From 117befd8986596f1b6903a68076aad75da4a0b7c Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Mon, 23 Aug 2021 02:34:32 +0100 Subject: [PATCH 1/3] detect all port 0 configs Signed-off-by: fenn-cs --- newsfragments/3563.minor | 1 + src/allmydata/node.py | 2 +- src/allmydata/test/test_node.py | 17 +++++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 newsfragments/3563.minor diff --git a/newsfragments/3563.minor b/newsfragments/3563.minor new file mode 100644 index 000000000..038b50995 --- /dev/null +++ b/newsfragments/3563.minor @@ -0,0 +1 @@ +detect all port 0 configs \ No newline at end of file diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 4dcb7cc76..5a6f8c66f 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -793,7 +793,7 @@ def _tub_portlocation(config, get_local_addresses_sync, allocate_tcp_port): tubport = _convert_tub_port(cfg_tubport) for port in tubport.split(","): - if port in ("0", "tcp:0"): + if port in ("0", "tcp:0", "tcp:port=0", "tcp:0:interface=127.0.0.1"): raise PortAssignmentRequired() if cfg_location is None: diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index e44fd5743..cf5fa27f3 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -6,7 +6,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -from future.utils import PY2, native_str +from future.utils import PY2 if PY2: from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 @@ -530,6 +530,14 @@ def _stub_allocate_tcp_port(): """ return 999 +def _stub_none(): + """ + A function like ``_stub_allocate_tcp`` or ``_stub_get_local_addresses_sync`` + but that return an empty list since ``allmydata.node._tub_portlocation`` requires a + callable for paramter 1 and 2 counting from 0. + """ + return [] + class TestMissingPorts(unittest.TestCase): """ @@ -550,7 +558,7 @@ class TestMissingPorts(unittest.TestCase): ) config = config_from_string(self.basedir, "portnum", config_data) with self.assertRaises(PortAssignmentRequired): - _tub_portlocation(config, None, None) + _tub_portlocation(config, _stub_none, _stub_none) def test_listen_on_zero_with_host(self): """ @@ -563,10 +571,7 @@ class TestMissingPorts(unittest.TestCase): ) config = config_from_string(self.basedir, "portnum", config_data) with self.assertRaises(PortAssignmentRequired): - _tub_portlocation(config, None, None) - test_listen_on_zero_with_host.todo = native_str( # type: ignore - "https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3563" - ) + _tub_portlocation(config, _stub_none, _stub_none) def test_parsing_tcp(self): """ From 398fe537e8da2e8d8e4eaf5e9bd145cbd32025e1 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Mon, 23 Aug 2021 02:48:24 +0100 Subject: [PATCH 2/3] added \n in newfragment file Signed-off-by: fenn-cs --- newsfragments/3563.minor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newsfragments/3563.minor b/newsfragments/3563.minor index 038b50995..ea08fda56 100644 --- a/newsfragments/3563.minor +++ b/newsfragments/3563.minor @@ -1 +1 @@ -detect all port 0 configs \ No newline at end of file +detect all port 0 configs From 7a88b5ddae5497f52421deb2e852971809a62b45 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Tue, 24 Aug 2021 13:05:11 +0100 Subject: [PATCH 3/3] removed unnecessary comment in minor newsfragment Signed-off-by: fenn-cs --- newsfragments/3563.minor | 1 - 1 file changed, 1 deletion(-) diff --git a/newsfragments/3563.minor b/newsfragments/3563.minor index ea08fda56..e69de29bb 100644 --- a/newsfragments/3563.minor +++ b/newsfragments/3563.minor @@ -1 +0,0 @@ -detect all port 0 configs