]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
wireguard-functions.pl: Return subnets as an array reference
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Apr 2025 17:58:01 +0000 (19:58 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Apr 2025 17:58:01 +0000 (19:58 +0200)
I don't know why, but otherwise Perl will try to expand everything
everywhere all of the time.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/wireguard-functions.pl
html/cgi-bin/wireguard.cgi

index ab1e4a49b8f99457e14bdcc19957ccabc081fcd5..bbdf122a61348a79d3c1e19bb3c55070c9277f84 100644 (file)
@@ -303,7 +303,7 @@ sub decode_subnets($) {
        # Split the string
        my @subnets = split(/\|/, $subnets);
 
-       return @subnets;
+       return \@subnets;
 }
 
 sub pool_is_in_use($) {
index 8bfb5df95230595b6f22f623c6ec7e0ddd7366ff..cc79347a62dfefd502440132dd808ab09b922159 100644 (file)
@@ -134,8 +134,8 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
        # Fetch type
        my $type = $Wireguard::peers{$key}[1];
 
-       my @remote_subnets = &Wireguard::decode_subnets($Wireguard::peers{$key}[8]);
-       my @local_subnets  = &Wireguard::decode_subnets($Wireguard::peers{$key}[10]);
+       my $remote_subnets = &Wireguard::decode_subnets($Wireguard::peers{$key}[8]);
+       my $local_subnets  = &Wireguard::decode_subnets($Wireguard::peers{$key}[10]);
 
        # Flush CGI parameters & load configuration
        %cgiparams = (
@@ -148,9 +148,9 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
                "PORT"                          => $Wireguard::peers{$key}[5],
                "ENDPOINT_ADDRESS"      => $Wireguard::peers{$key}[6],
                "ENDPOINT_PORT"         => $Wireguard::peers{$key}[7],
-               "REMOTE_SUBNETS"        => join(", ", @remote_subnets),
+               "REMOTE_SUBNETS"        => join(", ", @$remote_subnets),
                "REMARKS"                       => &MIME::Base64::decode_base64($Wireguard::peers{$key}[9]),
-               "LOCAL_SUBNETS"         => join(", ", @local_subnets),
+               "LOCAL_SUBNETS"         => join(", ", @$local_subnets),
                "PSK"                           => $Wireguard::peers{$key}[11],
                "KEEPALIVE"                     => $Wireguard::peers{$key}[12],
        );