]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
wireguard.cgi: Implement DNS configuration for clients
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 Apr 2024 17:50:45 +0000 (19:50 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Apr 2025 14:48:31 +0000 (16:48 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
12 files changed:
doc/language_issues.de
doc/language_issues.en
doc/language_issues.es
doc/language_issues.fr
doc/language_issues.it
doc/language_issues.nl
doc/language_issues.pl
doc/language_issues.ru
doc/language_issues.tr
doc/language_missings
html/cgi-bin/wireguard.cgi
langs/en/cgi-bin/en.pl

index 1dc31d6e7e6d2d87d1b3812fcdf8d2f7189b5b2a..3e61e176bf351123650b95d48992067051fc251e 100644 (file)
@@ -1038,7 +1038,10 @@ WARNING: untranslated string: user management = User Management
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index 49d51e046016139a66fecd0c189d16d46a109fbd..0a81010b2da93128bda3ad8045413d8a5e0ae011 100644 (file)
@@ -2145,7 +2145,10 @@ WARNING: untranslated string: weeks = Weeks
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index 9e6ce3b909a3e3fa223a392aaf4b37f8afe05a79..2d9a925b210f63cc005d037f120ee7cfecc3f5fb 100644 (file)
@@ -1105,7 +1105,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index f87f98eb7cd38f8a248c39a31eeb1000bc97f226..0ccbe945fea40dc306e8583f3268ba6cd395283e 100644 (file)
@@ -1045,7 +1045,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index e47ac4624d2a50a5dcaee4c77eb8f9f2339c35dd..0fe19599d58b52d8a8efa7c1dbb942b7a5c380e9 100644 (file)
@@ -1391,7 +1391,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index 832bb3805519b549cf9f68614158eb2cdef6b70b..87c69961d7577c142c927d018d07eed7bfd57137 100644 (file)
@@ -1412,7 +1412,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index b60fc6e4f9e43831063b161ff70e644bf0aa3312..cb25ad7ea8fc4b89542ccf7b78d740d13c149f9e 100644 (file)
@@ -1654,7 +1654,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index 28e43001ac1ed733601ad3d62e6cf7c7b7ad3345..ee2eb4eddcdb49de71695374f2fbf8824d56223f 100644 (file)
@@ -1647,7 +1647,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index e1c8027ce4622f108d99a8154aa2805224d1ea9f..77b1cb12ce0754eb9dbcd67c95232ab0e95f0b73 100644 (file)
@@ -1274,7 +1274,10 @@ WARNING: untranslated string: warning = Warning
 WARNING: untranslated string: wg client configuration file = WireGuard Client Configuration File
 WARNING: untranslated string: wg client pool = Client Pool
 WARNING: untranslated string: wg create peer = Create A New Peer
+WARNING: untranslated string: wg dns = DNS
 WARNING: untranslated string: wg edit peer = Edit Peer
+WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
+WARNING: untranslated string: wg invalid client dns = Invalid client DNS address
 WARNING: untranslated string: wg invalid client pool = Invalid client pool
 WARNING: untranslated string: wg invalid endpoint address = Invalid endpoint address
 WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
index 5d363fe71fd96f854541c0590b419824211bd009..66f31028edba7249e4e7fb5b193a2efefa153adf 100644 (file)
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
 < wg client configuration file
 < wg client pool
 < wg create peer
+< wg dns
 < wg edit peer
+< wg host to net client settings
+< wg invalid client dns
 < wg invalid client pool
 < wg invalid endpoint address
 < wg invalid endpoint port
index bcc51a7b6ab82e69f0817d6d28f9b7484bac5bbb..8b62bfedcc9123ad9e526f86f0a895f4c32c7c0c 100644 (file)
@@ -47,8 +47,9 @@ my %peers = ();
 
 # Set any defaults
 &General::set_defaults(\%settings, {
-       "ENABLED" => "off",
-       "PORT"    => $DEFAULT_PORT,
+       "ENABLED"    => "off",
+       "PORT"       => $DEFAULT_PORT,
+       "CLIENT_DNS" => $Network::ethernet{'GREEN_ADDRESS'},
 });
 
 # Generate keys
@@ -60,6 +61,8 @@ my %cgiparams = ();
 
 # Save on main page
 if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
+       my @client_dns = ();
+
        # Store whether enabled or not
        if ($cgiparams{'ENABLED'} =~ m/^(on|off)?$/) {
                $settings{'ENABLED'} = $cgiparams{'ENABLED'};
@@ -81,6 +84,20 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
                push(@errormessages, $Lang::tr{'wg invalid client pool'});
        }
 
+       # Check client DNS
+       if (defined $cgiparams{'CLIENT_DNS'}) {
+               @client_dns = split(/,/, $cgiparams{'CLIENT_DNS'});
+
+               foreach my $dns (@client_dns) {
+                       unless (&Network::check_ip_address($dns)) {
+                               push(@errormessages, "$Lang::tr{'wg invalid client dns'}: ${dns}");
+                       }
+               }
+
+               # Store CLIENT_DNS
+               $settings{'CLIENT_DNS'} = join("|", @client_dns);
+       }
+
        # Don't continue on error
        goto MAIN if (scalar @errormessages);
 
@@ -418,6 +435,8 @@ MAIN:
                "CLIENT_POOL" => (&pool_is_in_use($settings{'CLIENT_POOL'}) ? "readonly" : ""),
        );
 
+       my $client_dns = $settings{'CLIENT_DNS'} =~ s/\|/, /gr;
+
        print <<END;
                <form method="POST" action="">
                        <table class="form">
@@ -442,7 +461,11 @@ MAIN:
                                                        min="1024" max="65535" />
                                        </td>
                                </tr>
+                       </table>
 
+                       <h6>$Lang::tr{'wg host to net client settings'}</h6>
+
+                       <table class="form">
                                <tr>
                                        <td>$Lang::tr{'wg client pool'}</td>
                                        <td>
@@ -451,6 +474,14 @@ MAIN:
                                        </td>
                                </tr>
 
+                               <tr>
+                                       <td>$Lang::tr{'wg dns'}</td>
+                                       <td>
+                                               <input type="text" name="CLIENT_DNS"
+                                                       value="$client_dns" />
+                                       </td>
+                               </tr>
+
                                <tr class="action">
                                        <td colspan="2">
                                                <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
@@ -1252,19 +1283,32 @@ sub generate_client_configuration($) {
        ));
        my $port = $settings{'PORT'};
 
+       # Fetch any DNS servers
+       my @dns = split(/\|/, $settings{'CLIENT_DNS'});
+
        my @conf = (
                "[Interface]",
                "PrivateKey = $peer->{'PRIVATE_KEY'}",
                "Address = $peer->{'CLIENT_ADDRESS'}",
-               "",
+       );
+
+       # Optionally add DNS servers
+       if (scalar @dns) {
+               push(@conf, "DNS = " . join(", ", @dns));
+       }
 
+       # Finish the [Interface] section
+       push(@conf, "");
+
+       # Add peer configuration
+       push(@conf, (
                "[Peer]",
                "Endpoint = ${fqdn}:${port}",
                "PublicKey = $settings{'PUBLIC_KEY'}",
                "PresharedKey = $peer->{'PSK'}",
                "AllowedIPs = " . join(", ", @allowed_ips),
                "PersistentKeepalive = $DEFAULT_KEEPALIVE",
-       );
+       ));
 
        return join("\n", @conf);
 }
index 754a4ddb7f2beab68e2a6c874608678b6ee04b2a..4b6d793e8267beab34733f50fc5e8742682c7929 100644 (file)
 'wg client configuration file' => 'WireGuard Client Configuration File',
 'wg client pool' => 'Client Pool',
 'wg create peer' => 'Create A New Peer',
+'wg dns' => 'DNS',
 'wg edit peer' => 'Edit Peer',
+'wg host to net client settings' => 'Host-To-Net Client Settings',
+'wg invalid client dns' => 'Invalid client DNS address',
 'wg invalid client pool' => 'Invalid client pool',
 'wg invalid endpoint address' => 'Invalid endpoint address',
 'wg invalid endpoint port' => 'Invalid endpoint port',