mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Initial commit: wgkey gen
This commit is contained in:
parent
2c99f9857d
commit
d871e271ef
22
ajax/networking/get_wgkey.php
Normal file
22
ajax/networking/get_wgkey.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require '../../includes/csrf.php';
|
||||||
|
require_once '../../includes/config.php';
|
||||||
|
|
||||||
|
$entity = $_POST['entity'];
|
||||||
|
|
||||||
|
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);
|
||||||
|
$entity_pubkey = str_replace("\n",'',file_get_contents($pubkey_tmp));
|
||||||
|
exec("sudo mv $privkey_tmp $privkey", $return);
|
||||||
|
exec("sudo mv $pubkey_tmp $pubkey", $return);
|
||||||
|
|
||||||
|
echo json_encode($entity_pubkey);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user