diff options
author | Viacheslav <v.gletenko@vyos.io> | 2021-12-28 11:45:37 +0000 |
---|---|---|
committer | Viacheslav <v.gletenko@vyos.io> | 2021-12-28 11:45:37 +0000 |
commit | 5e05bfe790035f7d53dede8d76bccb089a186864 (patch) | |
tree | 8643a31cc75b4c0174f06b202205bada3e4b0a90 /python | |
parent | 5c5e283f8a964f5bbb3d838d1c0aabdee4e2032b (diff) | |
download | vyos-1x-5e05bfe790035f7d53dede8d76bccb089a186864.tar.gz vyos-1x-5e05bfe790035f7d53dede8d76bccb089a186864.zip |
ipsec: T4111: Fix for swanctl configuration IPV6 peers
Peer name must not contain dots and colons, otherwise
swanct can't generate correct configuration for swanctl.conf
This is used in connection names and child SA names
Add filter 'dot_colon_to_dash' which replace dots and colons
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/template.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/python/vyos/template.py b/python/vyos/template.py index b32cafe74..29c6b3882 100644 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -151,6 +151,16 @@ def bracketize_ipv6(address): return f'[{address}]' return address +@register_filter('dot_colon_to_dash') +def dot_colon_to_dash(text): + """ Replace dot and colon to dash for string + Example: + 192.0.2.1 => 192-0-2-1, 2001:db8::1 => 2001-db8--1 + """ + text = text.replace(":", "-") + text = text.replace(".", "-") + return text + @register_filter('netmask_from_cidr') def netmask_from_cidr(prefix): """ Take CIDR prefix and convert the prefix length to a "subnet mask". |