From 0ef5db4846c316fa6e12994fe94cd10aeb714c70 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Sun, 4 Jan 2026 17:36:47 +0100 Subject: [PATCH] [feat] download singbox config #938 #957 --- api/apiHandler.go | 2 ++ api/apiService.go | 18 ++++++++++++++++++ frontend | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/api/apiHandler.go b/api/apiHandler.go index 7e38a28..3237bde 100644 --- a/api/apiHandler.go +++ b/api/apiHandler.go @@ -95,6 +95,8 @@ func (a *APIHandler) getHandler(c *gin.Context) { a.ApiService.GetDb(c) case "tokens": a.ApiService.GetTokens(c) + case "singbox-config": + a.ApiService.GetSingboxConfig(c) default: jsonMsg(c, "failed", common.NewError("unknown action: ", action)) } diff --git a/api/apiService.go b/api/apiService.go index 2a8a885..8e6317e 100644 --- a/api/apiService.go +++ b/api/apiService.go @@ -378,3 +378,21 @@ func (a *ApiService) DeleteToken(c *gin.Context) { err := a.UserService.DeleteToken(tokenId) jsonMsg(c, "", err) } + +func (a *ApiService) GetSingboxConfig(c *gin.Context) { + config, err := a.ConfigService.GetConfig("") + if err != nil { + c.Status(400) + c.Writer.WriteString(err.Error()) + return + } + rawConfig, err := json.MarshalIndent(config, "", " ") + if err != nil { + c.Status(400) + c.Writer.WriteString(err.Error()) + return + } + c.Header("Content-Type", "application/json") + c.Header("Content-Disposition", "attachment; filename=config_"+time.Now().Format("20060102-150405")+".json") + c.Writer.Write(rawConfig) +} diff --git a/frontend b/frontend index 21c201d..e3c5a21 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit 21c201df8c58e6051c1f7939fb2566a6a8a2ac4c +Subproject commit e3c5a21f2f5bccf38d6f7cc2a07ddebe255c19d1