net/wireguard-go: pull all names into device registration after core change

PR: https://forum.opnsense.org/index.php?topic=37189.0
This commit is contained in:
Franco Fichtner
2023-11-24 14:32:02 +01:00
parent 8da84037c2
commit 837b403b7a
2 changed files with 18 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
PLUGIN_NAME= wireguard-go
PLUGIN_VERSION= 1.13
PLUGIN_REVISION= 7
PLUGIN_REVISION= 8
PLUGIN_COMMENT= WireGuard VPN service Go implementation
PLUGIN_CONFLICTS= wireguard
PLUGIN_OBSOLETE= yes
@@ -50,11 +50,6 @@ function wireguard_services()
'name' => 'wireguard-go',
];
if (file_exists('/boot/modules/if_wg.ko') || file_exists('/boot/kernel/if_wg.ko')) {
$service['name'] = 'wireguard';
$service['nocheck'] = true;
}
$services[] = $service;
return $services;
@@ -89,14 +84,26 @@ function wireguard_xmlrpc_sync()
$result['description'] = gettext('WireGuard');
$result['services'] = ['wireguard-go'];
if (file_exists('/boot/modules/if_wg.ko') || file_exists('/boot/kernel/if_wg.ko')) {
$result['services'] = ['wireguard'];
}
return [$result];
}
function wireguard_devices()
{
return [['pattern' => '^wg', 'volatile' => true]];
$names = [];
foreach ((new OPNsense\Wireguard\Server())->servers->server->iterateItems() as $key => $node) {
if (!empty((string)$node->enabled)) {
$names[(string)$node->interface] = [
'descr' => sprintf('%s (WireGuard - %s)', (string)$node->interface, (string)$node->name),
'ifdescr' => (string)$node->name,
'name' => (string)$node->interface
];
}
}
return [[
'configurable' => false,
'pattern' => '^wg',
'type' => 'wireguard',
'volatile' => true,
'names' => $names,
]];
}