Browse Source

Support link scope ipv6 address

pull/104/head
Sheng 5 years ago
parent
commit
7f6db649bf
  1. 4
      tests/test_utils.py
  2. 5
      webssh/utils.py

4
tests/test_utils.py

@ -35,6 +35,10 @@ class TestUitls(unittest.TestCase):
self.assertFalse(is_valid_ip_address(b'abc'))
self.assertTrue(is_valid_ip_address('::1'))
self.assertTrue(is_valid_ip_address(b'::1'))
self.assertTrue(is_valid_ip_address('fe80::1111:2222:3333:4444'))
self.assertTrue(is_valid_ip_address(b'fe80::1111:2222:3333:4444'))
self.assertTrue(is_valid_ip_address('fe80::1111:2222:3333:4444%eth0'))
self.assertTrue(is_valid_ip_address(b'fe80::1111:2222:3333:4444%eth0'))
def test_is_valid_port(self):
self.assertTrue(is_valid_port(80))

5
webssh/utils.py

@ -36,7 +36,10 @@ def to_int(string):
def to_ip_address(ipstr):
return ipaddress.ip_address(to_str(ipstr))
ip = to_str(ipstr)
if ip.startswith('fe80::'):
ip = ip.split('%')[0]
return ipaddress.ip_address(ip)
def is_valid_ip_address(ipstr):

Loading…
Cancel
Save