feat(nodes): add remote Xray and panel restart actions (#6970)

An operator running a master with sub-nodes could probe or update a node from the Nodes page but had to log in to the node, or SSH into it, to restart Xray or the panel (#6937).

Add Restart Xray and Restart panel to the node actions, behind a confirmation. Xray restarts through the node runtime; the panel restart is a new Remote call that the node accepts with node-admin credentials, the authority that already covers updatePanel. Both are refused for a disabled node.
This commit is contained in:
Hamed
2026-11-24 16:55:08 +03:30
committed by GitHub
parent a07ed97aa1
commit e409ed7244
40 changed files with 941 additions and 4 deletions
@@ -83,12 +83,29 @@ export function useNodeMutations() {
},
});
const restartMut = useMutation({
mutationFn: ({ id, target }: { id: number; target: 'xray' | 'panel' }) =>
HttpUtil.post(
`/panel/api/nodes/${target === 'xray' ? 'restartXray' : 'restartPanel'}/${id}`,
undefined,
{
silent: true,
timeout: 12000,
},
),
retry: false,
onSuccess: (msg) => {
if (msg?.success) queryClient.invalidateQueries({ queryKey: keys.nodes.root() });
},
});
return {
create: (payload: Partial<NodeRecord>) => createMut.mutateAsync(payload),
update: (id: number, payload: Partial<NodeRecord>) => updateMut.mutateAsync({ id, payload }),
remove: (id: number) => removeMut.mutateAsync(id),
setEnable: (id: number, enable: boolean) => setEnableMut.mutateAsync({ id, enable }),
probe: (id: number) => probeMut.mutateAsync(id),
restart: (id: number, target: 'xray' | 'panel') => restartMut.mutateAsync({ id, target }),
updatePanels: (ids: number[], dev: boolean): Promise<Msg<NodeUpdateResult[]>> =>
updatePanelsMut.mutateAsync({ ids, dev }),
testConnection: async (payload: Partial<NodeRecord>): Promise<Msg<ProbeResult>> => {