]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
wireguard.cgi: Change generate_peer_configuration to only generate RW stuff
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 6 Dec 2024 18:31:35 +0000 (19:31 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Apr 2025 14:48:53 +0000 (16:48 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/wireguard-functions.pl
html/cgi-bin/wireguard.cgi

index a3078a24fd8905127f736d8062297128426a0af8..33d9032c221878c874330aca8dbee3e7f97d2704 100644 (file)
@@ -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]",
index 5c639800b04c72e56969c940dfc9f4c919076fcd..82751fe1eb35cc170c3c547039acf23327a64cf9 100644 (file)
@@ -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(