mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-26 04:24:44 +03:00
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:
@@ -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>> => {
|
||||
|
||||
Reference in New Issue
Block a user