File tree Expand file tree Collapse file tree
pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models Expand file tree Collapse file tree Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments