]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
wireguard.cgi: Show client configuration after creating a client
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 Apr 2024 15:14:27 +0000 (17:14 +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 b45fd17782bb6fdfa46d069ed906e05b5e4f975d..b2e03ec38ea143cb7dc7eced66311acf62d81445 100644 (file)
@@ -1034,6 +1034,7 @@ WARNING: untranslated string: show tls-auth key = Show tls-auth key
 WARNING: untranslated string: smb daemon = SMB Daemon
 WARNING: untranslated string: subscription code = Subscription code
 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 edit peer = Edit Peer
@@ -1050,7 +1051,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: winbind daemon = Winbind Daemon
 WARNING: untranslated string: wio = unknown string
 WARNING: untranslated string: wio checked = unknown string
index cc6c3de56353a4f1a54c7bb9e4bd6fefdc8b93c4..0714a8cd37c4090ab1924005d76f13a6be3b789a 100644 (file)
@@ -2141,6 +2141,7 @@ WARNING: untranslated string: web server = Web Server
 WARNING: untranslated string: website = Website
 WARNING: untranslated string: wednesday = Wednesday
 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 edit peer = Edit Peer
@@ -2157,7 +2158,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 4ca0d4fd923cfd74c3fefe304d670b556e15e75b..f9cbc9a6e9de0e97934c553a44f351a683771a9f 100644 (file)
@@ -1101,6 +1101,7 @@ WARNING: untranslated string: timeformat = %Y-%m-%d at %H:%M:%S %Z
 WARNING: untranslated string: total = Total
 WARNING: untranslated string: transport mode does not support vti = VTI is not support in transport mode
 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 edit peer = Edit Peer
@@ -1117,7 +1118,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: wio = unknown string
 WARNING: untranslated string: wio checked = unknown string
index 3e3b6096ea1fa26b7da3a45e3d9e10061d7b75da..d0545fc3443fae0624c0603eb3f7ffebc0e4cb83 100644 (file)
@@ -1041,6 +1041,7 @@ WARNING: untranslated string: system time = System Time (as of last page load)
 WARNING: untranslated string: timeformat = %Y-%m-%d at %H:%M:%S %Z
 WARNING: untranslated string: total = Total
 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 edit peer = Edit Peer
@@ -1057,7 +1058,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: wio = unknown string
 WARNING: untranslated string: wio checked = unknown string
index 30226d1a18d6c6da4d5c333364ba69dd97ddea53..482546b51334460ca208c5038b4c76b0696bd0fe 100644 (file)
@@ -1387,6 +1387,7 @@ WARNING: untranslated string: vpn weak = Weak
 WARNING: untranslated string: vulnerability = Vulnerability
 WARNING: untranslated string: vulnerable = Vulnerable
 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 edit peer = Edit Peer
@@ -1403,7 +1404,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 14f92a8f10eabfde18e9797df7daceec0e354125..12521129019d13fa213c4a2cbb6a09df8ae6984f 100644 (file)
@@ -1408,6 +1408,7 @@ WARNING: untranslated string: vpn weak = Weak
 WARNING: untranslated string: vulnerability = Vulnerability
 WARNING: untranslated string: vulnerable = Vulnerable
 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 edit peer = Edit Peer
@@ -1424,7 +1425,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 7d92546b4be76c5bf0162592f75190a04bad4d65..2b3a9f3b83da86d5366c21c0785e8096eececb16 100644 (file)
@@ -1650,6 +1650,7 @@ WARNING: untranslated string: vpn weak = Weak
 WARNING: untranslated string: vulnerability = Vulnerability
 WARNING: untranslated string: vulnerable = Vulnerable
 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 edit peer = Edit Peer
@@ -1666,7 +1667,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 4e6b60db8b9d7b9330a919d07418e9d7a2cb815e..15af0652583f6de053bd6e6f16d4c61ae1673faa 100644 (file)
@@ -1643,6 +1643,7 @@ WARNING: untranslated string: vpn weak = Weak
 WARNING: untranslated string: vulnerability = Vulnerability
 WARNING: untranslated string: vulnerable = Vulnerable
 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 edit peer = Edit Peer
@@ -1659,7 +1660,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 4feea2d53a3885e5d59832de3bca4b6323afb96b..1cb9134dd32d1ff89c2860ef8737d660abf0057b 100644 (file)
@@ -1270,6 +1270,7 @@ WARNING: untranslated string: vpn wait = WAITING
 WARNING: untranslated string: vulnerability = Vulnerability
 WARNING: untranslated string: vulnerable = Vulnerable
 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 edit peer = Edit Peer
@@ -1286,7 +1287,9 @@ WARNING: untranslated string: wg keepalive interval = Keepalive Interval
 WARNING: untranslated string: wg name is already used = The name is already in use
 WARNING: untranslated string: wg no local subnets = No local subnets given
 WARNING: untranslated string: wg no remote subnets = No remote subnets given
+WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
+WARNING: untranslated string: wg warning configuration only shown once = Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 6a6226cc56f8631c78c32db54747986f26acc377..9e2df8913d8a2d99bcd93f4fa1cdba0e40165f53 100644 (file)
 < user management
 < vpn configuration main
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < winbind daemon
 < wireguard
 < wlanap 802.11w disabled
 < transport mode does not support vti
 < warning
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < wireguard
 < wlanap
 < upload fcdsl.o
 < warning
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < wireguard
 < wlanap hide ssid
 < warning
 < Weekly
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < whois results from
 < winbind daemon
 < warning
 < Weekly
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < whois results from
 < winbind daemon
 < warning
 < Weekly
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < whois results from
 < winbind daemon
 < week-graph
 < Weekly
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < whois results from
 < winbind daemon
 < warning
 < Weekly
 < wg
+< wg client configuration file
 < wg client pool
 < wg create peer
 < wg edit peer
 < wg name is already used
 < wg no local subnets
 < wg no remote subnets
+< wg peer configuration
 < wg peer does not exist
 < wg pre-shared key (optional)
+< wg warning configuration only shown once
 < whitelisted
 < whois results from
 < winbind daemon
index 057c7c1a7279c7cad89fd4a5266509d8790f8316..e8d33b486a33639d0641863697cf56d27127fe4f 100644 (file)
@@ -272,6 +272,7 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
 
 } elsif ($cgiparams{"ACTION"} eq "SAVE-PEER-HOST") {
        my @local_subnets = ();
+       my $private_key;
 
        # Fetch or allocate a new key
        my $key = $cgiparams{'KEY'} || &General::findhasharraykey(\%peers);
@@ -305,21 +306,24 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
        # If there are any errors, we go back to the editor
        goto EDITHOST if (scalar @errormessages);
 
-       # Fetch some configuration parts
-       if (exists $peers{$key}) {
-               $cgiparams{"PUBLIC_KEY"} = $peers{$key}[3];
-               $cgiparams{"PSK"}        = $peers{$key}[9];
+       # Is this a new connection?
+       my $is_new = !exists $peers{$key};
 
-       # Set some things if we are creating a new peer
-       } else {
+       # Generate things for a new peer
+       if ($is_new) {
                # Generate a new private key
-               my $private_key = &generate_private_key();
+               $private_key = &generate_private_key();
 
                # Derive the public key
                $cgiparams{"PUBLIC_KEY"} = &derive_public_key($private_key);
 
                # Generate a new PSK
                $cgiparams{"PSK"} = &generate_private_key();
+
+       # Fetch some configuration parts
+       } else {
+               $cgiparams{"PUBLIC_KEY"} = $peers{$key}[3];
+               $cgiparams{"PSK"}        = $peers{$key}[9];
        }
 
        # Save the connection
@@ -356,6 +360,9 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
                &General::system("/usr/local/bin/wireguardctrl", "reload");
        }
 
+       # Show the client configuration when creating a new peer
+       &show_peer_configuration($key, $private_key) if ($is_new);
+
 } elsif ($cgiparams{"ACTION"} eq $Lang::tr{'add'}) {
        if ($cgiparams{"TYPE"} eq "net") {
                goto EDITNET;
@@ -867,6 +874,52 @@ END
 
        exit(0);
 
+sub show_peer_configuration($$) {
+       my $key = shift;
+       my $private_key = shift;
+
+       # Send HTTP Headers
+       &Header::showhttpheaders();
+
+       # Open the page
+       &Header::openpage($Lang::tr{'wireguard'}, 1, '');
+
+       # Load the configuration
+       my %peer = (
+               "NAME"                          => $peers{$key}[2],
+               "PUBLIC_KEY"            => $peers{$key}[3],
+               "CLIENT_ADDRESS"        => $peers{$key}[6],
+               "LOCAL_SUBNETS"         => &decode_subnets($peers{$key}[8]),
+               "PSK"                           => $peers{$key}[9],
+
+               # Other stuff
+               "PRIVATE_KEY"           => $private_key,
+       );
+
+       # Generate the client configuration
+       my $config = &generate_client_configuration(\%peer);
+
+       # Open a new box
+       &Header::openbox('100%', '', "$Lang::tr{'wg peer configuration'}: $peer{'NAME'}");
+
+       print <<END;
+               <h6>$Lang::tr{'wg client configuration file'}</h6>
+
+               <code><pre>$config</textarea></code>
+END
+
+       &Header::closebox();
+
+       # Show a note that this configuration cannot be shown again
+       &Header::errorbox((
+               $Lang::tr{'wg warning configuration only shown once'},
+       ));
+
+       &Header::closepage();
+
+       exit(0);
+}
+
 # This function generates a set of keys for this host if none exist
 sub generate_keys($) {
        my $force = shift || 0;
@@ -1078,3 +1131,23 @@ sub pool_is_in_use($) {
        # No match found
        return 0;
 }
+
+sub generate_client_configuration($) {
+       my $peer = shift;
+
+       my @conf = (
+               "[Interface]",
+               "PrivateKey = $peer->{'PRIVATE_KEY'}",
+               "Address = $peer->{'CLIENT_ADDRESS'}",
+               "",
+
+               "[Peer]",
+               "Endpoint = $General::main{'HOSTNAME'}.$General::main{'DOMAINNAME'}",
+               "PublicKey = $settings{'PUBLIC_KEY'}",
+               "PresharedKey = $peer->{'PSK'}",
+               "AllowedIPs = $peer->{'LOCAL_SUBNETS'}",
+               "PersistentKeepalive = $DEFAULT_KEEPALIVE",
+       );
+
+       return join("\n", @conf);
+}
index 0567e4dc82be022639315d80c0ed00080a6380ce..cf82ff8d2bef7fc3916e0871bbea06b29ab654b9 100644 (file)
 'weekly firewallhits' => 'weekly firewallhits',
 'weeks' => 'Weeks',
 'wg' => 'WireGuard',
+'wg client configuration file' => 'WireGuard Client Configuration File',
 'wg client pool' => 'Client Pool',
 'wg create peer' => 'Create A New Peer',
 'wg edit peer' => 'Edit Peer',
 'wg name is already used' => 'The name is already in use',
 'wg no local subnets' => 'No local subnets given',
 'wg no remote subnets' => 'No remote subnets given',
+'wg peer configuration' => 'Peer Configuration',
 'wg peer does not exist' => 'Peer does not exist',
 'wg pre-shared key (optional)' => 'Pre-Shared Key (optional)',
+'wg warning configuration only shown once' => 'Attention: This WireGuard configuration file will only be shown this one time as it contains private key material that is not being stored on IPFire.',
 'whitelisted' => 'Whitelisted',
 'whois results from' => 'WHOIS results from',
 'wildcards' => 'Wildcards',