2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

refactor: 重构 tools.Write 函数

This commit is contained in:
耗子
2023-11-12 03:02:45 +08:00
parent 46e027b18c
commit ac420debbb
23 changed files with 591 additions and 1957 deletions

View File

@@ -265,7 +265,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
tools.Remove("/tmp/" + backupFile)
color.Greenln("|-压缩成功")
color.Greenln("|-开始移动")
if _, err := tools.Mv("/tmp/"+backupFile+".zip", path+"/"+backupFile+".zip"); err != nil {
if err := tools.Mv("/tmp/"+backupFile+".zip", path+"/"+backupFile+".zip"); err != nil {
color.Redln("|-移动失败: " + err.Error())
return nil
}
@@ -291,7 +291,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
tools.Remove("/tmp/" + backupFile)
color.Greenln("|-压缩成功")
color.Greenln("|-开始移动")
if _, err := tools.Mv("/tmp/"+backupFile+".zip", path+"/"+backupFile+".zip"); err != nil {
if err := tools.Mv("/tmp/"+backupFile+".zip", path+"/"+backupFile+".zip"); err != nil {
color.Redln("|-移动失败: " + err.Error())
return nil
}

View File

@@ -25,14 +25,14 @@ func NewCertController() *CertController {
}
// CAProviders
// @Summary 获取 CA 提供商
// @Description 获取面板证书管理支持的 CA 提供商
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Router /panel/cert/caProviders [get]
//
// @Summary 获取 CA 提供商
// @Description 获取面板证书管理支持的 CA 提供商
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/caProviders [get]
func (r *CertController) CAProviders(ctx http.Context) http.Response {
return Success(ctx, []map[string]string{
{
@@ -59,14 +59,14 @@ func (r *CertController) CAProviders(ctx http.Context) http.Response {
}
// DNSProviders
// @Summary 获取 DNS 提供商
// @Description 获取面板证书管理支持的 DNS 提供商
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Router /panel/cert/dnsProviders [get]
//
// @Summary 获取 DNS 提供商
// @Description 获取面板证书管理支持的 DNS 提供商
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/dnsProviders [get]
func (r *CertController) DNSProviders(ctx http.Context) http.Response {
return Success(ctx, []map[string]any{
{
@@ -85,14 +85,14 @@ func (r *CertController) DNSProviders(ctx http.Context) http.Response {
}
// Algorithms
// @Summary 获取算法列表
// @Description 获取面板证书管理支持的算法列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Router /panel/cert/algorithms [get]
//
// @Summary 获取算法列表
// @Description 获取面板证书管理支持的算法列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/algorithms [get]
func (r *CertController) Algorithms(ctx http.Context) http.Response {
return Success(ctx, []map[string]any{
{
@@ -115,16 +115,15 @@ func (r *CertController) Algorithms(ctx http.Context) http.Response {
}
// UserList
// @Summary 获取用户列表
// @Description 获取面板证书管理的 ACME 用户列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "分页信息"
// @Success 200 {object} SuccessResponse{data=responses.CertList}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/users [get]
//
// @Summary 获取用户列表
// @Description 获取面板证书管理的 ACME 用户列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "request"
// @Success 200 {object} SuccessResponse{data=responses.CertList}
// @Router /panel/cert/users [get]
func (r *CertController) UserList(ctx http.Context) http.Response {
var paginateRequest commonrequests.Paginate
sanitize := Sanitize(ctx, &paginateRequest)
@@ -149,17 +148,16 @@ func (r *CertController) UserList(ctx http.Context) http.Response {
}
// UserStore
// @Summary 添加 ACME 用户
// @Description 添加 ACME 用户到面板证书管理
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.UserStore true "用户信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/users [post]
//
// @Summary 添加 ACME 用户
// @Description 添加 ACME 用户到面板证书管理
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.UserStore true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/users [post]
func (r *CertController) UserStore(ctx http.Context) http.Response {
var storeRequest requests.UserStore
sanitize := Sanitize(ctx, &storeRequest)
@@ -179,18 +177,17 @@ func (r *CertController) UserStore(ctx http.Context) http.Response {
}
// UserUpdate
// @Summary 更新 ACME 用户
// @Description 更新面板证书管理的 ACME 用户
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "用户 ID"
// @Param data body requests.UserUpdate true "用户信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/users/{id} [put]
//
// @Summary 更新 ACME 用户
// @Description 更新面板证书管理的 ACME 用户
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "用户 ID"
// @Param data body requests.UserUpdate true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/users/{id} [put]
func (r *CertController) UserUpdate(ctx http.Context) http.Response {
var updateRequest requests.UserUpdate
sanitize := Sanitize(ctx, &updateRequest)
@@ -211,16 +208,15 @@ func (r *CertController) UserUpdate(ctx http.Context) http.Response {
}
// UserShow
// @Summary 获取 ACME 用户
// @Description 获取面板证书管理的 ACME 用户
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param id path int true "用户 ID"
// @Success 200 {object} SuccessResponse{data=models.CertUser}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/users/{id} [get]
//
// @Summary 获取 ACME 用户
// @Description 获取面板证书管理的 ACME 用户
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param id path int true "用户 ID"
// @Success 200 {object} SuccessResponse{data=models.CertUser}
// @Router /panel/cert/users/{id} [get]
func (r *CertController) UserShow(ctx http.Context) http.Response {
var showAndDestroyRequest requests.UserShowAndDestroy
sanitize := Sanitize(ctx, &showAndDestroyRequest)
@@ -241,17 +237,16 @@ func (r *CertController) UserShow(ctx http.Context) http.Response {
}
// UserDestroy
// @Summary 删除 ACME 用户
// @Description 删除面板证书管理的 ACME 用户
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "用户 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/users/{id} [delete]
//
// @Summary 删除 ACME 用户
// @Description 删除面板证书管理的 ACME 用户
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "用户 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/users/{id} [delete]
func (r *CertController) UserDestroy(ctx http.Context) http.Response {
var showAndDestroyRequest requests.UserShowAndDestroy
sanitize := Sanitize(ctx, &showAndDestroyRequest)
@@ -272,16 +267,15 @@ func (r *CertController) UserDestroy(ctx http.Context) http.Response {
}
// DNSList
// @Summary 获取 DNS 接口列表
// @Description 获取面板证书管理的 DNS 接口列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "分页信息"
// @Success 200 {object} SuccessResponse{data=responses.DNSList}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/dns [get]
//
// @Summary 获取 DNS 接口列表
// @Description 获取面板证书管理的 DNS 接口列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "request"
// @Success 200 {object} SuccessResponse{data=responses.DNSList}
// @Router /panel/cert/dns [get]
func (r *CertController) DNSList(ctx http.Context) http.Response {
var paginateRequest commonrequests.Paginate
sanitize := Sanitize(ctx, &paginateRequest)
@@ -306,17 +300,16 @@ func (r *CertController) DNSList(ctx http.Context) http.Response {
}
// DNSStore
// @Summary 添加 DNS 接口
// @Description 添加 DNS 接口到面板证书管理
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.DNSStore true "DNS 接口信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/dns [post]
//
// @Summary 添加 DNS 接口
// @Description 添加 DNS 接口到面板证书管理
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.DNSStore true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/dns [post]
func (r *CertController) DNSStore(ctx http.Context) http.Response {
var storeRequest requests.DNSStore
sanitize := Sanitize(ctx, &storeRequest)
@@ -336,16 +329,15 @@ func (r *CertController) DNSStore(ctx http.Context) http.Response {
}
// DNSShow
// @Summary 获取 DNS 接口
// @Description 获取面板证书管理的 DNS 接口
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param id path int true "DNS 接口 ID"
// @Success 200 {object} SuccessResponse{data=models.CertDNS}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/dns/{id} [get]
//
// @Summary 获取 DNS 接口
// @Description 获取面板证书管理的 DNS 接口
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param id path int true "DNS 接口 ID"
// @Success 200 {object} SuccessResponse{data=models.CertDNS}
// @Router /panel/cert/dns/{id} [get]
func (r *CertController) DNSShow(ctx http.Context) http.Response {
var showAndDestroyRequest requests.DNSShowAndDestroy
sanitize := Sanitize(ctx, &showAndDestroyRequest)
@@ -366,18 +358,17 @@ func (r *CertController) DNSShow(ctx http.Context) http.Response {
}
// DNSUpdate
// @Summary 更新 DNS 接口
// @Description 更新面板证书管理的 DNS 接口
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "DNS 接口 ID"
// @Param data body requests.DNSUpdate true "DNS 接口信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/dns/{id} [put]
//
// @Summary 更新 DNS 接口
// @Description 更新面板证书管理的 DNS 接口
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "DNS 接口 ID"
// @Param data body requests.DNSUpdate true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/dns/{id} [put]
func (r *CertController) DNSUpdate(ctx http.Context) http.Response {
var updateRequest requests.DNSUpdate
sanitize := Sanitize(ctx, &updateRequest)
@@ -398,17 +389,16 @@ func (r *CertController) DNSUpdate(ctx http.Context) http.Response {
}
// DNSDestroy
// @Summary 删除 DNS 接口
// @Description 删除面板证书管理的 DNS 接口
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "DNS 接口 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/dns/{id} [delete]
//
// @Summary 删除 DNS 接口
// @Description 删除面板证书管理的 DNS 接口
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "DNS 接口 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/dns/{id} [delete]
func (r *CertController) DNSDestroy(ctx http.Context) http.Response {
var showAndDestroyRequest requests.DNSShowAndDestroy
sanitize := Sanitize(ctx, &showAndDestroyRequest)
@@ -429,16 +419,15 @@ func (r *CertController) DNSDestroy(ctx http.Context) http.Response {
}
// CertList
// @Summary 获取证书列表
// @Description 获取面板证书管理的证书列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "分页信息"
// @Success 200 {object} SuccessResponse{data=responses.CertList}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/certs [get]
//
// @Summary 获取证书列表
// @Description 获取面板证书管理的证书列表
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "request"
// @Success 200 {object} SuccessResponse{data=responses.CertList}
// @Router /panel/cert/certs [get]
func (r *CertController) CertList(ctx http.Context) http.Response {
var paginateRequest commonrequests.Paginate
sanitize := Sanitize(ctx, &paginateRequest)
@@ -463,17 +452,16 @@ func (r *CertController) CertList(ctx http.Context) http.Response {
}
// CertStore
// @Summary 添加证书
// @Description 添加证书到面板证书管理
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.CertStore true "证书信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/certs [post]
//
// @Summary 添加证书
// @Description 添加证书到面板证书管理
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.CertStore true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/certs [post]
func (r *CertController) CertStore(ctx http.Context) http.Response {
var storeRequest requests.CertStore
sanitize := Sanitize(ctx, &storeRequest)
@@ -493,18 +481,17 @@ func (r *CertController) CertStore(ctx http.Context) http.Response {
}
// CertUpdate
// @Summary 更新证书
// @Description 更新面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "证书 ID"
// @Param data body requests.CertUpdate true "证书信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/certs/{id} [put]
//
// @Summary 更新证书
// @Description 更新面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "证书 ID"
// @Param data body requests.CertUpdate true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/certs/{id} [put]
func (r *CertController) CertUpdate(ctx http.Context) http.Response {
var updateRequest requests.CertUpdate
sanitize := Sanitize(ctx, &updateRequest)
@@ -525,16 +512,15 @@ func (r *CertController) CertUpdate(ctx http.Context) http.Response {
}
// CertShow
// @Summary 获取证书
// @Description 获取面板证书管理的证书
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param id path int true "证书 ID"
// @Success 200 {object} SuccessResponse{data=models.Cert}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/certs/{id} [get]
//
// @Summary 获取证书
// @Description 获取面板证书管理的证书
// @Tags 证书管理
// @Produce json
// @Security BearerToken
// @Param id path int true "证书 ID"
// @Success 200 {object} SuccessResponse{data=models.Cert}
// @Router /panel/cert/certs/{id} [get]
func (r *CertController) CertShow(ctx http.Context) http.Response {
var showAndDestroyRequest requests.CertShowAndDestroy
sanitize := Sanitize(ctx, &showAndDestroyRequest)
@@ -555,17 +541,16 @@ func (r *CertController) CertShow(ctx http.Context) http.Response {
}
// CertDestroy
// @Summary 删除证书
// @Description 删除面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "证书 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/certs/{id} [delete]
//
// @Summary 删除证书
// @Description 删除面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "证书 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/certs/{id} [delete]
func (r *CertController) CertDestroy(ctx http.Context) http.Response {
var showAndDestroyRequest requests.CertShowAndDestroy
sanitize := Sanitize(ctx, &showAndDestroyRequest)
@@ -586,17 +571,16 @@ func (r *CertController) CertDestroy(ctx http.Context) http.Response {
}
// Obtain
// @Summary 签发证书
// @Description 签发面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Obtain true "证书信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/obtain [post]
//
// @Summary 签发证书
// @Description 签发面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Obtain true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/obtain [post]
func (r *CertController) Obtain(ctx http.Context) http.Response {
var obtainRequest requests.Obtain
sanitize := Sanitize(ctx, &obtainRequest)
@@ -629,17 +613,16 @@ func (r *CertController) Obtain(ctx http.Context) http.Response {
}
// Renew
// @Summary 续签证书
// @Description 续签面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Renew true "证书信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/renew [post]
//
// @Summary 续签证书
// @Description 续签面板证书管理的证书
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Renew true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/cert/renew [post]
func (r *CertController) Renew(ctx http.Context) http.Response {
var renewRequest requests.Renew
sanitize := Sanitize(ctx, &renewRequest)
@@ -659,17 +642,16 @@ func (r *CertController) Renew(ctx http.Context) http.Response {
}
// ManualDNS
// @Summary 获取手动 DNS 记录
// @Description 获取签发证书所需的 DNS 记录
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Obtain true "证书信息"
// @Success 200 {object} SuccessResponse{data=map[string]acme.Resolve}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/cert/manualDNS [post]
//
// @Summary 获取手动 DNS 记录
// @Description 获取签发证书所需的 DNS 记录
// @Tags 证书管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Obtain true "request"
// @Success 200 {object} SuccessResponse{data=map[string]acme.Resolve}
// @Router /panel/cert/manualDNS [post]
func (r *CertController) ManualDNS(ctx http.Context) http.Response {
var obtainRequest requests.Obtain
sanitize := Sanitize(ctx, &obtainRequest)

View File

@@ -263,7 +263,9 @@ logpath = /www/wwwlogs/` + website.Name + `.log
# ` + jailWebsiteName + `-` + jailWebsiteMode + `-END
`
raw += rule
tools.Write("/etc/fail2ban/jail.local", raw, 0644)
if err = tools.Write("/etc/fail2ban/jail.local", raw, 0644); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "写入Fail2ban规则失败")
}
var filter string
if jailWebsiteMode == "cc" {
@@ -279,7 +281,9 @@ failregex = ^<HOST>\s-.*\s` + jailWebsitePath + `.*HTTP/.*$
ignoreregex =
`
}
tools.Write("/etc/fail2ban/filter.d/haozi-"+jailWebsiteName+"-"+jailWebsiteMode+".conf", filter, 0644)
if err = tools.Write("/etc/fail2ban/filter.d/haozi-"+jailWebsiteName+"-"+jailWebsiteMode+".conf", filter, 0644); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "写入Fail2ban规则失败")
}
case "service":
var logPath string
@@ -323,7 +327,9 @@ logpath = ` + logPath + `
# ` + jailName + `-END
`
raw += rule
tools.Write("/etc/fail2ban/jail.local", raw, 0644)
if err := tools.Write("/etc/fail2ban/jail.local", raw, 0644); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "写入Fail2ban规则失败")
}
}
tools.Exec("fail2ban-client reload")
@@ -346,7 +352,9 @@ func (r *Fail2banController) Delete(ctx http.Context) http.Response {
rule := tools.Cut(raw, "# "+jailName+"-START", "# "+jailName+"-END")
raw = strings.Replace(raw, "\n# "+jailName+"-START"+rule+"# "+jailName+"-END", "", -1)
raw = strings.TrimSpace(raw)
tools.Write("/etc/fail2ban/jail.local", raw, 0644)
if err := tools.Write("/etc/fail2ban/jail.local", raw, 0644); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "写入Fail2ban规则失败")
}
tools.Exec("fail2ban-client reload")
return controllers.Success(ctx, nil)
@@ -427,7 +435,9 @@ func (r *Fail2banController) SetWhiteList(ctx http.Context) http.Response {
return controllers.Error(ctx, http.StatusInternalServerError, "解析Fail2ban规则失败Fail2ban可能已损坏")
}
tools.Write("/etc/fail2ban/jail.local", raw, 0644)
if err := tools.Write("/etc/fail2ban/jail.local", raw, 0644); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "写入Fail2ban规则失败")
}
tools.Exec("fail2ban-client reload")
return controllers.Success(ctx, nil)
}

View File

@@ -145,7 +145,9 @@ func (r *Php74Controller) SaveConfig(ctx http.Context) http.Response {
}
config := ctx.Request().Input("config")
tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644)
if err := tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644); err != nil {
return nil
}
return r.Reload(ctx)
}

View File

@@ -145,7 +145,9 @@ func (r *Php80Controller) SaveConfig(ctx http.Context) http.Response {
}
config := ctx.Request().Input("config")
tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644)
if err := tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644); err != nil {
return nil
}
return r.Reload(ctx)
}

View File

@@ -145,7 +145,9 @@ func (r *Php81Controller) SaveConfig(ctx http.Context) http.Response {
}
config := ctx.Request().Input("config")
tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644)
if err := tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644); err != nil {
return nil
}
return r.Reload(ctx)
}

View File

@@ -145,7 +145,9 @@ func (r *Php82Controller) SaveConfig(ctx http.Context) http.Response {
}
config := ctx.Request().Input("config")
tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644)
if err := tools.Write("/www/server/php/"+r.version+"/etc/php.ini", config, 0644); err != nil {
return nil
}
return r.Reload(ctx)
}

View File

@@ -66,8 +66,7 @@ func (r *PhpMyAdminController) SetPort(ctx http.Context) http.Response {
conf := tools.Read("/www/server/vhost/phpmyadmin.conf")
conf = regexp.MustCompile(`listen\s+(\d+);`).ReplaceAllString(conf, "listen "+port+";")
err := tools.Write("/www/server/vhost/phpmyadmin.conf", conf, 0644)
if err != nil {
if err := tools.Write("/www/server/vhost/phpmyadmin.conf", conf, 0644); err != nil {
facades.Log().Request(ctx.Request()).Tags("插件", "phpMyAdmin").With(map[string]any{
"error": err.Error(),
}).Info("修改 phpMyAdmin 端口失败")

View File

@@ -115,7 +115,9 @@ func (r *S3fsController) Add(ctx http.Context) http.Response {
id := carbon.Now().TimestampMilli()
password := ak + ":" + sk
tools.Write("/etc/passwd-s3fs-"+cast.ToString(id), password, 0600)
if err = tools.Write("/etc/passwd-s3fs-"+cast.ToString(id), password, 0600); err != nil {
return nil
}
tools.Exec(`echo 's3fs#` + bucket + ` ` + path + ` fuse _netdev,allow_other,nonempty,url=` + url + `,passwd_file=/etc/passwd-s3fs-` + cast.ToString(id) + ` 0 0' >> /etc/fstab`)
mountCheck := tools.Exec("mount -a 2>&1")
if len(mountCheck) != 0 {

View File

@@ -152,10 +152,15 @@ func (r *SupervisorController) SaveConfig(ctx http.Context) http.Response {
}
config := ctx.Request().Input("config")
var err error
if tools.IsRHEL() {
tools.Write(`/etc/supervisord.conf`, config, 0644)
err = tools.Write(`/etc/supervisord.conf`, config, 0644)
} else {
tools.Write(`/etc/supervisor/supervisord.conf`, config, 0644)
err = tools.Write(`/etc/supervisor/supervisord.conf`, config, 0644)
}
if err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
}
return r.Restart(ctx)
@@ -321,11 +326,17 @@ func (r *SupervisorController) SaveProcessConfig(ctx http.Context) http.Response
process := ctx.Request().Input("process")
config := ctx.Request().Input("config")
var err error
if tools.IsRHEL() {
tools.Write(`/etc/supervisord.d/`+process+`.conf`, config, 0644)
err = tools.Write(`/etc/supervisord.d/`+process+`.conf`, config, 0644)
} else {
tools.Write(`/etc/supervisor/conf.d/`+process+`.conf`, config, 0644)
err = tools.Write(`/etc/supervisor/conf.d/`+process+`.conf`, config, 0644)
}
if err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
}
tools.Exec(`supervisorctl reread`)
tools.Exec(`supervisorctl update`)
tools.Exec(`supervisorctl start ` + process)
@@ -372,10 +383,15 @@ stdout_logfile=/var/log/supervisor/` + name + `.log
stdout_logfile_maxbytes=2MB
`
if tools.IsRHEL() {
tools.Write(`/etc/supervisord.d/`+name+`.conf`, config, 0644)
err = tools.Write(`/etc/supervisord.d/`+name+`.conf`, config, 0644)
} else {
tools.Write(`/etc/supervisor/conf.d/`+name+`.conf`, config, 0644)
err = tools.Write(`/etc/supervisor/conf.d/`+name+`.conf`, config, 0644)
}
if err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, err.Error())
}
tools.Exec(`supervisorctl reread`)
tools.Exec(`supervisorctl update`)
tools.Exec(`supervisorctl start ` + name)

View File

@@ -57,7 +57,10 @@ func (r *ToolBoxController) SetDNS(ctx http.Context) http.Response {
dns += "nameserver " + dns1 + "\n"
dns += "nameserver " + dns2 + "\n"
tools.Write("/etc/resolv.conf", dns, 0644)
if err := tools.Write("/etc/resolv.conf", dns, 0644); err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, "写入 DNS 信息失败")
}
return controllers.Success(ctx, nil)
}
@@ -203,7 +206,9 @@ func (r *ToolBoxController) SetHosts(ctx http.Context) http.Response {
return controllers.Error(ctx, http.StatusUnprocessableEntity, "hosts 信息不能为空")
}
tools.Write("/etc/hosts", hosts, 0644)
if err := tools.Write("/etc/hosts", hosts, 0644); err != nil {
return controllers.Error(ctx, http.StatusUnprocessableEntity, "写入 hosts 信息失败")
}
return controllers.Success(ctx, nil)
}

View File

@@ -23,15 +23,14 @@ func NewSettingController() *SettingController {
}
// List
// @Summary 设置列表
// @Description 获取面板设置列表
// @Tags 面板设置
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=responses.Settings}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/setting/list [get]
//
// @Summary 设置列表
// @Description 获取面板设置列表
// @Tags 面板设置
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=responses.Settings}
// @Router /panel/setting/list [get]
func (r *SettingController) List(ctx http.Context) http.Response {
var settings []models.Setting
err := facades.Orm().Query().Get(&settings)
@@ -61,17 +60,16 @@ func (r *SettingController) List(ctx http.Context) http.Response {
}
// Update
// @Summary 更新设置
// @Description 更新面板设置
// @Tags 面板设置
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Update true "更新设置"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/setting/update [post]
//
// @Summary 更新设置
// @Description 更新面板设置
// @Tags 面板设置
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Update true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/setting/update [post]
func (r *SettingController) Update(ctx http.Context) http.Response {
var updateRequest requests.Update
sanitize := Sanitize(ctx, &updateRequest)

View File

@@ -33,12 +33,13 @@ func NewSwaggerController() *SwaggerController {
}
// Index
// @Summary Swagger UI
// @Description Swagger UI
// @Tags Swagger
// @Success 200
// @Failure 500
// @Router /swagger [get]
//
// @Summary Swagger UI
// @Description Swagger UI
// @Tags Swagger
// @Success 200
// @Failure 500
// @Router /swagger [get]
func (r *SwaggerController) Index(ctx http.Context) http.Response {
config := Config{
URL: "swagger.json",

View File

@@ -20,16 +20,17 @@ func NewUserController() *UserController {
}
// Login
// @Summary 登录
// @Description 通过用户名和密码获取访问令牌
// @Tags 用户鉴权
// @Accept json
// @Produce json
// @Param data body requests.Login true "登录信息"
// @Success 200 {object} SuccessResponse
// @Failure 403 {object} ErrorResponse "用户名或密码错误"
// @Failure 500 {object} ErrorResponse "系统内部错误
// @Router /panel/user/login [post]
//
// @Summary 登录
// @Description 通过用户名和密码获取访问令牌
// @Tags 用户鉴权
// @Accept json
// @Produce json
// @Param data body requests.Login true "request"
// @Success 200 {object} SuccessResponse
// @Failure 403 {object} ErrorResponse "用户名或密码错误"
// @Failure 500 {object} ErrorResponse "系统内部错误
// @Router /panel/user/login [post]
func (r *UserController) Login(ctx http.Context) http.Response {
var loginRequest requests.Login
sanitize := Sanitize(ctx, &loginRequest)
@@ -74,15 +75,14 @@ func (r *UserController) Login(ctx http.Context) http.Response {
}
// Info
// @Summary 用户信息
// @Description 获取当前登录用户信息
// @Tags 用户鉴权
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=responses.Info}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/user/info [get]
//
// @Summary 用户信息
// @Description 获取当前登录用户信息
// @Tags 用户鉴权
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=responses.Info}
// @Router /panel/user/info [get]
func (r *UserController) Info(ctx http.Context) http.Response {
var user models.User
err := facades.Auth().User(ctx, &user)

View File

@@ -31,17 +31,15 @@ func NewWebsiteController() *WebsiteController {
}
// List
// @Summary 获取网站列表
// @Description 获取网站管理的网站列表
// @Tags 网站管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "分页信息"
// @Success 200 {object} SuccessResponse{data=responses.List}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 403 {object} ErrorResponse "插件需更新"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website [get]
//
// @Summary 获取网站列表
// @Description 获取网站管理的网站列表
// @Tags 网站管理
// @Produce json
// @Security BearerToken
// @Param data body commonrequests.Paginate true "request"
// @Success 200 {object} SuccessResponse{data=responses.List}
// @Router /panel/website [get]
func (c *WebsiteController) List(ctx http.Context) http.Response {
var paginateRequest commonrequests.Paginate
sanitize := Sanitize(ctx, &paginateRequest)
@@ -64,18 +62,16 @@ func (c *WebsiteController) List(ctx http.Context) http.Response {
}
// Add
// @Summary 添加网站
// @Description 添加网站到网站管理
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Add true "网站信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 403 {object} ErrorResponse "插件需更新"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website [post]
//
// @Summary 添加网站
// @Description 添加网站到网站管理
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.Add true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website [post]
func (c *WebsiteController) Add(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -111,18 +107,16 @@ func (c *WebsiteController) Add(ctx http.Context) http.Response {
}
// Delete
// @Summary 删除网站
// @Description 删除网站管理的网站
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 403 {object} ErrorResponse "插件需更新"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/{id} [delete]
//
// @Summary 删除网站
// @Description 删除网站管理的网站
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/{id} [delete]
func (c *WebsiteController) Delete(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -148,15 +142,14 @@ func (c *WebsiteController) Delete(ctx http.Context) http.Response {
}
// GetDefaultConfig
// @Summary 获取默认配置
// @Description 获取默认首页和停止页配置
// @Tags 网站管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=map[string]string}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 403 {object} ErrorResponse "插件需更新"
// @Router /panel/website/defaultConfig [get]
//
// @Summary 获取默认配置
// @Description 获取默认首页和停止页配置
// @Tags 网站管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=map[string]string}
// @Router /panel/website/defaultConfig [get]
func (c *WebsiteController) GetDefaultConfig(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -172,18 +165,16 @@ func (c *WebsiteController) GetDefaultConfig(ctx http.Context) http.Response {
}
// SaveDefaultConfig
// @Summary 保存默认配置
// @Description 保存默认首页和停止页配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body map[string]string true "页面信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 403 {object} ErrorResponse "插件需更新"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/defaultConfig [post]
//
// @Summary 保存默认配置
// @Description 保存默认首页和停止页配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body map[string]string true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/defaultConfig [post]
func (c *WebsiteController) SaveDefaultConfig(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -210,17 +201,16 @@ func (c *WebsiteController) SaveDefaultConfig(ctx http.Context) http.Response {
}
// GetConfig
// @Summary 获取配置
// @Description 获取网站的配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse{data=services.PanelWebsite}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/config/{id} [get]
//
// @Summary 获取配置
// @Description 获取网站的配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse{data=services.PanelWebsite}
// @Router /panel/website/config/{id} [get]
func (c *WebsiteController) GetConfig(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -246,18 +236,17 @@ func (c *WebsiteController) GetConfig(ctx http.Context) http.Response {
}
// SaveConfig
// @Summary 保存配置
// @Description 保存网站的配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Param data body requests.SaveConfig true "网站配置"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/config/{id} [post]
//
// @Summary 保存配置
// @Description 保存网站的配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Param data body requests.SaveConfig true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/config/{id} [post]
func (c *WebsiteController) SaveConfig(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -282,17 +271,16 @@ func (c *WebsiteController) SaveConfig(ctx http.Context) http.Response {
}
// ClearLog
// @Summary 清空日志
// @Description 清空网站的日志
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/log/{id} [delete]
//
// @Summary 清空日志
// @Description 清空网站的日志
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/log/{id} [delete]
func (c *WebsiteController) ClearLog(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -316,17 +304,16 @@ func (c *WebsiteController) ClearLog(ctx http.Context) http.Response {
}
// UpdateRemark
// @Summary 更新备注
// @Description 更新网站的备注
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/updateRemark/{id} [post]
//
// @Summary 更新备注
// @Description 更新网站的备注
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/updateRemark/{id} [post]
func (c *WebsiteController) UpdateRemark(ctx http.Context) http.Response {
var idRequest requests.ID
sanitize := Sanitize(ctx, &idRequest)
@@ -353,15 +340,14 @@ func (c *WebsiteController) UpdateRemark(ctx http.Context) http.Response {
}
// BackupList
// @Summary 获取备份列表
// @Description 获取网站的备份列表
// @Tags 网站管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=[]services.BackupFile}
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/backupList [get]
//
// @Summary 获取备份列表
// @Description 获取网站的备份列表
// @Tags 网站管理
// @Produce json
// @Security BearerToken
// @Success 200 {object} SuccessResponse{data=[]services.BackupFile}
// @Router /panel/website/backupList [get]
func (c *WebsiteController) BackupList(ctx http.Context) http.Response {
backupList, err := c.backup.WebsiteList()
if err != nil {
@@ -375,17 +361,16 @@ func (c *WebsiteController) BackupList(ctx http.Context) http.Response {
}
// CreateBackup
// @Summary 创建备份
// @Description 创建网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.ID true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/createBackup [post]
//
// @Summary 创建备份
// @Description 创建网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.ID true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/createBackup [post]
func (c *WebsiteController) CreateBackup(ctx http.Context) http.Response {
var idRequest requests.ID
sanitize := Sanitize(ctx, &idRequest)
@@ -414,18 +399,16 @@ func (c *WebsiteController) CreateBackup(ctx http.Context) http.Response {
}
// UploadBackup
// @Summary 上传备份
// @Description 上传网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param file formData file true "备份文件"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 422 {object} ErrorResponse "上传文件失败"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/uploadBackup [post]
//
// @Summary 上传备份
// @Description 上传网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param file formData file true "备份文件"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/uploadBackup [post]
func (c *WebsiteController) UploadBackup(ctx http.Context) http.Response {
file, err := ctx.Request().File("file")
if err != nil {
@@ -450,18 +433,16 @@ func (c *WebsiteController) UploadBackup(ctx http.Context) http.Response {
}
// RestoreBackup
// @Summary 还原备份
// @Description 还原网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.RestoreBackup true "备份信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 422 {object} ErrorResponse "参数错误"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/restoreBackup [post]
//
// @Summary 还原备份
// @Description 还原网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.RestoreBackup true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/restoreBackup [post]
func (c *WebsiteController) RestoreBackup(ctx http.Context) http.Response {
var restoreBackupRequest requests.RestoreBackup
sanitize := Sanitize(ctx, &restoreBackupRequest)
@@ -487,18 +468,16 @@ func (c *WebsiteController) RestoreBackup(ctx http.Context) http.Response {
}
// DeleteBackup
// @Summary 删除备份
// @Description 删除网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.DeleteBackup true "备份信息"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 422 {object} ErrorResponse "参数错误"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/deleteBackup [delete]
//
// @Summary 删除备份
// @Description 删除网站的备份
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.DeleteBackup true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/deleteBackup [delete]
func (c *WebsiteController) DeleteBackup(ctx http.Context) http.Response {
var deleteBackupRequest requests.DeleteBackup
sanitize := Sanitize(ctx, &deleteBackupRequest)
@@ -519,18 +498,16 @@ func (c *WebsiteController) DeleteBackup(ctx http.Context) http.Response {
}
// ResetConfig
// @Summary 重置配置
// @Description 重置网站的配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.ID true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 422 {object} ErrorResponse "参数错误"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/resetConfig [post]
//
// @Summary 重置配置
// @Description 重置网站的配置
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param data body requests.ID true "request"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/resetConfig [post]
func (c *WebsiteController) ResetConfig(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {
@@ -628,18 +605,16 @@ server
}
// Status
// @Summary 状态
// @Description 启用或停用网站
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Failure 401 {object} ErrorResponse "登录已过期"
// @Failure 422 {object} ErrorResponse "参数错误"
// @Failure 500 {object} ErrorResponse "系统内部错误"
// @Router /panel/website/status/{id} [post]
//
// @Summary 状态
// @Description 启用或停用网站
// @Tags 网站管理
// @Accept json
// @Produce json
// @Security BearerToken
// @Param id path int true "网站 ID"
// @Success 200 {object} SuccessResponse
// @Router /panel/website/status/{id} [post]
func (c *WebsiteController) Status(ctx http.Context) http.Response {
check := Check(ctx, "openresty")
if check != nil {

View File

@@ -310,8 +310,12 @@ func (s *CertImpl) ObtainAuto(ID uint) (certificate.Resource, error) {
}
if cert.Website != nil {
tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".pem", string(ssl.Certificate), 0644)
tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".key", string(ssl.PrivateKey), 0644)
if err := tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".pem", string(ssl.Certificate), 0644); err != nil {
return certificate.Resource{}, err
}
if err := tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".key", string(ssl.PrivateKey), 0644); err != nil {
return certificate.Resource{}, err
}
tools.Exec("systemctl reload openresty")
}
@@ -364,8 +368,12 @@ func (s *CertImpl) ObtainManual(ID uint) (certificate.Resource, error) {
}
if cert.Website != nil {
tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".pem", string(ssl.Certificate), 0644)
tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".key", string(ssl.PrivateKey), 0644)
if err := tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".pem", string(ssl.Certificate), 0644); err != nil {
return certificate.Resource{}, err
}
if err := tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".key", string(ssl.PrivateKey), 0644); err != nil {
return certificate.Resource{}, err
}
tools.Exec("systemctl reload openresty")
}
@@ -465,8 +473,12 @@ func (s *CertImpl) Renew(ID uint) (certificate.Resource, error) {
}
if cert.Website != nil {
tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".pem", string(ssl.Certificate), 0644)
tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".key", string(ssl.PrivateKey), 0644)
if err := tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".pem", string(ssl.Certificate), 0644); err != nil {
return certificate.Resource{}, err
}
if err := tools.Write("/www/server/vhost/ssl/"+cert.Website.Name+".key", string(ssl.PrivateKey), 0644); err != nil {
return certificate.Resource{}, err
}
tools.Exec("systemctl reload openresty")
}

View File

@@ -181,7 +181,9 @@ func (r *WebsiteImpl) Add(website PanelWebsite) (models.Website, error) {
</html>
`
tools.Write(website.Path+"/index.html", index, 0644)
if err := tools.Write(website.Path+"/index.html", index, 0644); err != nil {
return models.Website{}, err
}
portList := ""
domainList := ""
@@ -265,10 +267,18 @@ server
}
`, portList, domainList, website.Path, website.Php, website.Name, website.Name, website.Name)
tools.Write("/www/server/vhost/"+website.Name+".conf", nginxConf, 0644)
tools.Write("/www/server/vhost/rewrite/"+website.Name+".conf", "", 0644)
tools.Write("/www/server/vhost/ssl/"+website.Name+".pem", "", 0644)
tools.Write("/www/server/vhost/ssl/"+website.Name+".key", "", 0644)
if err := tools.Write("/www/server/vhost/"+website.Name+".conf", nginxConf, 0644); err != nil {
return models.Website{}, err
}
if err := tools.Write("/www/server/vhost/rewrite/"+website.Name+".conf", "", 0644); err != nil {
return models.Website{}, err
}
if err := tools.Write("/www/server/vhost/ssl/"+website.Name+".pem", "", 0644); err != nil {
return models.Website{}, err
}
if err := tools.Write("/www/server/vhost/ssl/"+website.Name+".key", "", 0644); err != nil {
return models.Website{}, err
}
tools.Chmod(r.setting.Get(models.SettingKeyWebsitePath), 0755)
tools.Chmod(website.Path, 0755)
@@ -308,8 +318,7 @@ func (r *WebsiteImpl) SaveConfig(config requests.SaveConfig) error {
// 原文
raw := tools.Read("/www/server/vhost/" + website.Name + ".conf")
if strings.TrimSpace(raw) != strings.TrimSpace(config.Raw) {
err := tools.Write("/www/server/vhost/"+website.Name+".conf", config.Raw, 0644)
if err != nil {
if err := tools.Write("/www/server/vhost/"+website.Name+".conf", config.Raw, 0644); err != nil {
return err
}
tools.Exec("systemctl reload openresty")

View File

@@ -13,6 +13,9 @@ const docTemplate = `{
"name": "耗子科技",
"email": "i@haozi.net"
},
"license": {
"name": "GNU Affero General Public License v3"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
@@ -39,12 +42,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -70,12 +67,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -97,7 +88,7 @@ const docTemplate = `{
"summary": "获取证书列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -124,18 +115,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -158,7 +137,7 @@ const docTemplate = `{
"summary": "添加证书",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -173,18 +152,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -231,18 +198,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -272,7 +227,7 @@ const docTemplate = `{
"required": true
},
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -287,18 +242,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -334,18 +277,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -367,7 +298,7 @@ const docTemplate = `{
"summary": "获取 DNS 接口列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -394,18 +325,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -428,7 +347,7 @@ const docTemplate = `{
"summary": "添加 DNS 接口",
"parameters": [
{
"description": "DNS 接口信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -443,18 +362,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -501,18 +408,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -542,7 +437,7 @@ const docTemplate = `{
"required": true
},
{
"description": "DNS 接口信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -557,18 +452,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -604,18 +487,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -641,12 +512,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -671,7 +536,7 @@ const docTemplate = `{
"summary": "获取手动 DNS 记录",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -701,18 +566,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -737,7 +590,7 @@ const docTemplate = `{
"summary": "签发证书",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -752,18 +605,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -788,7 +629,7 @@ const docTemplate = `{
"summary": "续签证书",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -803,18 +644,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -836,7 +665,7 @@ const docTemplate = `{
"summary": "获取用户列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -863,18 +692,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -897,7 +714,7 @@ const docTemplate = `{
"summary": "添加 ACME 用户",
"parameters": [
{
"description": "用户信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -912,18 +729,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -970,18 +775,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1011,7 +804,7 @@ const docTemplate = `{
"required": true
},
{
"description": "用户信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1026,18 +819,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1073,18 +854,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1122,18 +891,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1158,7 +915,7 @@ const docTemplate = `{
"summary": "更新设置",
"parameters": [
{
"description": "更新设置",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1173,18 +930,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1222,18 +967,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1253,7 +986,7 @@ const docTemplate = `{
"summary": "登录",
"parameters": [
{
"description": "登录信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1301,7 +1034,7 @@ const docTemplate = `{
"summary": "获取网站列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1328,24 +1061,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1368,7 +1083,7 @@ const docTemplate = `{
"summary": "添加网站",
"parameters": [
{
"description": "网站信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1383,24 +1098,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1441,18 +1138,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1502,18 +1187,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1543,7 +1216,7 @@ const docTemplate = `{
"required": true
},
{
"description": "网站配置",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1558,18 +1231,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1594,7 +1255,7 @@ const docTemplate = `{
"summary": "创建备份",
"parameters": [
{
"description": "网站 ID",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1609,18 +1270,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1661,18 +1310,6 @@ const docTemplate = `{
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1695,7 +1332,7 @@ const docTemplate = `{
"summary": "保存默认配置",
"parameters": [
{
"description": "页面信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1713,24 +1350,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1755,7 +1374,7 @@ const docTemplate = `{
"summary": "删除备份",
"parameters": [
{
"description": "备份信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1770,24 +1389,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1825,18 +1426,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1861,7 +1450,7 @@ const docTemplate = `{
"summary": "重置配置",
"parameters": [
{
"description": "网站 ID",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1876,24 +1465,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1918,7 +1489,7 @@ const docTemplate = `{
"summary": "还原备份",
"parameters": [
{
"description": "备份信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1933,24 +1504,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1988,24 +1541,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -2043,18 +1578,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -2092,24 +1615,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "上传文件失败",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -2147,24 +1652,6 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}

View File

@@ -7,6 +7,9 @@
"name": "耗子科技",
"email": "i@haozi.net"
},
"license": {
"name": "GNU Affero General Public License v3"
},
"version": "2"
},
"basePath": "/api",
@@ -32,12 +35,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -63,12 +60,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -90,7 +81,7 @@
"summary": "获取证书列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -117,18 +108,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -151,7 +130,7 @@
"summary": "添加证书",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -166,18 +145,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -224,18 +191,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -265,7 +220,7 @@
"required": true
},
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -280,18 +235,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -327,18 +270,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -360,7 +291,7 @@
"summary": "获取 DNS 接口列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -387,18 +318,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -421,7 +340,7 @@
"summary": "添加 DNS 接口",
"parameters": [
{
"description": "DNS 接口信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -436,18 +355,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -494,18 +401,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -535,7 +430,7 @@
"required": true
},
{
"description": "DNS 接口信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -550,18 +445,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -597,18 +480,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -634,12 +505,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -664,7 +529,7 @@
"summary": "获取手动 DNS 记录",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -694,18 +559,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -730,7 +583,7 @@
"summary": "签发证书",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -745,18 +598,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -781,7 +622,7 @@
"summary": "续签证书",
"parameters": [
{
"description": "证书信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -796,18 +637,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -829,7 +658,7 @@
"summary": "获取用户列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -856,18 +685,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -890,7 +707,7 @@
"summary": "添加 ACME 用户",
"parameters": [
{
"description": "用户信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -905,18 +722,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -963,18 +768,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1004,7 +797,7 @@
"required": true
},
{
"description": "用户信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1019,18 +812,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1066,18 +847,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1115,18 +884,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1151,7 +908,7 @@
"summary": "更新设置",
"parameters": [
{
"description": "更新设置",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1166,18 +923,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1215,18 +960,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1246,7 +979,7 @@
"summary": "登录",
"parameters": [
{
"description": "登录信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1294,7 +1027,7 @@
"summary": "获取网站列表",
"parameters": [
{
"description": "分页信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1321,24 +1054,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1361,7 +1076,7 @@
"summary": "添加网站",
"parameters": [
{
"description": "网站信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1376,24 +1091,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1434,18 +1131,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1495,18 +1180,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1536,7 +1209,7 @@
"required": true
},
{
"description": "网站配置",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1551,18 +1224,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1587,7 +1248,7 @@
"summary": "创建备份",
"parameters": [
{
"description": "网站 ID",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1602,18 +1263,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1654,18 +1303,6 @@
}
]
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
},
@@ -1688,7 +1325,7 @@
"summary": "保存默认配置",
"parameters": [
{
"description": "页面信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1706,24 +1343,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1748,7 +1367,7 @@
"summary": "删除备份",
"parameters": [
{
"description": "备份信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1763,24 +1382,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1818,18 +1419,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1854,7 +1443,7 @@
"summary": "重置配置",
"parameters": [
{
"description": "网站 ID",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1869,24 +1458,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1911,7 +1482,7 @@
"summary": "还原备份",
"parameters": [
{
"description": "备份信息",
"description": "request",
"name": "data",
"in": "body",
"required": true,
@@ -1926,24 +1497,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -1981,24 +1534,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -2036,18 +1571,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -2085,24 +1608,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"422": {
"description": "上传文件失败",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}
@@ -2140,24 +1645,6 @@
"schema": {
"$ref": "#/definitions/controllers.SuccessResponse"
}
},
"401": {
"description": "登录已过期",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"403": {
"description": "插件需更新",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
},
"500": {
"description": "系统内部错误",
"schema": {
"$ref": "#/definitions/controllers.ErrorResponse"
}
}
}
}

View File

@@ -462,6 +462,8 @@ info:
email: i@haozi.net
name: 耗子科技
description: 耗子 Linux 面板的 API 信息
license:
name: GNU Affero General Public License v3
title: 耗子 Linux 面板 API
version: "2"
paths:
@@ -475,10 +477,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取算法列表
@@ -494,10 +492,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取 CA 提供商
@@ -507,7 +501,7 @@ paths:
get:
description: 获取面板证书管理的证书列表
parameters:
- description: 分页信息
- description: request
in: body
name: data
required: true
@@ -525,14 +519,6 @@ paths:
data:
$ref: '#/definitions/responses.CertList'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取证书列表
@@ -543,7 +529,7 @@ paths:
- application/json
description: 添加证书到面板证书管理
parameters:
- description: 证书信息
- description: request
in: body
name: data
required: true
@@ -556,14 +542,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 添加证书
@@ -587,14 +565,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 删除证书
@@ -620,14 +590,6 @@ paths:
data:
$ref: '#/definitions/models.Cert'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取证书
@@ -643,7 +605,7 @@ paths:
name: id
required: true
type: integer
- description: 证书信息
- description: request
in: body
name: data
required: true
@@ -656,14 +618,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 更新证书
@@ -673,7 +627,7 @@ paths:
get:
description: 获取面板证书管理的 DNS 接口列表
parameters:
- description: 分页信息
- description: request
in: body
name: data
required: true
@@ -691,14 +645,6 @@ paths:
data:
$ref: '#/definitions/responses.DNSList'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取 DNS 接口列表
@@ -709,7 +655,7 @@ paths:
- application/json
description: 添加 DNS 接口到面板证书管理
parameters:
- description: DNS 接口信息
- description: request
in: body
name: data
required: true
@@ -722,14 +668,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 添加 DNS 接口
@@ -753,14 +691,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 删除 DNS 接口
@@ -786,14 +716,6 @@ paths:
data:
$ref: '#/definitions/models.CertDNS'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取 DNS 接口
@@ -809,7 +731,7 @@ paths:
name: id
required: true
type: integer
- description: DNS 接口信息
- description: request
in: body
name: data
required: true
@@ -822,14 +744,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 更新 DNS 接口
@@ -845,10 +759,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取 DNS 提供商
@@ -860,7 +770,7 @@ paths:
- application/json
description: 获取签发证书所需的 DNS 记录
parameters:
- description: 证书信息
- description: request
in: body
name: data
required: true
@@ -880,14 +790,6 @@ paths:
$ref: '#/definitions/acme.Resolve'
type: object
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取手动 DNS 记录
@@ -899,7 +801,7 @@ paths:
- application/json
description: 签发面板证书管理的证书
parameters:
- description: 证书信息
- description: request
in: body
name: data
required: true
@@ -912,14 +814,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 签发证书
@@ -931,7 +825,7 @@ paths:
- application/json
description: 续签面板证书管理的证书
parameters:
- description: 证书信息
- description: request
in: body
name: data
required: true
@@ -944,14 +838,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 续签证书
@@ -961,7 +847,7 @@ paths:
get:
description: 获取面板证书管理的 ACME 用户列表
parameters:
- description: 分页信息
- description: request
in: body
name: data
required: true
@@ -979,14 +865,6 @@ paths:
data:
$ref: '#/definitions/responses.CertList'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取用户列表
@@ -997,7 +875,7 @@ paths:
- application/json
description: 添加 ACME 用户到面板证书管理
parameters:
- description: 用户信息
- description: request
in: body
name: data
required: true
@@ -1010,14 +888,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 添加 ACME 用户
@@ -1041,14 +911,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 删除 ACME 用户
@@ -1074,14 +936,6 @@ paths:
data:
$ref: '#/definitions/models.CertUser'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取 ACME 用户
@@ -1097,7 +951,7 @@ paths:
name: id
required: true
type: integer
- description: 用户信息
- description: request
in: body
name: data
required: true
@@ -1110,14 +964,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 更新 ACME 用户
@@ -1138,14 +984,6 @@ paths:
data:
$ref: '#/definitions/responses.Settings'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 设置列表
@@ -1157,7 +995,7 @@ paths:
- application/json
description: 更新面板设置
parameters:
- description: 更新设置
- description: request
in: body
name: data
required: true
@@ -1170,14 +1008,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 更新设置
@@ -1198,14 +1028,6 @@ paths:
data:
$ref: '#/definitions/responses.Info'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 用户信息
@@ -1217,7 +1039,7 @@ paths:
- application/json
description: 通过用户名和密码获取访问令牌
parameters:
- description: 登录信息
- description: request
in: body
name: data
required: true
@@ -1245,7 +1067,7 @@ paths:
get:
description: 获取网站管理的网站列表
parameters:
- description: 分页信息
- description: request
in: body
name: data
required: true
@@ -1263,18 +1085,6 @@ paths:
data:
$ref: '#/definitions/responses.List'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"403":
description: 插件需更新
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取网站列表
@@ -1285,7 +1095,7 @@ paths:
- application/json
description: 添加网站到网站管理
parameters:
- description: 网站信息
- description: request
in: body
name: data
required: true
@@ -1298,18 +1108,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"403":
description: 插件需更新
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 添加网站
@@ -1333,18 +1131,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"403":
description: 插件需更新
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 删除网站
@@ -1367,14 +1153,6 @@ paths:
$ref: '#/definitions/services.BackupFile'
type: array
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取备份列表
@@ -1403,14 +1181,6 @@ paths:
data:
$ref: '#/definitions/services.PanelWebsite'
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取配置
@@ -1426,7 +1196,7 @@ paths:
name: id
required: true
type: integer
- description: 网站配置
- description: request
in: body
name: data
required: true
@@ -1439,14 +1209,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 保存配置
@@ -1458,7 +1220,7 @@ paths:
- application/json
description: 创建网站的备份
parameters:
- description: 网站 ID
- description: request
in: body
name: data
required: true
@@ -1471,14 +1233,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 创建备份
@@ -1501,14 +1255,6 @@ paths:
type: string
type: object
type: object
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"403":
description: 插件需更新
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 获取默认配置
@@ -1519,7 +1265,7 @@ paths:
- application/json
description: 保存默认首页和停止页配置
parameters:
- description: 页面信息
- description: request
in: body
name: data
required: true
@@ -1534,18 +1280,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"403":
description: 插件需更新
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 保存默认配置
@@ -1557,7 +1291,7 @@ paths:
- application/json
description: 删除网站的备份
parameters:
- description: 备份信息
- description: request
in: body
name: data
required: true
@@ -1570,18 +1304,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"422":
description: 参数错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 删除备份
@@ -1605,14 +1327,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 清空日志
@@ -1624,7 +1338,7 @@ paths:
- application/json
description: 重置网站的配置
parameters:
- description: 网站 ID
- description: request
in: body
name: data
required: true
@@ -1637,18 +1351,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"422":
description: 参数错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 重置配置
@@ -1660,7 +1362,7 @@ paths:
- application/json
description: 还原网站的备份
parameters:
- description: 备份信息
- description: request
in: body
name: data
required: true
@@ -1673,18 +1375,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"422":
description: 参数错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 还原备份
@@ -1708,18 +1398,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"422":
description: 参数错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 状态
@@ -1743,14 +1421,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 更新备注
@@ -1774,18 +1444,6 @@ paths:
description: OK
schema:
$ref: '#/definitions/controllers.SuccessResponse'
"401":
description: 登录已过期
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"422":
description: 上传文件失败
schema:
$ref: '#/definitions/controllers.ErrorResponse'
"500":
description: 系统内部错误
schema:
$ref: '#/definitions/controllers.ErrorResponse'
security:
- BearerToken: []
summary: 上传备份

21
main.go
View File

@@ -22,18 +22,21 @@ import (
"panel/bootstrap"
)
// @title 耗子 Linux 面板 API
// @version 2
// @description 耗子 Linux 面板的 API 信息
// @title 耗子 Linux 面板 API
// @version 2
// @description 耗子 Linux 面板的 API 信息
// @contact.name 耗子科技
// @contact.email i@haozi.net
// @contact.name 耗子科技
// @contact.email i@haozi.net
// @securityDefinitions.apikey BearerToken
// @in header
// @name Authorization
// @license.name GNU Affero General Public License v3
// @license url https://www.gnu.org/licenses/agpl-3.0.html
// @BasePath /api
// @securityDefinitions.apikey BearerToken
// @in header
// @name Authorization
// @BasePath /api
func main() {
// 启动框架
bootstrap.Boot()

View File

@@ -162,27 +162,17 @@ func Empty(path string) bool {
}
// Mv 移动文件/目录
func Mv(src, dst string) (bool, error) {
func Mv(src, dst string) error {
cmd := exec.Command("mv", src, dst)
err := cmd.Run()
if err != nil {
return false, err
}
return true, nil
return cmd.Run()
}
// Cp 复制文件/目录
func Cp(src, dst string) (bool, error) {
func Cp(src, dst string) error {
cmd := exec.Command("cp", "-r", src, dst)
err := cmd.Run()
if err != nil {
return false, err
}
return true, nil
return cmd.Run()
}
// Size 获取路径大小
@@ -197,19 +187,11 @@ func Size(path string) (int64, error) {
return nil
})
if err != nil {
return 0, err
}
return size, nil
return size, err
}
// FileSize 获取文件大小
func FileSize(path string) (int64, error) {
info, err := os.Stat(path)
if err != nil {
return 0, err
}
return info.Size(), nil
return info.Size(), err
}

View File

@@ -113,7 +113,7 @@ func (s *SystemHelperTestSuite) TestMv() {
err := os.WriteFile(filePath, []byte("test data"), 0644)
s.Nil(err)
s.True(Mv(filePath, "/tmp/testfile2"))
s.Nil(Mv(filePath, "/tmp/testfile2"))
s.False(Exists(filePath))
}
@@ -124,7 +124,7 @@ func (s *SystemHelperTestSuite) TestCp() {
err := os.WriteFile(filePath, []byte("test data"), 0644)
s.Nil(err)
s.True(Cp(filePath, "/tmp/testfile2"))
s.Nil(Cp(filePath, "/tmp/testfile2"))
s.True(Exists(filePath))
}