【新增】litessl

【新增】删除历史记录
【调整】批量删除证书
This commit is contained in:
v-me-50
2026-01-13 16:12:29 +08:00
parent 44efcea14a
commit 6c15ae35a1
6 changed files with 98 additions and 0 deletions

View File

@@ -234,3 +234,23 @@ func GetExecLog(c *gin.Context) {
public.SuccessData(c, data, 0)
return
}
func DelWorkflowHistory(c *gin.Context) {
var form struct {
ID string `form:"id"`
}
err := c.Bind(&form)
if err != nil {
public.FailMsg(c, err.Error())
return
}
form.ID = strings.TrimSpace(form.ID)
err = workflow.DelWorkflowHistory(form.ID)
if err != nil {
public.FailMsg(c, err.Error())
return
}
public.SuccessMsg(c, "删除成功")
return
}

View File

@@ -65,6 +65,7 @@ var CADirURLMap = map[string]string{
"sslcom-rsa": "https://acme.ssl.com/sslcom-dv-rsa",
"sslcom-ecc": "https://acme.ssl.com/sslcom-dv-ecc",
"buypass": "https://api.buypass.com/acme/directory",
"litessl": "https://acme.litessl.com/acme/v2/directory",
}
func GetSqlite() (*public.Sqlite, error) {
@@ -286,6 +287,47 @@ func GetZeroSSLEabFromEmail(email string, httpClient *http.Client) (map[string]a
}, nil
}
func GetEabFromBt(httpClient *http.Client) (map[string]any, error) {
APIPath := "https://www.bt.cn/api/v3/litessl/eab"
data := map[string]any{}
jsonData, err := json.Marshal(data)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", APIPath, strings.NewReader(string(jsonData)))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
if httpClient == nil {
httpClient = &http.Client{}
}
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("获取BT EAB信息失败状态码%d", resp.StatusCode)
}
var result map[string]any
err = json.NewDecoder(resp.Body).Decode(&result)
if err != nil {
return nil, fmt.Errorf("解析BT EAB信息失败%v", err)
}
res, ok := result["res"].(map[string]map[string]any)
if !ok {
return nil, fmt.Errorf("BT EAB信息格式错误缺少res字段")
}
if res["data"]["eab_kid"] == nil || res["data"]["eab_hmac"] == nil {
return nil, fmt.Errorf("BT EAB信息不完整缺少kid或hmacEncoded")
}
return map[string]any{
"Kid": res["data"]["eab_kid"],
"HmacEncoded": res["data"]["eab_hmac"],
}, nil
}
func getEABFromAccData(accData map[string]any, eabData *map[string]any) bool {
if accData == nil {
return false
@@ -388,6 +430,8 @@ func GetAcmeClient(email, algorithm, eabId, ca string, httpClient *http.Client,
if err != nil {
return nil, fmt.Errorf("获取ZeroSSL EAB信息失败: %v", err)
}
case "litessl":
eabData, err = GetEabFromBt(httpClient)
case "sslcom", "google":
return nil, fmt.Errorf("未找到EAB信息请在账号管理中添加%s账号", ca)
}

View File

@@ -145,6 +145,10 @@ func SaveCert(source, key, cert, issuerCert, historyId string) (string, error) {
for _, dns := range certObj.DNSNames {
domainSet[dns] = true
}
// 处理 IP 地址
for _, ip := range certObj.IPAddresses {
domainSet[ip.String()] = true
}
// 转成切片并拼接成逗号分隔的字符串
var domains []string

View File

@@ -163,3 +163,31 @@ func CleanWorkflowHistory() error {
}
return nil
}
// DelWorkflowHistory 删除工作流执行历史记录
func DelWorkflowHistory(ids string) error {
idArr := strings.Split(ids, ",")
s, err := GetSqliteObjWH()
if err != nil {
return err
}
defer s.Close()
_, err = s.Where("id IN ('"+strings.Join(idArr, "','")+"')", nil).Delete()
if err != nil {
return err
}
// 删除工作流执行日志
logPath := public.GetSettingIgnoreError("workflow_log_path")
if logPath == "" {
logPath = "logs/workflow"
}
for _, id := range idArr {
logFile := filepath.Join(logPath, id+".log")
if _, err := os.Stat(logFile); err == nil {
if err := os.Remove(logFile); err != nil {
return err
}
}
}
return nil
}

View File

@@ -200,6 +200,7 @@ func init() {
InsertIfNotExists(db, "access_type", map[string]any{"name": "webhook", "type": "host"}, []string{"name", "type"}, []any{"webhook", "host"})
InsertIfNotExists(db, "access_type", map[string]any{"name": "btdomain", "type": "dns"}, []string{"name", "type"}, []any{"btdomain", "dns"})
InsertIfNotExists(db, "access_type", map[string]any{"name": "edgeone", "type": "dns"}, []string{"name", "type"}, []any{"edgeone", "dns"})
err = sqlite_migrate.EnsureDatabaseWithTables(
"data/site_monitor.db",

View File

@@ -47,6 +47,7 @@ func Register(r *gin.Engine) {
workflow.POST("/get_workflow_history", api.GetWorkflowHistory)
workflow.POST("/get_exec_log", api.GetExecLog)
workflow.POST("/stop", api.StopWorkflow)
workflow.POST("/del_workflow_history", api.DelWorkflowHistory)
}
access := v1.Group("/access")
{