Parsing yggdrasil addresses

main
bashrc 2026-02-25 18:49:09 +00:00
parent 8b762a2733
commit 7d40d5aac4
2 changed files with 10 additions and 2 deletions

View File

@ -9661,6 +9661,10 @@ def _test_yggdrasil_addresses() -> None:
text = 'http://[203:abcd:abcd:abcd:abcd:abcd:abcd]/something'
assert not is_yggdrasil_url(text)
assert get_port_from_domain(text) is None
text = 'http://[302:abcd:abcd:abcd::abc]'
assert is_yggdrasil_url(text)
text = 'http://[302:abcd:abcd:abcd:abc]'
assert not is_yggdrasil_url(text)
def run_all_tests():

View File

@ -3374,8 +3374,12 @@ def is_yggdrasil_address(domain: str) -> bool:
domain = domain.split(']:')[0] + ']'
else:
return False
if domain.count(':') != 7:
return False
if domain.startswith('[2'):
if domain.count(':') != 7:
return False
else:
if domain.count(':') != 5:
return False
return True