From: Michael Tremer Date: Tue, 22 Apr 2025 17:58:01 +0000 (+0200) Subject: wireguard-functions.pl: Return subnets as an array reference X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=843c39434195e0fe78be36fb25adc5854aff78a2;p=ipfire-2.x.git wireguard-functions.pl: Return subnets as an array reference I don't know why, but otherwise Perl will try to expand everything everywhere all of the time. Signed-off-by: Michael Tremer --- diff --git a/config/cfgroot/wireguard-functions.pl b/config/cfgroot/wireguard-functions.pl index ab1e4a49b..bbdf122a6 100644 --- a/config/cfgroot/wireguard-functions.pl +++ b/config/cfgroot/wireguard-functions.pl @@ -303,7 +303,7 @@ sub decode_subnets($) { # Split the string my @subnets = split(/\|/, $subnets); - return @subnets; + return \@subnets; } sub pool_is_in_use($) { diff --git a/html/cgi-bin/wireguard.cgi b/html/cgi-bin/wireguard.cgi index 8bfb5df95..cc79347a6 100644 --- a/html/cgi-bin/wireguard.cgi +++ b/html/cgi-bin/wireguard.cgi @@ -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], );