"htdocs/libs/includes/user.class.php" did not exist on "f3a100693b8784b5bc4b375ac28d4eb8a6bcf67b"
Newer
Older
<?php
${basename(__FILE__, '.php')} = function () {
if (
$this->get_request_method() == "POST"
and $this->isAuthenticated()
and isset($this->_request['peer'])
and !empty($this->_request['peer'])
) {
try {
$wg = new wireguard('wg0');
$ip_net = new ipNetwork($wg->getCIDR(),$wg->device);
"data" => $wg->addPeer($this->_request['peer'],$ip_net->getNextIp())
];
$data = $this->json($data);
$this->response($data, 200);
} catch (Exception $e) {
$data = [
"error" => $e->getMessage()
];
$data = $this->json($data);
$this->response($data, 403);
}
} else {
$data = [
"error" => "Bad request"
];
$data = $this->json($data);
$this->response($data, 400);
}
};