]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
wireguard-functions.pl: Tolerate any IP addresses with subnet masks on import
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Apr 2025 16:01:44 +0000 (18:01 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 Apr 2025 16:01:44 +0000 (18:01 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/wireguard-functions.pl

index f13fed17ca44b2102a59dde5baef457e49568bbf..11451a6153bb0440936abc96fd9377b2185b39b2 100644 (file)
@@ -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)) {