@@ -95,6 +95,8 @@ func (a *APIHandler) getHandler(c *gin.Context) {
|
|||||||
a.ApiService.GetDb(c)
|
a.ApiService.GetDb(c)
|
||||||
case "tokens":
|
case "tokens":
|
||||||
a.ApiService.GetTokens(c)
|
a.ApiService.GetTokens(c)
|
||||||
|
case "singbox-config":
|
||||||
|
a.ApiService.GetSingboxConfig(c)
|
||||||
default:
|
default:
|
||||||
jsonMsg(c, "failed", common.NewError("unknown action: ", action))
|
jsonMsg(c, "failed", common.NewError("unknown action: ", action))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,3 +378,21 @@ func (a *ApiService) DeleteToken(c *gin.Context) {
|
|||||||
err := a.UserService.DeleteToken(tokenId)
|
err := a.UserService.DeleteToken(tokenId)
|
||||||
jsonMsg(c, "", err)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
Submodule frontend updated: 21c201df8c...e3c5a21f2f
Reference in New Issue
Block a user