From 8b7f769451feade69f7a269387f67d3f95dcaa90 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 27 Apr 2025 18:01:44 +0200 Subject: [PATCH] wireguard-functions.pl: Tolerate any IP addresses with subnet masks on import Signed-off-by: Michael Tremer --- config/cfgroot/wireguard-functions.pl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/config/cfgroot/wireguard-functions.pl b/config/cfgroot/wireguard-functions.pl index f13fed17c..11451a615 100644 --- a/config/cfgroot/wireguard-functions.pl +++ b/config/cfgroot/wireguard-functions.pl @@ -506,12 +506,24 @@ sub parse_configuration($$) { if ($section eq "Interface") { # Address if ($key eq "Address") { - if (&Network::check_ip_address($val)) { - $peer{'LOCAL_ADDRESS'} = $val; - } else { + my $address = &Network::get_netaddress($val); + my $prefix = &Network::get_prefix($val); + + # There must be an address + unless ($address) { push(@errormessages, $Lang::tr{'invalid ip address'}); } + # If there was a prefix it must be /32 + if (defined $prefix) { + unless ($prefix == 32) { + push(@errormessages, $Lang::tr{'invalid ip address'}); + } + } + + # Store the address + $peer{'LOCAL_ADDRESS'} = ${address}; + # Port } elsif ($key eq "Port") { if (&General::validport($val)) { -- 2.39.5