diff --git a/sshuttle/options.py b/sshuttle/options.py index a0a06c3..7cb05d1 100644 --- a/sshuttle/options.py +++ b/sshuttle/options.py @@ -37,9 +37,9 @@ def parse_subnetport_file(s): def parse_subnetport(s): if s.count(':') > 1: - rx = r'(?:\[?([\w\:]+)(?:/(\d+))?]?)(?::(\d+)(?:-(\d+))?)?$' + rx = r'(?:\[?(?:\*\.)?([\w\:]+)(?:/(\d+))?]?)(?::(\d+)(?:-(\d+))?)?$' else: - rx = r'([\w\.\-]+)(?:/(\d+))?(?::(\d+)(?:-(\d+))?)?$' + rx = r'((?:\*\.)?[\w\.\-]+)(?:/(\d+))?(?::(\d+)(?:-(\d+))?)?$' m = re.match(rx, s) if not m: diff --git a/tests/client/test_options.py b/tests/client/test_options.py index 6969ce1..fe04117 100644 --- a/tests/client/test_options.py +++ b/tests/client/test_options.py @@ -38,6 +38,10 @@ def _mock_getaddrinfo(host, *_): (socket.AF_INET6, socket.SOCK_STREAM, 0, '', ('::1', 0, 0, 0)), (socket.AF_INET, socket.SOCK_STREAM, 0, '', ('127.0.0.1', 0)), ], + "*.blogspot.com": [ + (socket.AF_INET6, socket.SOCK_STREAM, 0, '', ('2404:6800:4004:821::2001', 0, 0, 0)), + (socket.AF_INET, socket.SOCK_STREAM, 0, '', ('142.251.42.129', 0)), + ], }.get(host, []) @@ -133,6 +137,11 @@ def test_parse_subnetport_host(mock_getaddrinfo): (socket.AF_INET6, '::1', 128, 0, 0), (socket.AF_INET, '127.0.0.1', 32, 0, 0), ]) + assert set(sshuttle.options.parse_subnetport('*.blogspot.com')) \ + == set([ + (socket.AF_INET6, '2404:6800:4004:821::2001', 128, 0, 0), + (socket.AF_INET, '142.251.42.129', 32, 0, 0), + ]) @patch('sshuttle.options.socket.getaddrinfo', side_effect=_mock_getaddrinfo) @@ -157,3 +166,13 @@ def test_parse_subnetport_host_with_port(mock_getaddrinfo): (socket.AF_INET6, '::1', 128, 445, 450), (socket.AF_INET, '127.0.0.1', 32, 445, 450), ]) + assert set(sshuttle.options.parse_subnetport('*.blogspot.com:80')) \ + == set([ + (socket.AF_INET6, '2404:6800:4004:821::2001', 128, 80, 80), + (socket.AF_INET, '142.251.42.129', 32, 80, 80), + ]) + assert set(sshuttle.options.parse_subnetport('*.blogspot.com:80-90')) \ + == set([ + (socket.AF_INET6, '2404:6800:4004:821::2001', 128, 80, 90), + (socket.AF_INET, '142.251.42.129', 32, 80, 90), + ])