onQueue('provisioning'); } public static function for(VpnPeer $peer): self { return new self($peer->public_key, $peer->allowed_ip, $peer->enabled); } public function handle(WireguardHub $hub): void { if ($this->enabled && $this->allowedIp !== null) { $hub->addPeer($this->publicKey, $this->allowedIp); } else { $hub->removePeer($this->publicKey); } // Reflect the change immediately instead of waiting for the next sync, // so the console does not sit on "wird angewendet" for a whole minute. VpnPeer::query()->where('public_key', $this->publicKey)->update([ 'present' => $this->enabled, 'observed_at' => now(), ]); } }