Skip to content

Commit d8d4732

Browse files
fix(WireGuardTunnel): ignore addresses if tunnel has a current iface assignment #902
1 parent fbee00c commit d8d4732

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ class WireGuardTunnel extends Model {
145145
return wg_is_key_clamped($privatekey) ? $privatekey : wg_clamp_key($privatekey);
146146
}
147147

148+
/**
149+
* Extends the default _update method to ensure addresses are removed if the tunnel has an interface assignment
150+
*/
151+
public function _update(): void
152+
{
153+
# Remove any existing addresses if this tunnel has an existing interface assignment
154+
if (NetworkInterface::query(if: $this->name->value)->exists()) {
155+
$this->addresses->value = null;
156+
}
157+
158+
parent::_update();
159+
}
160+
148161
/**
149162
* Obtains the next available WireGuard tunnel interface name.
150163
* @return string The next available WireGuard tunnel interface name (i.e. tun_wg0)

0 commit comments

Comments
 (0)