From: Michael Tremer Date: Sun, 27 Apr 2025 16:01:44 +0000 (+0200) Subject: wireguard-functions.pl: Tolerate any IP addresses with subnet masks on import X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b7f769451feade69f7a269387f67d3f95dcaa90;p=people%2Fmfischer%2Fipfire-2.x.git wireguard-functions.pl: Tolerate any IP addresses with subnet masks on import Signed-off-by: Michael Tremer --- 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)) {