libs/tools: add option to only add private ips if system has only private ips
This commit is contained in:
parent
12d179235e
commit
958ea3c9e3
1 changed files with 6 additions and 1 deletions
|
@ -5,7 +5,7 @@ from bundlewrap.utils.text import bold, red
|
||||||
from bundlewrap.utils.ui import io
|
from bundlewrap.utils.ui import io
|
||||||
|
|
||||||
|
|
||||||
def resolve_identifier(repo, identifier, linklocal=False, only_physical=False):
|
def resolve_identifier(repo, identifier, linklocal=False, only_physical=False, allow_private=True):
|
||||||
"""
|
"""
|
||||||
Try to resolve an identifier (group or node). Return a set of ip
|
Try to resolve an identifier (group or node). Return a set of ip
|
||||||
addresses valid for this identifier.
|
addresses valid for this identifier.
|
||||||
|
@ -62,10 +62,15 @@ def resolve_identifier(repo, identifier, linklocal=False, only_physical=False):
|
||||||
'ipv6': set(),
|
'ipv6': set(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_public_ips = bool([ip for ip in found_ips if not ip.is_private])
|
||||||
|
|
||||||
for ip in found_ips:
|
for ip in found_ips:
|
||||||
if ip.is_link_local and not linklocal:
|
if ip.is_link_local and not linklocal:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if ip.is_private and not allow_private and has_public_ips:
|
||||||
|
continue
|
||||||
|
|
||||||
if isinstance(ip, IPv4Address):
|
if isinstance(ip, IPv4Address):
|
||||||
ip_dict['ipv4'].add(ip)
|
ip_dict['ipv4'].add(ip)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue