From 190e2681d441e26208156691d573b4db86e55ccd Mon Sep 17 00:00:00 2001 From: sever-sever Date: Tue, 9 Mar 2021 17:41:36 +0000 Subject: syslog: T3396: Fix remote IPv6 host --- python/vyos/template.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'python') 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". -- cgit v1.2.3