Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix ipv6 regex under mac ifconfig
	inet6 fe80::8ad:15b:3155:5fec%en0 prefixlen 64 secured scopeid 0x5
	inet6 fe80::440b:15d5:3436:ef34%utun0 prefixlen 64 scopeid 0xa
  • Loading branch information
xufan6 committed Jun 17, 2019
1 parent aaf1e79 commit a920389
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions util/ip.py
Expand Up @@ -63,7 +63,7 @@ def ip_regex_match(parrent_regex, match_regex):
if os_name == 'nt': # windows:
cmd = 'ipconfig'
else:
cmd = 'ifconfig || ip address'
cmd = 'ifconfig 2>/dev/null || ip address'

for s in popen(cmd).readlines():
addr = ip_pattern.search(s)
Expand All @@ -83,5 +83,5 @@ def regex_v6(reg): # ipv6 正则提取
if os_name == 'nt': # Windows: IPv4 xxx: ::1
regex_str = r'IPv6 .*: ([\:\dabcdef]*)?\W'
else:
regex_str = r'inet6 (?:addr\:)?([\:\dabcdef]*)?[\s/]'
regex_str = r'inet6 (?:addr\:)?([\:\dabcdef]*)?[\s/%]'
return ip_regex_match(regex_str, reg)

0 comments on commit a920389

Please sign in to comment.