mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-25 05:19:53 +00:00
private-mode: reject legacy host:port locations
This commit is contained in:
parent
c17217699e
commit
0116c965fa
@ -373,7 +373,15 @@ class Node(service.MultiService):
|
|||||||
for ip in local_addresses])
|
for ip in local_addresses])
|
||||||
else:
|
else:
|
||||||
if not self._reveal_ip:
|
if not self._reveal_ip:
|
||||||
hint_type = loc.split(":")[0]
|
# Legacy hints are "host:port". We use Foolscap's utility
|
||||||
|
# function to convert all hints into the modern format
|
||||||
|
# ("tcp:host:port") because that's what the receiving
|
||||||
|
# client will probably do. We test the converted hint for
|
||||||
|
# TCP-ness, but publish the original hint because that
|
||||||
|
# was the user's intent.
|
||||||
|
from foolscap.connections.tcp import convert_legacy_hint
|
||||||
|
converted_hint = convert_legacy_hint(loc)
|
||||||
|
hint_type = converted_hint.split(":")[0]
|
||||||
if hint_type == "tcp":
|
if hint_type == "tcp":
|
||||||
raise PrivacyError("tub.location includes tcp: hint")
|
raise PrivacyError("tub.location includes tcp: hint")
|
||||||
new_locations.append(loc)
|
new_locations.append(loc)
|
||||||
|
@ -295,4 +295,12 @@ class Privacy(unittest.TestCase):
|
|||||||
None, "tcp:hostname:1234")
|
None, "tcp:hostname:1234")
|
||||||
self.assertEqual(str(e), "tub.location includes tcp: hint")
|
self.assertEqual(str(e), "tub.location includes tcp: hint")
|
||||||
|
|
||||||
|
def test_tub_location_legacy_tcp(self):
|
||||||
|
n = FakeNode(BASECONFIG+"[node]\nreveal-IP-address = false\n")
|
||||||
|
n._portnumfile = "missing"
|
||||||
|
n.check_privacy()
|
||||||
|
e = self.assertRaises(PrivacyError, n.get_tub_portlocation,
|
||||||
|
None, "hostname:1234")
|
||||||
|
self.assertEqual(str(e), "tub.location includes tcp: hint")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user