diff options
| author | Mohammad Movaghari <52345697+mohammadmovaghari@users.noreply.github.com> | 2023-04-12 16:29:17 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-12 16:29:17 +0300 |
| commit | c575425292e2c4c690728174e42a6f34963394c2 (patch) | |
| tree | c9b033457baa55a98cea23a8769645f8f3dbd476 /web/controller/server.go | |
| parent | 63f71e527ceddc724e0bd2893c4946b01f3a5f6c (diff) | |
| parent | 82b2809fccb6a131b4f84e2ca236f8bea567beae (diff) | |
Merge branch 'MHSanaei:main' into main
Diffstat (limited to 'web/controller/server.go')
| -rw-r--r-- | web/controller/server.go | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/web/controller/server.go b/web/controller/server.go index 7b7239d5..c5a3965b 100644 --- a/web/controller/server.go +++ b/web/controller/server.go @@ -38,7 +38,9 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) { g.POST("/stopXrayService", a.stopXrayService) g.POST("/restartXrayService", a.restartXrayService) g.POST("/installXray/:version", a.installXray) - g.POST("/logs", a.getLogs) + g.POST("/logs/:count", a.getLogs) + g.POST("/getConfigJson", a.getConfigJson) + g.GET("/getDb", a.getDb) } func (a *ServerController) refreshStatus() { @@ -109,10 +111,34 @@ func (a *ServerController) restartXrayService(c *gin.Context) { } func (a *ServerController) getLogs(c *gin.Context) { - logs, err := a.serverService.GetLogs() + count := c.Param("count") + logs, err := a.serverService.GetLogs(count) if err != nil { jsonMsg(c, I18n(c, "getLogs"), err) return } jsonObj(c, logs, nil) } + +func (a *ServerController) getConfigJson(c *gin.Context) { + configJson, err := a.serverService.GetConfigJson() + if err != nil { + jsonMsg(c, I18n(c, "getLogs"), err) + return + } + jsonObj(c, configJson, nil) +} + +func (a *ServerController) getDb(c *gin.Context) { + db, err := a.serverService.GetDb() + if err != nil { + jsonMsg(c, I18n(c, "getLogs"), err) + return + } + // Set the headers for the response + c.Header("Content-Type", "application/octet-stream") + c.Header("Content-Disposition", "attachment; filename=xui.db") + + // Write the file contents to the response + c.Writer.Write(db) +} |
