mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
VPN: WireGuard: Peer generator - forgot to store attached instance (server), closes https://github.com/opnsense/core/issues/7356
This commit is contained in:
parent
b71c42b9c5
commit
9cc991194d
@ -138,6 +138,27 @@ class ClientController extends ApiMutableModelControllerBase
|
||||
|
||||
public function addClientBuilderAction()
|
||||
{
|
||||
return $this->addBase('configbuilder', 'clients.client');
|
||||
$uuid = null;
|
||||
if ($this->request->isPost() && !empty($this->request->getPost('configbuilder'))) {
|
||||
Config::getInstance()->lock();
|
||||
$mdl = new Server();
|
||||
$uuid = $this->getModel()->clients->generateUUID();
|
||||
$server = $this->request->getPost('configbuilder')['server'];
|
||||
foreach ($mdl->servers->server->iterateItems() as $key => $node) {
|
||||
if ($key == $server) {
|
||||
$peers = array_filter(explode(',', (string)$node->peers));
|
||||
$node->peers = implode(',', array_merge($peers, [$uuid]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Save to in memory model.
|
||||
* Ignore validations as $uuid might be new or trigger an existing validation issue.
|
||||
* Persisting the data is handled by setBase()
|
||||
*/
|
||||
$mdl->serializeToConfig(false, true);
|
||||
}
|
||||
|
||||
return $this->setBase('configbuilder', 'clients.client', $uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@
|
||||
psk: $("#configbuilder\\.psk").val(),
|
||||
tunneladdress: $("#configbuilder\\.tunneladdress").val(),
|
||||
keepalive: $("#configbuilder\\.keepalive").val(),
|
||||
servers: instance_id,
|
||||
server: instance_id,
|
||||
}
|
||||
};
|
||||
ajaxCall('/api/wireguard/client/addClientBuilder', peer, function(data, status) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user