mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 15:51:11 +08:00
【修复】长期持有tcp连接未关闭
【新增】支持通过webhook调用自己的服务解析dns记录 【新增】支持通过webhook推送证书和密钥 【新增】导入导出工作流、通知、证书、api授权数据 【新增】支持自定义插件目录
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"ALLinSSL/backend/internal/setting"
|
||||
"ALLinSSL/backend/public"
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func GetSetting(c *gin.Context) {
|
||||
@@ -47,3 +49,40 @@ func GetVersion(c *gin.Context) {
|
||||
}
|
||||
public.SuccessData(c, data, 0)
|
||||
}
|
||||
|
||||
func DownloadData(c *gin.Context) {
|
||||
dbPath := "data/data.db"
|
||||
dbName := filepath.Base(dbPath)
|
||||
|
||||
// 设置响应头,让浏览器下载文件
|
||||
c.Header("Content-Type", "application/octet-stream")
|
||||
c.Header("Content-Disposition", "attachment; filename=\""+dbName+"\"")
|
||||
c.File(dbPath)
|
||||
}
|
||||
|
||||
func UploadData(c *gin.Context) {
|
||||
file, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
public.FailMsg(c, "文件上传失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
// 检查文件类型
|
||||
if filepath.Ext(file.Filename) != ".db" {
|
||||
public.FailMsg(c, "只允许上传 .db 文件")
|
||||
return
|
||||
}
|
||||
// 备份源文件
|
||||
// 修改源文件名为 data.db.bak
|
||||
err = os.Rename("data/data.db", "data/data.db.bak")
|
||||
if err != nil {
|
||||
public.FailMsg(c, "备份源文件失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.SaveUploadedFile(file, "data/data.db"); err != nil {
|
||||
public.FailMsg(c, "保存文件失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
public.SuccessMsg(c, "数据上传成功")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user