[feat] download singbox config #938 #957

This commit is contained in:
Alireza Ahmadi
2026-01-04 17:36:47 +01:00
parent 94cc29edf5
commit 0ef5db4846
3 changed files with 21 additions and 1 deletions
+18
View File
@@ -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)
}