fix(vpn): pause polling while a private config is on screen

Every five-second poll re-rendered the page, putting the private key into
another HTTP response — the handoff kept it out of the snapshot but not out of
the responses. Traffic figures can wait the minute it takes to copy a key.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat/portal-design
nexxo 2026-07-25 22:44:31 +02:00
parent c2b18ecfbc
commit 3bd3e64a3d
2 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,7 @@
<div class="space-y-5" wire:poll.5s="refreshPeers">
{{-- Polling pauses while a config is on screen: every poll re-renders this
page, and that would put the private key into an HTTP response every five
seconds. Traffic figures can wait the minute someone needs to copy a key. --}}
<div class="space-y-5" @if (! $newConfig) wire:poll.5s="refreshPeers" @endif>
<div class="animate-rise">
<h1 class="text-2xl font-semibold tracking-tight text-ink">{{ __('vpn.title') }}</h1>
<p class="mt-1 text-sm text-muted">{{ __('vpn.subtitle') }}</p>

View File

@ -714,3 +714,20 @@ it('never leaves the previous config on screen after another access is created',
->and($component->get('newConfigName'))->toBeNull()
->and(App\Services\Wireguard\ConfigHandoff::get($firstToken))->toBeNull();
});
it('does not keep polling while a private config is on screen', function () {
vpnHub();
Queue::fake();
$owner = operator('Owner');
$component = Livewire::actingAs($owner)->test(Vpn::class)->assertSee('wire:poll', false);
$component->set('name', 'Notebook')->set('ownerId', $owner->id)->call('create');
// Otherwise every poll would put the private key into another response.
$component->assertDontSee('wire:poll', false)->assertSee('PrivateKey');
$component->call('dismissConfig')
->assertSee('wire:poll', false)
->assertDontSee('PrivateKey');
});