mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-25 12:04: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:
@@ -41,6 +41,8 @@ func (a *NodeController) initRouter(g *gin.RouterGroup) {
|
||||
g.POST("/inbounds", a.inbounds)
|
||||
g.POST("/probe/:id", a.probe)
|
||||
g.POST("/updatePanel", a.updatePanel)
|
||||
g.POST("/restartXray/:id", a.restartXray)
|
||||
g.POST("/restartPanel/:id", a.restartPanel)
|
||||
g.GET("/history/:id/:metric/:bucket", a.history)
|
||||
g.POST("/mtls/ca", a.mtlsCa)
|
||||
g.POST("/mtls/trustCA", a.setMtlsTrustCA)
|
||||
@@ -349,6 +351,34 @@ func (a *NodeController) updatePanel(c *gin.Context) {
|
||||
jsonMsgObj(c, I18nWeb(c, "pages.nodes.toasts.updateStarted"), results, err)
|
||||
}
|
||||
|
||||
func (a *NodeController) restartXray(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil || id <= 0 {
|
||||
jsonMsg(c, I18nWeb(c, "pages.nodes.restartXray"), fmt.Errorf("invalid node ID"))
|
||||
return
|
||||
}
|
||||
err = a.nodeService.RestartXray(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.nodes.restartXray"), err)
|
||||
return
|
||||
}
|
||||
jsonMsg(c, I18nWeb(c, "pages.nodes.toasts.xrayRestarted"), nil)
|
||||
}
|
||||
|
||||
func (a *NodeController) restartPanel(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil || id <= 0 {
|
||||
jsonMsg(c, I18nWeb(c, "pages.nodes.restartPanel"), fmt.Errorf("invalid node ID"))
|
||||
return
|
||||
}
|
||||
err = a.nodeService.RestartPanel(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.nodes.restartPanel"), err)
|
||||
return
|
||||
}
|
||||
jsonMsg(c, I18nWeb(c, "pages.nodes.toasts.panelRestartAccepted"), nil)
|
||||
}
|
||||
|
||||
func (a *NodeController) history(c *gin.Context) {
|
||||
id, err := strconv.Atoi(c.Param("id"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user