mirror of https://github.com/allinssl/allinssl
插件接口
parent
9155f47ec9
commit
143db0baae
|
@ -4,6 +4,7 @@ import (
|
||||||
"ALLinSSL/backend/app/dto/response"
|
"ALLinSSL/backend/app/dto/response"
|
||||||
"ALLinSSL/backend/internal/access"
|
"ALLinSSL/backend/internal/access"
|
||||||
"ALLinSSL/backend/internal/cert/deploy"
|
"ALLinSSL/backend/internal/cert/deploy"
|
||||||
|
"ALLinSSL/backend/internal/cert/deploy/plugin"
|
||||||
"ALLinSSL/backend/public"
|
"ALLinSSL/backend/public"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -371,3 +372,36 @@ func GetSiteList(c *gin.Context) {
|
||||||
|
|
||||||
public.SuccessData(c, siteList, len(siteList))
|
public.SuccessData(c, siteList, len(siteList))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetPluginActions(c *gin.Context) {
|
||||||
|
var form struct {
|
||||||
|
Name string `form:"name"`
|
||||||
|
}
|
||||||
|
err := c.Bind(&form)
|
||||||
|
if err != nil {
|
||||||
|
public.FailMsg(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
form.Name = strings.TrimSpace(form.Name)
|
||||||
|
if form.Name == "" {
|
||||||
|
public.FailMsg(c, "插件名称不能为空")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := plugin.GetActions(form.Name)
|
||||||
|
if err != nil {
|
||||||
|
public.FailMsg(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
public.SuccessData(c, data, len(data))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPlugins(c *gin.Context) {
|
||||||
|
data, err := plugin.GetPlugins()
|
||||||
|
if err != nil {
|
||||||
|
public.FailMsg(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
public.SuccessData(c, data, len(data))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -128,6 +128,11 @@ func AddAccount(email, ca, Kid, HmacEncoded, CADirURL string) error {
|
||||||
return fmt.Errorf("failed to get sqlite: %w", err)
|
return fmt.Errorf("failed to get sqlite: %w", err)
|
||||||
}
|
}
|
||||||
now := time.Now().Format("2006-01-02 15:04:05")
|
now := time.Now().Format("2006-01-02 15:04:05")
|
||||||
|
if (ca == "sslcom" || ca == "google") && (Kid == "" || HmacEncoded == "") {
|
||||||
|
return fmt.Errorf("Kid and HmacEncoded are required for %s CA", ca)
|
||||||
|
} else if ca == "custom" && CADirURL == "" {
|
||||||
|
return fmt.Errorf("CADirURL is required for custom CA")
|
||||||
|
}
|
||||||
account := map[string]interface{}{
|
account := map[string]interface{}{
|
||||||
"email": email,
|
"email": email,
|
||||||
"type": ca,
|
"type": ca,
|
||||||
|
|
|
@ -192,7 +192,13 @@ func GetVersion() (map[string]string, error) {
|
||||||
update := "0"
|
update := "0"
|
||||||
newVersionObj, err := http.Get("https://download.allinssl.com/version.json")
|
newVersionObj, err := http.Get("https://download.allinssl.com/version.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to fetch version: %v", err)
|
return map[string]string{
|
||||||
|
"version": version,
|
||||||
|
"new_version": version,
|
||||||
|
"update": update,
|
||||||
|
"log": "",
|
||||||
|
"date": "",
|
||||||
|
}, err
|
||||||
}
|
}
|
||||||
defer newVersionObj.Body.Close()
|
defer newVersionObj.Body.Close()
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,8 @@ func init() {
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "baidu", "type": "dns"}, []string{"name", "type"}, []any{"baidu", "dns"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "baidu", "type": "dns"}, []string{"name", "type"}, []any{"baidu", "dns"})
|
||||||
|
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "btwaf", "type": "host"}, []string{"name", "type"}, []any{"btwaf", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "btwaf", "type": "host"}, []string{"name", "type"}, []any{"btwaf", "host"})
|
||||||
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "doge", "type": "host"}, []string{"name", "type"}, []any{"doge", "host"})
|
||||||
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "plugin", "type": "host"}, []string{"name", "type"}, []any{"plugin", "host"})
|
||||||
|
|
||||||
// 雷池
|
// 雷池
|
||||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "safeline", "type": "host"}, []string{"name", "type"}, []any{"safeline", "host"})
|
InsertIfNotExists(db, "access_type", map[string]any{"name": "safeline", "type": "host"}, []string{"name", "type"}, []any{"safeline", "host"})
|
||||||
|
|
|
@ -51,6 +51,10 @@ func Register(r *gin.Engine) {
|
||||||
access.POST("/del_eab", api.DelEAB)
|
access.POST("/del_eab", api.DelEAB)
|
||||||
access.POST("/upd_eab", api.UpdEAB)
|
access.POST("/upd_eab", api.UpdEAB)
|
||||||
access.POST("/get_all_eab", api.GetAllEAB)
|
access.POST("/get_all_eab", api.GetAllEAB)
|
||||||
|
|
||||||
|
// 插件先放这里
|
||||||
|
access.POST("/get_plugin_actions", api.GetPluginActions)
|
||||||
|
access.POST("/get_plugins", api.GetPlugins)
|
||||||
}
|
}
|
||||||
// acme账户
|
// acme账户
|
||||||
acmeAccount := v1.Group("/acme_account")
|
acmeAccount := v1.Group("/acme_account")
|
||||||
|
|
Loading…
Reference in New Issue