36 lines
915 B
PHP
36 lines
915 B
PHP
<?php
|
|
|
|
namespace App\Provisioning\Jobs;
|
|
|
|
use App\Services\Wireguard\WireguardHub;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* Removes a host's WireGuard peer. Runs on the provisioning queue so it executes
|
|
* in the privileged worker that owns the wg0 interface (the web container can't
|
|
* manage WireGuard).
|
|
*/
|
|
class RemoveWireguardPeer implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public $tries = 3;
|
|
|
|
public $timeout = 120;
|
|
|
|
public function __construct(public string $publicKey)
|
|
{
|
|
$this->onConnection('provisioning');
|
|
$this->onQueue('provisioning');
|
|
}
|
|
|
|
public function handle(WireguardHub $hub): void
|
|
{
|
|
$hub->removePeer($this->publicKey);
|
|
}
|
|
}
|