fix(connections): disable close on kernel-forwarded connections with the reason

This commit is contained in:
Zakk committed 2026-09-29 17:51:38 +10:00
1 parent 13361f841b
commit 6dcdc507a3
3 files changed
+15 -6

No files matched your search

+7 -3
View File
@@ -395,10 +395,14 @@ test('closing a connection removes it from the list and clears the selection', a
await expect(page.locator('.rp-toast.positive')).toContainText('Closed api.telegram.org');
await expect(page).toHaveURL(/#\/connections$/);
await expect(page.locator('.rp-table [data-key="c-0001"]')).toHaveCount(0);
// A kernel-observed connection is refused by the backend, and the row stays.
// A kernel-forwarded connection has no userspace transport to cancel, so Close says why before it is pressed.
await page.goto('/#/connections?id=c-0002');
await panel.getByRole('button', {name: 'Close connection', exact: true}).click();
await expect(page.locator('.rp-toast.negative')).toContainText('cannot be closed');
const reason =
'The backend has no userspace transfer to interrupt, so this connection cannot be closed. Connections the kernel forwards directly are of this kind.';
const close = panel.getByRole('button', {name: 'Close connection', exact: true});
await expect(close).toBeDisabled();
await expect(close).toHaveAccessibleDescription(reason);
await expect(panel.getByText(reason)).toBeVisible();
await expect(page.locator('.rp-table [data-key="c-0002"]')).toHaveCount(1);
});
+6 -3
View File
@@ -1,4 +1,5 @@
import {
ActionHelp,
Badge,
Button,
ConfirmButton,
@@ -120,9 +121,11 @@ export function Connections(props: PageProps) {
{cur.source && <Button onPress={vm.onlyClient}>{t('conn.onlyThisClient')}</Button>}
</div>
{vm.canClose && cur.closable && (
<Button negative quiet isPending={vm.close.pending} isDisabled={vm.close.disabled} onPress={vm.close.run}>
{t('conn.close')}
</Button>
<ActionHelp reason={cur.closeReason}>
<Button negative quiet isPending={vm.close.pending} isDisabled={vm.close.disabled || !!cur.closeReason} onPress={vm.close.run}>
{t('conn.close')}
</Button>
</ActionHelp>
)}
</div>
<Kv items={cur.fields} />
+2
View File
@@ -360,6 +360,8 @@ export function connectionDetail(
: null,
source: current.src ? (sourceIp(current.src) ?? current.src) : null,
closable: current.state === 'active' || current.state === 'dialing' || current.state === 'routing',
// An ebpf-only observation is kernel-forwarded: the backend has no userspace transport to cancel.
closeReason: current.observed_by === 'ebpf' ? t('conn.notClosable') : null,
stateHelp: connectionStateHelp(current.state, t)
}
: null;