]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
wireguard.cgi: Add controls to download configuration
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 30 Sep 2024 17:40:09 +0000 (19:40 +0200)
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>
14 files changed:
config/cfgroot/wireguard-functions.pl
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/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl

index ef8bf9b0ca1769840231d67ee26e9f9698abf4b0..b2d9c14a06914869267abb7d4675691b920dd849 100644 (file)
@@ -152,6 +152,31 @@ sub dump($) {
        return %dump;
 }
 
+sub load_peer($) {
+       my $key = shift;
+
+       my $type = $peers{$key}[1];
+
+       my %peer = (
+               "ENABLED"               => $peers{$key}[0],
+               "TYPE"                  => $type,
+               "NAME"                  => $peers{$key}[2],
+               "PUBLIC_KEY"            => $peers{$key}[3],
+               "PRIVATE_KEY"           => $peers{$key}[4],
+               "PORT"                  => $peers{$key}[5],
+               "ENDPOINT_ADDR"         => $peers{$key}[6],
+               "ENDPOINT_PORT"         => $peers{$key}[7],
+               ($type eq "host") ? "CLIENT_ADDRESS" : "REMOTE_SUBNETS"
+                                       => &decode_subnets($peers{$key}[8]),
+               "REMARKS"               => &decode_remarks($peers{$key}[9]),
+               "LOCAL_SUBNETS"         => &decode_subnets($peers{$key}[10]),
+               "PSK"                   => $peers{$key}[11],
+               "KEEPALIVE"             => $peers{$key}[12],
+       );
+
+       return %peer;
+}
+
 sub name_is_valid($) {
        my $name = shift;
 
@@ -314,13 +339,19 @@ sub free_pool_addresses($$) {
 }
 
 sub generate_peer_configuration($) {
-       my $peer = shift;
+       my $key = shift;
+
+       # Load the peer
+       my %peer = &load_peer($key);
+
+       # Return if we could not find the peer
+       return undef unless (%peer);
 
        my @allowed_ips = ();
        my @dns = ();
 
        # Convert all subnets into CIDR notation
-       foreach my $subnet ($peer->{'LOCAL_SUBNETS'}) {
+       foreach my $subnet ($peer{'LOCAL_SUBNETS'}) {
                my $netaddress = &Network::get_netaddress($subnet);
                my $prefix     = &Network::get_prefix($subnet);
 
@@ -340,14 +371,14 @@ sub generate_peer_configuration($) {
        my $port = $settings{'PORT'};
 
        # Fetch any DNS servers for hosts
-       if ($peer->{'TYPE'} eq 'host') {
+       if ($peer{'TYPE'} eq 'host') {
                @dns = split(/\|/, $settings{'CLIENT_DNS'});
        }
 
        my @conf = (
                "[Interface]",
-               "PrivateKey = $peer->{'PRIVATE_KEY'}",
-               "Address = $peer->{'CLIENT_ADDRESS'}",
+               "PrivateKey = $peer{'PRIVATE_KEY'}",
+               "Address = $peer{'CLIENT_ADDRESS'}",
        );
 
        # Optionally add DNS servers
@@ -363,7 +394,7 @@ sub generate_peer_configuration($) {
                "[Peer]",
                "Endpoint = ${endpoint}:${port}",
                "PublicKey = $settings{'PUBLIC_KEY'}",
-               "PresharedKey = $peer->{'PSK'}",
+               "PresharedKey = $peer{'PSK'}",
                "AllowedIPs = " . join(", ", @allowed_ips),
                "PersistentKeepalive = $DEFAULT_KEEPALIVE",
        ));
index 8c3f8b2a0079bf7276c87627f464832f2f62757b..eff641863e6d50a16d9f01cdbe3269a49bbd58f1 100644 (file)
@@ -1049,6 +1049,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1061,7 +1062,6 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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 efad13f1009476abe0ce54eea56a53972f0a0ae9..2ccf371b56150713554e4981852f11e165bd5912 100644 (file)
@@ -2156,6 +2156,7 @@ WARNING: untranslated string: weeks = Weeks
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -2166,6 +2167,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -2178,7 +2180,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index de41b16ac3effda30712b65f786e4e9ba18164b8..37623809f25b53a9ea419d5e013725ecf9fa2a65 100644 (file)
@@ -1115,6 +1115,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1125,6 +1126,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1137,7 +1139,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: wio = unknown string
 WARNING: untranslated string: wio checked = unknown string
index 96c7f9f55428140ca4b6c46ea3e0134e95ce4ed9..3a5a949ec8fa9b3e1c3063b663be71a9863f4065 100644 (file)
@@ -1055,6 +1055,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1065,6 +1066,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1077,7 +1079,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: wio = unknown string
 WARNING: untranslated string: wio checked = unknown string
index e2568c34789326ce1cb9c8f2777a0d97eee30cd6..459723c53216ba6e2021a12a8f8bd9379335cf08 100644 (file)
@@ -1401,6 +1401,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1411,6 +1412,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1423,7 +1425,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 49be295223fb924007f1ca4316d8bc8a9ba86398..640172f9fa0a2272971e3071fd2b29d4e95e783a 100644 (file)
@@ -1422,6 +1422,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1432,6 +1433,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1444,7 +1446,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 832fb403f9772b1f98e7717d2e7227d1e211de12..55725f2b627d5c40ca24cea458e9c42277497165 100644 (file)
@@ -1664,6 +1664,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1674,6 +1675,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1686,7 +1688,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 96832e9ff4dfe9bf98ac0e84ad0453797ab93ba6..5ec2515324ece55d8d73250a868919566c3d9d00 100644 (file)
@@ -1657,6 +1657,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1667,6 +1668,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1679,7 +1681,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index 8605801238326464d94e6efd8b8d0f4d4d487301..7ad028fe8db9416bb88e722fedd69a3f4b6a9188 100644 (file)
@@ -1284,6 +1284,7 @@ WARNING: untranslated string: warning = Warning
 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 download configuration = Download Configuration
 WARNING: untranslated string: wg download configuration file = Download the configuration file
 WARNING: untranslated string: wg edit peer = Edit Peer
 WARNING: untranslated string: wg host to net client settings = Host-To-Net Client Settings
@@ -1294,6 +1295,7 @@ WARNING: untranslated string: wg invalid endpoint port = Invalid endpoint port
 WARNING: untranslated string: wg invalid keepalive interval = Invalid Keepalive Interval (Must be between 0 and 65535)
 WARNING: untranslated string: wg invalid local subnet = Invalid local subnet
 WARNING: untranslated string: wg invalid name = Invalid name (Only letters, numbers, space and hyphen are allowed)
+WARNING: untranslated string: wg invalid private key = unknown string
 WARNING: untranslated string: wg invalid psk = Invalid pre-shared key
 WARNING: untranslated string: wg invalid public key = Invalid public key
 WARNING: untranslated string: wg invalid remote subnet = Invalid remote subnet
@@ -1306,7 +1308,7 @@ WARNING: untranslated string: wg peer configuration = Peer Configuration
 WARNING: untranslated string: wg peer does not exist = Peer does not exist
 WARNING: untranslated string: wg rw peers = WireGuard Roadwarrior Peers
 WARNING: untranslated string: wg scan the qr code = Scan the QR code to import the WireGuard configuration into a mobile client.
-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: wg show configuration qrcode = Show Configuration QR Code
 WARNING: untranslated string: whitelisted = Whitelisted
 WARNING: untranslated string: whois results from = WHOIS results from
 WARNING: untranslated string: winbind daemon = Winbind Daemon
index b97d8ca9caa146de3355e4e0a5c86ba42035aa6d..52d323f5dcc5bad7e842bb08910d8ea82c7de71e 100644 (file)
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < wireguard
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < wireguard
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < whois results from
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < whois results from
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < whois results from
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < whois results from
 < wg client pool
 < wg create peer
 < wg dns
+< wg download configuration
 < wg download configuration file
 < wg edit peer
 < wg host to net client settings
 < wg pre-shared key (optional)
 < wg rw peers
 < wg scan the qr code
+< wg show configuration qrcode
 < wg warning configuration only shown once
 < whitelisted
 < whois results from
index d0105b34ff28f61cd5fb5daae400bc69f38c26de..dfb95a062afd00daaedd62efac66516098ee730b 100644 (file)
@@ -450,6 +450,42 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{'save'}) {
        if ($Wireguard::settings{'ENABLED'} eq "on") {
                &General::system("/usr/local/bin/wireguardctrl", "start");
        }
+
+# Download configuration
+} elsif ($cgiparams{'ACTION'} eq 'CONFIG') {
+       my $key = $cgiparams{'KEY'} || 0;
+
+       # Load the peer
+       my %peer = &Wireguard::load_peer($key);
+
+       # Make the filename for files
+       my $filename = &Header::normalize($peer{'NAME'}) . ".conf";
+
+       # Generate the client configuration
+       my $config = &Wireguard::generate_peer_configuration($key);
+
+       # Send the configuration
+       if (defined $config) {
+               print "Content-Type: application/octet-stream\n";
+               print "Content-Disposition: filename=\"${filename}\"\n";
+               print "\n";
+               print $config;
+
+       # If there is no configuration, we return 404
+       } else {
+               &CGI::header(status => 404);
+       }
+
+       exit(0);
+
+# Show the configuration as QR code
+} elsif ($cgiparams{'ACTION'} eq 'CONFIG-QRCODE') {
+       my $key = $cgiparams{'KEY'} || 0;
+
+       # Show the configuration
+       &show_peer_configuration($key);
+
+       exit(0);
 }
 
 # The main page starts here
@@ -560,7 +596,7 @@ END
                                                $Lang::tr{'status'}
                                        </th>
 
-                                       <th width='10%' colspan='3'>
+                                       <th width='10%' colspan='5'>
                                                $Lang::tr{'action'}
                                        </th>
                                </tr>
@@ -658,6 +694,24 @@ END
                        }
 
                        print <<END;
+                                       <td class="text-center">
+                                               <form method='post'>
+                                                       <input type='image' name='$Lang::tr{'wg show configuration qrcode'}' src='/images/qr-code.png'
+                                                               alt='$Lang::tr{'wg show configuration qrcode'}' title='$Lang::tr{'wg show configuration qrcode'}' />
+                                                       <input type='hidden' name='ACTION' value='CONFIG-QRCODE' />
+                                                       <input type='hidden' name='KEY' value='$key' />
+                                               </form>
+                                       </td>
+
+                                       <td class="text-center">
+                                               <form method='post'>
+                                                       <input type='image' name='$Lang::tr{'wg download configuration'}' src='/images/media-floppy.png'
+                                                               alt='$Lang::tr{'wg download configuration'}' title='$Lang::tr{'wg download configuration'}' />
+                                                       <input type='hidden' name='ACTION' value='CONFIG' />
+                                                       <input type='hidden' name='KEY' value='$key' />
+                                               </form>
+                                       </td>
+
                                        <td class="text-center">
                                                <form method='post'>
                                                        <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif'
@@ -1028,18 +1082,11 @@ sub show_peer_configuration($) {
        # Open the page
        &Header::openpage($Lang::tr{'wireguard'}, 1, '');
 
-       # Load the configuration
-       my %peer = (
-               "NAME"                          => $Wireguard::peers{$key}[2],
-               "PUBLIC_KEY"            => $Wireguard::peers{$key}[3],
-               "PRIVATE_KEY"           => $Wireguard::peers{$key}[4],
-               "CLIENT_ADDRESS"        => $Wireguard::peers{$key}[8],
-               "LOCAL_SUBNETS"         => &Wireguard::decode_subnets($Wireguard::peers{$key}[10]),
-               "PSK"                           => $Wireguard::peers{$key}[11],
-       );
+       # Load the peer
+       my %peer = &Wireguard::load_peer($key);
 
        # Generate the client configuration
-       my $config = &Wireguard::generate_peer_configuration(\%peer);
+       my $config = &Wireguard::generate_peer_configuration($key);
 
        # Create a QR code generator
        my $qrgen = Imager::QRCode->new(
index cc5fcf3a934a427f9443809a36dae683e0d59562..5ae43272139ca1fd52ad2663fddbf8ac2a8886f1 100644 (file)
 'week-graph' => 'Woche',
 'weekly firewallhits' => 'wöchentliche Firewalltreffer',
 'weeks' => 'Wochen',
+'wg download configuration' => 'Konfiguration herunterladen',
+'wg show configuration qrcode' => 'Konfigurations-QR-Code anzeigen',
 'whitelisted' => 'Ausgenommen',
 'whois results from' => 'WHOIS-Ergebnisse von',
 'wildcards' => 'Wildcards',
index 79634e90b431a6252040afb7f5459385f947848d..af2c3b33825c777153126a79455c265e62a26c68 100644 (file)
 'wg client pool' => 'Client Pool',
 'wg create peer' => 'Create A New Peer',
 'wg dns' => 'DNS',
+'wg download configuration' => 'Download Configuration',
 'wg download configuration file' => 'Download the configuration file',
 'wg edit peer' => 'Edit Peer',
 'wg host to net client settings' => 'Host-To-Net Client Settings',
 'wg pre-shared key (optional)' => 'Pre-Shared Key (optional)',
 'wg rw peers' => 'WireGuard Roadwarrior Peers',
 'wg scan the qr code' => 'Scan the QR code to import the WireGuard configuration into a mobile client.',
+'wg show configuration qrcode' => 'Show Configuration QR Code',
 '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',