net/wireguard: deal with kmod service status; closes #3273

Shift the name from wireguard-go to wireguard in this case.
HA between go and kmod is probably not going to work fully
as the service name shifts, but eventually go should be gone.

Since wireguard rc.d script misuses "status" we don't know
what the status is and since the kmod has no "process" either
we have nothing to go on so the stop and start actions cannot
be cleanly represented and are instead replaced by a single
restart.

If you want to stop wireguard from the GUI it needs to be
disabled in its settings.
This commit is contained in:
Franco Fichtner
2023-01-27 08:36:05 +01:00
parent 7205ea0094
commit 2ed1f987eb
2 changed files with 37 additions and 20 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
PLUGIN_NAME= wireguard
PLUGIN_VERSION= 1.13
PLUGIN_REVISION= 3
PLUGIN_REVISION= 4
PLUGIN_COMMENT= WireGuard VPN service
PLUGIN_DEPENDS= wireguard-tools
PLUGIN_MAINTAINER= m.muenz@gmail.com
@@ -34,49 +34,66 @@ function wireguard_enabled()
function wireguard_services()
{
$services = array();
$services = [];
if (!wireguard_enabled()) {
return $services;
}
$services[] = array(
$service = [
'description' => gettext('WireGuard VPN'),
'configd' => array(
'restart' => array('wireguard restart'),
'start' => array('wireguard start'),
'stop' => array('wireguard stop'),
),
'name' => 'wireguard-go'
);
'configd' => [
'restart' => ['wireguard restart'],
'start' => ['wireguard start'],
'stop' => ['wireguard stop'],
],
'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;
}
function wireguard_interfaces()
{
$interfaces = array();
$interfaces = [];
if (!wireguard_enabled()) {
return $interfaces;
}
$oic = array('enable' => true);
$oic['if'] = 'wireguard';
$oic['descr'] = gettext('WireGuard (Group)');
$oic['type'] = 'group';
$oic['virtual'] = true;
$oic['networks'] = array();
$interfaces['wireguard'] = $oic;
$interfaces['wireguard'] = [
'descr' => gettext('WireGuard (Group)'),
'if' => 'wireguard',
'virtual' => true,
'enable' => true,
'type' => 'group',
'networks' => [],
];
return $interfaces;
}
function wireguard_xmlrpc_sync()
{
$result = array();
$result = [];
$result['id'] = 'wireguard';
$result['section'] = 'OPNsense.wireguard';
$result['description'] = gettext('WireGuard');
$result['services'] = ['wireguard-go'];
return array($result);
if (file_exists('/boot/modules/if_wg.ko') || file_exists('/boot/kernel/if_wg.ko')) {
$result['services'] = ['wireguard'];
}
return [$result];
}
function wireguard_devices()