From 9eadd28df1b90dda47c56f4e40b3d7b3df32d49d Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 2 Mar 2021 14:16:43 +0000 Subject: [PATCH] Save client.conf --- includes/wireguard.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/wireguard.php b/includes/wireguard.php index 787672d0..44b2bc74 100644 --- a/includes/wireguard.php +++ b/includes/wireguard.php @@ -47,6 +47,7 @@ function DisplayWireGuardConfig() } // Save settings if ($good_input) { + // server (wg0.conf) $config[] = '[Interface]'; $config[] = 'Address = '.$_POST['wg_srvipaddress']; $config[] = 'ListenPort = '.$_POST['wg_srvport']; @@ -68,7 +69,23 @@ function DisplayWireGuardConfig() file_put_contents("/tmp/wgdata", $config); system('sudo cp /tmp/wgdata '.RASPI_WIREGUARD_CONFIG, $return); - + + // client1 (client.conf) + $config = []; + $config[] = '[Interface]'; + $config[] = 'Address = '; + $config[] = 'PrivateKey = '; + $config[] = ''; + $config[] = '[Peer]'; + $config[] = 'PublicKey = '; + $config[] = 'AllowedIPs = '; + $config[] = 'Endpoint = '; + $config[] = ''; + $config = join(PHP_EOL, $config); + + file_put_contents("/tmp/wgdata", $config); + system('sudo cp /tmp/wgdata '.RASPI_WIREGUARD_PATH.'client.conf', $return); + // handle log option if ($_POST['wg_log'] == "1") { exec("sudo /bin/systemctl status wg-quick@wg0 | sudo tee /tmp/wireguard.log > /dev/null");