diff --git a/net/pfSense-pkg-WireGuard/Makefile b/net/pfSense-pkg-WireGuard/Makefile
index 092a9ba9..18f19384 100644
--- a/net/pfSense-pkg-WireGuard/Makefile
+++ b/net/pfSense-pkg-WireGuard/Makefile
@@ -1,6 +1,5 @@
PORTNAME= pfSense-pkg-WireGuard
-PORTVERSION= 0.1.2
-PORTREVISION= 6
+PORTVERSION= 0.1.3
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg.inc b/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg.inc
index e6e0009c..2617b62e 100644
--- a/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg.inc
+++ b/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg.inc
@@ -228,6 +228,9 @@ function wg_delete_tunnel($tunnel_name) {
// Sync with configuration backend
write_config("[{$wgg['pkg_name']}] Tunnel {$tunnel['name']} deleted.");
+
+ // Mark any peers as unassigned
+ wg_tunnel_unassign_peers($tunnel['name']);
// We've got meaningful changes...
$changes = true;
@@ -243,6 +246,32 @@ function wg_delete_tunnel($tunnel_name) {
}
+function wg_tunnel_unassign_peers($tunnel_name) {
+ global $wgg;
+
+ wg_globals();
+
+ if (isset($wgg['peers']) && is_array($wgg['peers'])) {
+
+ $peers = $wgg['peers'];
+
+ foreach ($peers as $peer_idx => $peer) {
+
+ if ($peer['tun'] == $tunnel_name) {
+
+ $wgg['peers'][$peer_idx]['tun'] = 'unassigned';
+
+ }
+
+ }
+
+ // Sync with configuration backend
+ write_config("[{$wgg['pkg_name']}] Tunnel {$tunnel_name} peers unassigned.");
+
+ }
+
+}
+
/*
* This transforms a raw peer post consisting of repeatables
*/
@@ -1018,11 +1047,17 @@ function wg_download_tunnel($tunnel_name, $failure_redirect) {
// Make sure conf files are current
wg_resync();
+ $now = new DateTimeImmutable();
+
+ $stamp = $now->format('YmdHis');
+
$conf_path = "{$wgg['conf_path']}/{$tunnel_name}.conf";
+ $name = "tunnel-{$tunnel_name}-{$stamp}.conf";
+
if (file_exists($conf_path)) {
- send_user_download('file', $conf_path);
+ send_user_download('file', $conf_path, $name);
}
diff --git a/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg_api.inc b/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg_api.inc
index 90ea65ea..0a0d14be 100644
--- a/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg_api.inc
+++ b/net/pfSense-pkg-WireGuard/files/usr/local/pkg/wireguard/wg_api.inc
@@ -130,11 +130,15 @@ function wg_status_json($pretty = false) {
function wg_get_peer_id($public_key, $tunnel_name) {
global $wgg;
- foreach ($wgg['peers'] as $peer_id => $peer){
+ if (isset($wgg['peers']) && is_array($wgg['peers'])) {
- if ($public_key == $peer['publickey'] && $tunnel_name = $peer['tun']) {
+ foreach ($wgg['peers'] as $peer_id => $peer){
- return $peer_id;
+ if ($public_key == $peer['publickey'] && $tunnel_name = $peer['tun']) {
+
+ return $peer_id;
+
+ }
}
@@ -732,15 +736,19 @@ function wg_get_tunnel_peers($tunnel_name) {
if (isset($wgg['tunnels'][$tun_idx])) {
- // Look through array of peers for matching tunnel name
- foreach ($wgg['peers'] as $peer_idx => $peer) {
+ if (isset($wgg['peers']) && is_array($wgg['peers'])) {
- if ($peer['tun'] == $tunnel_name) {
+ // Look through array of peers for matching tunnel name
+ foreach ($wgg['peers'] as $peer_idx => $peer) {
- // We need the array index for future manipulations
- $peer['index'] = $peer_idx;
+ if ($peer['tun'] == $tunnel_name) {
- $a_ret[] = $peer;
+ // We need the array index for future manipulations
+ $peer['index'] = $peer_idx;
+
+ $a_ret[] = $peer;
+
+ }
}
diff --git a/net/pfSense-pkg-WireGuard/files/usr/local/www/wg/vpn_wg_tunnels.php b/net/pfSense-pkg-WireGuard/files/usr/local/www/wg/vpn_wg_tunnels.php
index 4e1f329d..f34a035e 100644
--- a/net/pfSense-pkg-WireGuard/files/usr/local/www/wg/vpn_wg_tunnels.php
+++ b/net/pfSense-pkg-WireGuard/files/usr/local/www/wg/vpn_wg_tunnels.php
@@ -99,7 +99,7 @@
default:
// Shouldn't be here, so bail out.
- header("Location: /wg/vpn_wg_tunnels.php");
+ header('Location: /wg/vpn_wg_tunnels.php');
break;
@@ -198,7 +198,7 @@
">
" usepost>
=wg_generate_toggle_icon_link($tunnel, 'Click to toggle enabled/disabled status', "?act=toggle&tun={$tunnel['name']}")?>
- " usepost>
+ " usepost>
diff --git a/net/pfSense-pkg-WireGuard/pkg-plist b/net/pfSense-pkg-WireGuard/pkg-plist
index 6a9e4a61..5c2449b6 100644
--- a/net/pfSense-pkg-WireGuard/pkg-plist
+++ b/net/pfSense-pkg-WireGuard/pkg-plist
@@ -8,13 +8,13 @@ pkg/wireguard/wg_install.inc
pkg/wireguard/wg_service.inc
pkg/wireguard/wg_validate.inc
www/shortcuts/pkg_wireguard.inc
+www/wg/js/WireGuardHelpers.js
www/wg/status_wireguard.php
www/wg/vpn_wg_peers.php
www/wg/vpn_wg_peers_edit.php
www/wg/vpn_wg_settings.php
www/wg/vpn_wg_tunnels.php
www/wg/vpn_wg_tunnels_edit.php
-www/wg/js/WireGuardHelpers.js
/etc/inc/priv/wireguard.priv.inc
%%DATADIR%%/info.xml
@dir /etc/inc/priv