2021-02-24 08:45:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require '../../includes/csrf.php';
|
|
|
|
require_once '../../includes/config.php';
|
|
|
|
|
2023-09-17 14:33:23 +00:00
|
|
|
$entity = escapeshellcmd($_POST['entity']);
|
2021-02-24 18:07:19 +00:00
|
|
|
|
2021-02-24 08:45:26 +00:00
|
|
|
if (isset($entity)) {
|
|
|
|
|
|
|
|
// generate public/private key pairs for entity
|
|
|
|
$pubkey = RASPI_WIREGUARD_PATH.$entity.'-public.key';
|
|
|
|
$privkey = RASPI_WIREGUARD_PATH.$entity.'-private.key';
|
|
|
|
$pubkey_tmp = '/tmp/'.$entity.'-public.key';
|
|
|
|
$privkey_tmp = '/tmp/'.$entity.'-private.key';
|
|
|
|
|
|
|
|
exec("sudo wg genkey | tee $privkey_tmp | wg pubkey > $pubkey_tmp", $return);
|
2021-02-24 18:07:19 +00:00
|
|
|
$wgdata['pubkey'] = str_replace("\n",'',file_get_contents($pubkey_tmp));
|
2021-02-24 08:45:26 +00:00
|
|
|
exec("sudo mv $privkey_tmp $privkey", $return);
|
|
|
|
exec("sudo mv $pubkey_tmp $pubkey", $return);
|
|
|
|
|
2021-02-24 18:07:19 +00:00
|
|
|
echo json_encode($wgdata);
|
2021-02-24 08:45:26 +00:00
|
|
|
}
|