From: Michael Tremer Date: Fri, 6 Dec 2024 18:31:35 +0000 (+0100) Subject: wireguard.cgi: Change generate_peer_configuration to only generate RW stuff X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b62f1706638ab287e0300b43a322c595b1466fb;p=people%2Fstevee%2Fipfire-2.x.git wireguard.cgi: Change generate_peer_configuration to only generate RW stuff Signed-off-by: Michael Tremer --- diff --git a/config/cfgroot/wireguard-functions.pl b/config/cfgroot/wireguard-functions.pl index a3078a24f..33d9032c2 100644 --- a/config/cfgroot/wireguard-functions.pl +++ b/config/cfgroot/wireguard-functions.pl @@ -338,7 +338,7 @@ sub free_pool_addresses($$) { return @free_addresses; } -sub generate_peer_configuration($) { +sub generate_host_configuration($) { my $key = shift; # Load the peer @@ -347,8 +347,10 @@ sub generate_peer_configuration($) { # Return if we could not find the peer return undef unless (%peer); + # Return if this is not a roadwarrior peer + return undef unless ($peer{'TYPE'} eq 'host'); + my @allowed_ips = (); - my @dns = (); # Convert all subnets into CIDR notation foreach my $subnet ($peer{'LOCAL_SUBNETS'}) { @@ -371,9 +373,7 @@ sub generate_peer_configuration($) { my $port = $settings{'PORT'}; # Fetch any DNS servers for hosts - if ($peer{'TYPE'} eq 'host') { - @dns = split(/\|/, $settings{'CLIENT_DNS'}); - } + my @dns = split(/\|/, $settings{'CLIENT_DNS'}); my @conf = ( "[Interface]", diff --git a/html/cgi-bin/wireguard.cgi b/html/cgi-bin/wireguard.cgi index 5c639800b..82751fe1e 100644 --- a/html/cgi-bin/wireguard.cgi +++ b/html/cgi-bin/wireguard.cgi @@ -581,7 +581,7 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) { my $filename = &Header::normalize($peer{'NAME'}) . ".conf"; # Generate the client configuration - my $config = &Wireguard::generate_peer_configuration($key); + my $config = &Wireguard::generate_host_configuration($key); # Send the configuration if (defined $config) { @@ -1331,7 +1331,7 @@ sub show_peer_configuration($) { my %peer = &Wireguard::load_peer($key); # Generate the client configuration - my $config = &Wireguard::generate_peer_configuration($key); + my $config = &Wireguard::generate_host_configuration($key); # Create a QR code generator my $qrgen = Imager::QRCode->new(