summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-10 15:58:26 +0100
committerGitHub <noreply@github.com>2021-03-10 15:58:26 +0100
commite874f284b5b20d2dafb1861296dd34a6be4d7da5 (patch)
treedf30665cf1453e8ab69e008d27dc76c47446ecab /python/vyos
parent8b195a2665ca9efa31ecbd297a60f2b19106cd66 (diff)
parent190e2681d441e26208156691d573b4db86e55ccd (diff)
downloadvyos-1x-e874f284b5b20d2dafb1861296dd34a6be4d7da5.tar.gz
vyos-1x-e874f284b5b20d2dafb1861296dd34a6be4d7da5.zip
Merge pull request #764 from sever-sever/T3396
syslog: T3396: Fix remote IPv6 host
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/template.py7
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".