1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Save client.conf

This commit is contained in:
billz 2021-03-02 14:16:43 +00:00
parent 3ec81ba085
commit 9eadd28df1

View File

@ -47,6 +47,7 @@ function DisplayWireGuardConfig()
} }
// Save settings // Save settings
if ($good_input) { if ($good_input) {
// server (wg0.conf)
$config[] = '[Interface]'; $config[] = '[Interface]';
$config[] = 'Address = '.$_POST['wg_srvipaddress']; $config[] = 'Address = '.$_POST['wg_srvipaddress'];
$config[] = 'ListenPort = '.$_POST['wg_srvport']; $config[] = 'ListenPort = '.$_POST['wg_srvport'];
@ -68,7 +69,23 @@ function DisplayWireGuardConfig()
file_put_contents("/tmp/wgdata", $config); file_put_contents("/tmp/wgdata", $config);
system('sudo cp /tmp/wgdata '.RASPI_WIREGUARD_CONFIG, $return); 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 // handle log option
if ($_POST['wg_log'] == "1") { if ($_POST['wg_log'] == "1") {
exec("sudo /bin/systemctl status wg-quick@wg0 | sudo tee /tmp/wireguard.log > /dev/null"); exec("sudo /bin/systemctl status wg-quick@wg0 | sudo tee /tmp/wireguard.log > /dev/null");