mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-08 07:41:10 +08:00
【新增】litessl
【新增】删除历史记录 【调整】批量删除证书
This commit is contained in:
@@ -234,3 +234,23 @@ func GetExecLog(c *gin.Context) {
|
|||||||
public.SuccessData(c, data, 0)
|
public.SuccessData(c, data, 0)
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ var CADirURLMap = map[string]string{
|
|||||||
"sslcom-rsa": "https://acme.ssl.com/sslcom-dv-rsa",
|
"sslcom-rsa": "https://acme.ssl.com/sslcom-dv-rsa",
|
||||||
"sslcom-ecc": "https://acme.ssl.com/sslcom-dv-ecc",
|
"sslcom-ecc": "https://acme.ssl.com/sslcom-dv-ecc",
|
||||||
"buypass": "https://api.buypass.com/acme/directory",
|
"buypass": "https://api.buypass.com/acme/directory",
|
||||||
|
"litessl": "https://acme.litessl.com/acme/v2/directory",
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSqlite() (*public.Sqlite, error) {
|
func GetSqlite() (*public.Sqlite, error) {
|
||||||
@@ -286,6 +287,47 @@ func GetZeroSSLEabFromEmail(email string, httpClient *http.Client) (map[string]a
|
|||||||
}, nil
|
}, 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 {
|
func getEABFromAccData(accData map[string]any, eabData *map[string]any) bool {
|
||||||
if accData == nil {
|
if accData == nil {
|
||||||
return false
|
return false
|
||||||
@@ -388,6 +430,8 @@ func GetAcmeClient(email, algorithm, eabId, ca string, httpClient *http.Client,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("获取ZeroSSL EAB信息失败: %v", err)
|
return nil, fmt.Errorf("获取ZeroSSL EAB信息失败: %v", err)
|
||||||
}
|
}
|
||||||
|
case "litessl":
|
||||||
|
eabData, err = GetEabFromBt(httpClient)
|
||||||
case "sslcom", "google":
|
case "sslcom", "google":
|
||||||
return nil, fmt.Errorf("未找到EAB信息,请在账号管理中添加%s账号", ca)
|
return nil, fmt.Errorf("未找到EAB信息,请在账号管理中添加%s账号", ca)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,10 @@ func SaveCert(source, key, cert, issuerCert, historyId string) (string, error) {
|
|||||||
for _, dns := range certObj.DNSNames {
|
for _, dns := range certObj.DNSNames {
|
||||||
domainSet[dns] = true
|
domainSet[dns] = true
|
||||||
}
|
}
|
||||||
|
// 处理 IP 地址
|
||||||
|
for _, ip := range certObj.IPAddresses {
|
||||||
|
domainSet[ip.String()] = true
|
||||||
|
}
|
||||||
|
|
||||||
// 转成切片并拼接成逗号分隔的字符串
|
// 转成切片并拼接成逗号分隔的字符串
|
||||||
var domains []string
|
var domains []string
|
||||||
|
|||||||
@@ -163,3 +163,31 @@ func CleanWorkflowHistory() error {
|
|||||||
}
|
}
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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": "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": "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(
|
err = sqlite_migrate.EnsureDatabaseWithTables(
|
||||||
"data/site_monitor.db",
|
"data/site_monitor.db",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func Register(r *gin.Engine) {
|
|||||||
workflow.POST("/get_workflow_history", api.GetWorkflowHistory)
|
workflow.POST("/get_workflow_history", api.GetWorkflowHistory)
|
||||||
workflow.POST("/get_exec_log", api.GetExecLog)
|
workflow.POST("/get_exec_log", api.GetExecLog)
|
||||||
workflow.POST("/stop", api.StopWorkflow)
|
workflow.POST("/stop", api.StopWorkflow)
|
||||||
|
workflow.POST("/del_workflow_history", api.DelWorkflowHistory)
|
||||||
}
|
}
|
||||||
access := v1.Group("/access")
|
access := v1.Group("/access")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user