mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Remove unnecessary manipulation with IPv6 scope outside of the IPv6Address object instance
This commit is contained in:
parent
c314e1c675
commit
3ce265e7cc
1 changed files with 3 additions and 8 deletions
|
@ -1029,18 +1029,13 @@ def parse_resolv(src='/etc/resolv.conf'):
|
|||
try:
|
||||
(directive, arg) = (line[0].lower(), line[1:])
|
||||
# Drop everything after # or ; (comments)
|
||||
arg = list(itertools.takewhile(
|
||||
lambda x: x[0] not in ('#', ';'), arg))
|
||||
|
||||
arg = list(itertools.takewhile(lambda x: x[0] not in ('#', ';'), arg))
|
||||
if directive == 'nameserver':
|
||||
# Split the scope (interface) if it is present
|
||||
addr, scope = arg[0].split('%', 1) if '%' in arg[0] else (arg[0], '')
|
||||
addr = arg[0]
|
||||
try:
|
||||
ip_addr = ipaddress.ip_address(addr)
|
||||
version = ip_addr.version
|
||||
# Rejoin scope after address validation
|
||||
if scope:
|
||||
ip_addr = '%'.join((str(ip_addr), scope))
|
||||
ip_addr = str(ip_addr)
|
||||
if ip_addr not in nameservers:
|
||||
nameservers.append(ip_addr)
|
||||
if version == 4 and ip_addr not in ip4_nameservers:
|
||||
|
|
Loading…
Add table
Reference in a new issue