summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-10-29 21:07:02 +0200
committerGitHub <noreply@github.com>2022-10-29 21:07:02 +0200
commit4d924de02cedd3a2a85cb6346c30f902bc2fa57c (patch)
treef7b50f5f0cb6b7ffe74b2a759235fa52a3d4c0e0 /src
parent509ddb0a1d3f53131bc4eb7a405a8208d8f12c61 (diff)
parentc2ff9aa158b81fa66ce9c810e891ad25d4a7f14b (diff)
downloadvyos-1x-4d924de02cedd3a2a85cb6346c30f902bc2fa57c.tar.gz
vyos-1x-4d924de02cedd3a2a85cb6346c30f902bc2fa57c.zip
Merge pull request #1621 from sarthurdev/T4774
wireguard: T4774: Prevent duplicate peer public keys
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces-wireguard.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py
index 8d738f55e..762bad94f 100755
--- a/src/conf_mode/interfaces-wireguard.py
+++ b/src/conf_mode/interfaces-wireguard.py
@@ -87,6 +87,8 @@ def verify(wireguard):
'cannot be used for the interface!')
# run checks on individual configured WireGuard peer
+ public_keys = []
+
for tmp in wireguard['peer']:
peer = wireguard['peer'][tmp]
@@ -100,6 +102,11 @@ def verify(wireguard):
raise ConfigError('Both Wireguard port and address must be defined '
f'for peer "{tmp}" if either one of them is set!')
+ if peer['public_key'] in public_keys:
+ raise ConfigError(f'Duplicate public-key defined on peer "{tmp}"')
+
+ public_keys.append(peer['public_key'])
+
def apply(wireguard):
tmp = WireGuardIf(wireguard['ifname'])
if 'deleted' in wireguard: