wireguard-functions.pl: backport two fixes from ipfire

commit 68a3334413efb1a963b7cc6c6dca1ec0126e1cc1
    Author: Michael Tremer <michael.tremer@ipfire.org>
    Date:   Fri Jul 18 08:42:12 2025 +0000

        wireguard-functions.pl: Automatically skip IPv6 subnets

        Since we do not support this and some VPN providers generate
        configuration files that send any data over to them, we simply ignore
        any IPv6 subnets.

        Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

    commit f7565a885b55384a64edd8bd73079143a04da519
    Author: Michael Tremer <michael.tremer@ipfire.org>
    Date:   Fri Jul 18 09:57:34 2025 +0000

        wireguard-functions.pl: Remove any carriage returns on import

        Some files might include carriage returns which won't be removed by
        chomp() on Linux. To be extra safe, we remove them manually.

        Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2025-07-21 19:37:48 +00:00
parent c7e72c51bf
commit 351e665042

View File

@@ -491,6 +491,9 @@ sub parse_configuration($$) {
# Remove line breaks
chomp;
# Remove any carriage returns
$_ =~ s/\r$//;
# Search for section headers
if ($_ =~ m/^\[(\w+)\]$/) {
$section = $1;
@@ -573,6 +576,9 @@ sub parse_configuration($$) {
# Check if all networks are valid
foreach my $network (@networks) {
# Skip any IPv6 networks
next if ($network =~ m/:/);
unless (&Network::check_subnet($network)) {
push(@errormessages, $Lang::tr{'invalid network'} . " $network");
}