diff options
author | sever-sever <v.gletenko@vyos.io> | 2021-03-09 17:41:36 +0000 |
---|---|---|
committer | sever-sever <v.gletenko@vyos.io> | 2021-03-10 14:51:34 +0000 |
commit | 190e2681d441e26208156691d573b4db86e55ccd (patch) | |
tree | 5a63230ee44766d1adf5ee6258802e4d0d5bf889 /python/vyos | |
parent | dfdbcb4e52ab67892c7dc50d6e82b1b7aef8eeb2 (diff) | |
download | vyos-1x-190e2681d441e26208156691d573b4db86e55ccd.tar.gz vyos-1x-190e2681d441e26208156691d573b4db86e55ccd.zip |
syslog: T3396: Fix remote IPv6 host
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/template.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/python/vyos/template.py b/python/vyos/template.py index 22883b103..85e4d12b3 100644 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -131,6 +131,13 @@ def address_from_cidr(prefix): from ipaddress import ip_network return str(ip_network(prefix).network_address) +@register_filter('bracketize_ipv6') +def bracketize_ipv6(address): + """ Place a passed IPv6 address into [] brackets, do nothing for IPv4 """ + if is_ipv6(address): + return f'[{address}]' + return address + @register_filter('netmask_from_cidr') def netmask_from_cidr(prefix): """ Take CIDR prefix and convert the prefix length to a "subnet mask". |