mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-14 02:20:53 +08:00
【调整】插件支持动态参数和参数类型
【调整】获取证书列表支持状态过滤 【新增】dns提供商腾讯云eo
This commit is contained in:
105
plugins/alicloud/main.go
Normal file
105
plugins/alicloud/main.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
//go:embed metadata.json
|
||||
var metadataJSON []byte
|
||||
|
||||
var pluginMeta map[string]interface{}
|
||||
|
||||
func init() {
|
||||
if err := json.Unmarshal(metadataJSON, &pluginMeta); err != nil {
|
||||
panic(fmt.Sprintf("解析元数据失败: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
Action string `json:"action"`
|
||||
Params map[string]interface{} `json:"params"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Result map[string]interface{} `json:"result"`
|
||||
}
|
||||
|
||||
func outputJSON(resp *Response) {
|
||||
_ = json.NewEncoder(os.Stdout).Encode(resp)
|
||||
}
|
||||
|
||||
func outputError(msg string, err error) {
|
||||
outputJSON(&Response{
|
||||
Status: "error",
|
||||
Message: fmt.Sprintf("%s: %v", msg, err),
|
||||
})
|
||||
}
|
||||
|
||||
func main() {
|
||||
var req Request
|
||||
input, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
outputError("读取输入失败", err)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(input, &req); err != nil {
|
||||
outputError("解析请求失败", err)
|
||||
return
|
||||
}
|
||||
switch req.Action {
|
||||
case "get_metadata":
|
||||
outputJSON(&Response{Status: "success", Message: "插件信息", Result: pluginMeta})
|
||||
case "list_actions":
|
||||
outputJSON(&Response{Status: "success", Message: "支持的动作", Result: map[string]interface{}{"actions": pluginMeta["actions"]}})
|
||||
case "cdn":
|
||||
rep, err := Cdn(req.Params)
|
||||
if err != nil {
|
||||
outputError("CDN 部署失败", err)
|
||||
return
|
||||
}
|
||||
outputJSON(rep)
|
||||
case "dcdn":
|
||||
rep, err := Dcdn(req.Params)
|
||||
if err != nil {
|
||||
outputError("DCDN 部署失败", err)
|
||||
return
|
||||
}
|
||||
outputJSON(rep)
|
||||
case "oss":
|
||||
rep, err := Oss(req.Params)
|
||||
if err != nil {
|
||||
outputError("OSS 部署失败", err)
|
||||
return
|
||||
}
|
||||
outputJSON(rep)
|
||||
case "waf":
|
||||
rep, err := Waf(req.Params)
|
||||
if err != nil {
|
||||
outputError("WAF 部署失败", err)
|
||||
return
|
||||
}
|
||||
outputJSON(rep)
|
||||
case "esa":
|
||||
rep, err := Esa(req.Params)
|
||||
if err != nil {
|
||||
outputError("ESA 部署失败", err)
|
||||
return
|
||||
}
|
||||
outputJSON(rep)
|
||||
case "cas":
|
||||
rep, err := Cas(req.Params)
|
||||
if err != nil {
|
||||
outputError("CAS 上传失败", err)
|
||||
return
|
||||
}
|
||||
outputJSON(rep)
|
||||
default:
|
||||
outputJSON(&Response{Status: "error", Message: "未知 action: " + req.Action})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user