mirror of
https://github.com/allinssl/allinssl.git
synced 2025-12-12 09:44:09 +08:00
@@ -6,8 +6,9 @@ import (
|
||||
"ALLinSSL/backend/internal/cert/deploy"
|
||||
"ALLinSSL/backend/internal/cert/deploy/plugin"
|
||||
"ALLinSSL/backend/public"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetAccessList(c *gin.Context) {
|
||||
@@ -323,6 +324,8 @@ func TestAccess(c *gin.Context) {
|
||||
result = deploy.TencentCloudAPITest(form.ID)
|
||||
case "aliyun":
|
||||
result = deploy.AliyunCdnAPITest(form.ID)
|
||||
case "rainyun":
|
||||
result = deploy.RainyunApiTest(form.ID)
|
||||
case "qiniu":
|
||||
result = deploy.QiniuAPITest(form.ID)
|
||||
case "baidu":
|
||||
|
||||
@@ -10,6 +10,13 @@ import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
azcorecloud "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
"github.com/go-acme/lego/v4/certificate"
|
||||
@@ -31,18 +38,13 @@ import (
|
||||
"github.com/go-acme/lego/v4/providers/dns/namedotcom"
|
||||
"github.com/go-acme/lego/v4/providers/dns/namesilo"
|
||||
"github.com/go-acme/lego/v4/providers/dns/ns1"
|
||||
"github.com/go-acme/lego/v4/providers/dns/rainyun"
|
||||
"github.com/go-acme/lego/v4/providers/dns/route53"
|
||||
"github.com/go-acme/lego/v4/providers/dns/spaceship"
|
||||
"github.com/go-acme/lego/v4/providers/dns/tencentcloud"
|
||||
"github.com/go-acme/lego/v4/providers/dns/volcengine"
|
||||
"github.com/go-acme/lego/v4/providers/dns/westcn"
|
||||
"github.com/go-acme/lego/v4/registration"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var AlgorithmMap = map[string]certcrypto.KeyType{
|
||||
@@ -217,6 +219,11 @@ func GetDNSProvider(providerName string, creds map[string]string, httpClient *ht
|
||||
config.APISecret = creds["api_secret"]
|
||||
config.PropagationTimeout = maxWait
|
||||
return spaceship.NewDNSProviderConfig(config)
|
||||
case "rainyun":
|
||||
config := rainyun.NewDefaultConfig()
|
||||
config.APIKey = creds["api_key"]
|
||||
config.PropagationTimeout = maxWait
|
||||
return rainyun.NewDNSProviderConfig(config)
|
||||
case "btdomain":
|
||||
config := bt.NewDefaultConfig()
|
||||
config.AccountID = creds["account_id"]
|
||||
|
||||
@@ -110,6 +110,9 @@ func Deploy(cfg map[string]any, logger *public.Logger) error {
|
||||
case "webhook":
|
||||
logger.Debug("通过Webhook推送证书...")
|
||||
return webhook.Deploy(cfg)
|
||||
case "rainyun-sslcenter":
|
||||
logger.Debug("部署到雨云证书中...")
|
||||
return DeployRainyunSSLCenter(cfg)
|
||||
default:
|
||||
return fmt.Errorf("不支持的部署: %s", providerName)
|
||||
}
|
||||
|
||||
130
backend/internal/cert/deploy/rainyun.go
Normal file
130
backend/internal/cert/deploy/rainyun.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"ALLinSSL/backend/internal/access"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
var rainyunApi = "https://api.v2.rainyun.com"
|
||||
var httpClient = &http.Client{}
|
||||
|
||||
func RainyunApiTest(providerID string) error {
|
||||
providerData, err := access.GetAccess(providerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
providerConfigStr, ok := providerData["config"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("api配置错误")
|
||||
}
|
||||
// 解析 JSON 配置
|
||||
var providerConfig map[string]string
|
||||
err = json.Unmarshal([]byte(providerConfigStr), &providerConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := requestRainyunApi("/user/", providerConfig["api_key"], http.MethodGet, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if gjson.Get(resp, "code").Int() != 200 {
|
||||
return errors.New(gjson.Get(resp, "message").String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeployRainyunSSLCenter(cfg map[string]any) error {
|
||||
// 获取证书
|
||||
cert, ok := cfg["certificate"].(map[string]any)
|
||||
if !ok {
|
||||
return fmt.Errorf("证书不存在")
|
||||
}
|
||||
|
||||
// 获取ApiKey
|
||||
var providerID string
|
||||
switch v := cfg["provider_id"].(type) {
|
||||
case float64:
|
||||
providerID = strconv.Itoa(int(v))
|
||||
case string:
|
||||
providerID = v
|
||||
default:
|
||||
return fmt.Errorf("参数错误:provider_id")
|
||||
}
|
||||
providerData, err := access.GetAccess(providerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
providerConfigStr, _ := providerData["config"].(string)
|
||||
var providerConfig map[string]string
|
||||
err = json.Unmarshal([]byte(providerConfigStr), &providerConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
apiKey := providerConfig["api_key"]
|
||||
|
||||
// 校验参数
|
||||
certId, ok := cfg["cert_id"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("参数错误:cert_id")
|
||||
}
|
||||
_, ok = cert["key"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("证书错误:key")
|
||||
}
|
||||
_, ok = cert["cert"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("证书错误:cert")
|
||||
}
|
||||
|
||||
// 更新证书中心
|
||||
reqPath := fmt.Sprintf("/product/sslcenter/%s", certId)
|
||||
resp, err := requestRainyunApi(reqPath, apiKey, http.MethodPut, cert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if gjson.Get(resp, "code").Int() != 200 {
|
||||
return errors.New(gjson.Get(resp, "message").String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func requestRainyunApi(path, apikey, method string, data interface{}) (string, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
reqBody, err := json.Marshal(data)
|
||||
if err != nil || data == nil {
|
||||
reqBody = nil
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, method, rainyunApi+path, bytes.NewBuffer(reqBody))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("build request: %w", err)
|
||||
}
|
||||
req.Header.Set("X-Api-Key", apikey)
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("http get error: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(io.LimitReader(resp.Body, 50*1024*1024))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("read body: %w", err)
|
||||
}
|
||||
|
||||
return string(body), nil
|
||||
}
|
||||
@@ -5,14 +5,21 @@ import (
|
||||
"ALLinSSL/backend/public/sqlite_migrate"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
_ "modernc.org/sqlite"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 指定运行目录为当前目录
|
||||
exePath, err := os.Executable()
|
||||
|
||||
// 如果为开发环境则使用工作目录
|
||||
if strings.Contains(exePath, "go-build") {
|
||||
exePath, _ = os.Getwd()
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "获取可执行文件路径失败: %v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -148,6 +155,8 @@ func init() {
|
||||
INSERT INTO access_type (name, type) VALUES ('1panel', 'host');`)
|
||||
|
||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "cloudflare", "type": "host"}, []string{"name", "type"}, []any{"cloudflare", "host"})
|
||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "rainyun", "type": "dns"}, []string{"name", "type"}, []any{"rainyun", "dns"})
|
||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "rainyun", "type": "host"}, []string{"name", "type"}, []any{"rainyun", "host"})
|
||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "cloudflare", "type": "dns"}, []string{"name", "type"}, []any{"cloudflare", "dns"})
|
||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "huaweicloud", "type": "host"}, []string{"name", "type"}, []any{"huaweicloud", "host"})
|
||||
InsertIfNotExists(db, "access_type", map[string]any{"name": "huaweicloud", "type": "dns"}, []string{"name", "type"}, []any{"huaweicloud", "dns"})
|
||||
|
||||
@@ -2,37 +2,37 @@ import { $t } from '@locales/index'
|
||||
|
||||
// 消息推送类型
|
||||
export interface MessagePushType {
|
||||
name: string
|
||||
type: string
|
||||
name: string
|
||||
type: string
|
||||
}
|
||||
|
||||
// 定义ApiProject接口,包含可选的notApi属性
|
||||
export interface ApiProjectType {
|
||||
name: string
|
||||
icon: string
|
||||
type?: string[]
|
||||
notApi?: boolean
|
||||
hostRelated?: Record<string, any>
|
||||
sort?: number
|
||||
name: string
|
||||
icon: string
|
||||
type?: string[]
|
||||
notApi?: boolean
|
||||
hostRelated?: Record<string, any>
|
||||
sort?: number
|
||||
}
|
||||
|
||||
// $t('t_0_1747886301644')
|
||||
export const MessagePushConfig = {
|
||||
mail: { name: $t('t_68_1745289354676'), type: 'mail' },
|
||||
workwx: { name: $t('t_33_1746773350932'), type: 'workwx' },
|
||||
dingtalk: { name: $t('t_32_1746773348993'), type: 'dingtalk' },
|
||||
feishu: { name: $t('t_34_1746773350153'), type: 'feishu' },
|
||||
webhook: { name: 'WebHook', type: 'webhook' },
|
||||
mail: { name: $t('t_68_1745289354676'), type: 'mail' },
|
||||
workwx: { name: $t('t_33_1746773350932'), type: 'workwx' },
|
||||
dingtalk: { name: $t('t_32_1746773348993'), type: 'dingtalk' },
|
||||
feishu: { name: $t('t_34_1746773350153'), type: 'feishu' },
|
||||
webhook: { name: 'WebHook', type: 'webhook' },
|
||||
}
|
||||
|
||||
// CA证书授权
|
||||
export const CACertificateAuthorization = {
|
||||
zerossl: { name: 'ZeroSSL', type: 'zerossl' },
|
||||
google: { name: 'Google', type: 'google' },
|
||||
sslcom: { name: 'SSL.COM', type: 'sslcom' },
|
||||
buypass: { name: 'Buypass', type: 'buypass' },
|
||||
letsencrypt: { name: "Let's Encrypt", type: 'letsencrypt' },
|
||||
custom: { name: '自定义', type: 'custom' },
|
||||
zerossl: { name: 'ZeroSSL', type: 'zerossl' },
|
||||
google: { name: 'Google', type: 'google' },
|
||||
sslcom: { name: 'SSL.COM', type: 'sslcom' },
|
||||
buypass: { name: 'Buypass', type: 'buypass' },
|
||||
letsencrypt: { name: "Let's Encrypt", type: 'letsencrypt' },
|
||||
custom: { name: '自定义', type: 'custom' },
|
||||
}
|
||||
|
||||
// 授权API管理
|
||||
@@ -278,6 +278,15 @@ export const ApiProjectConfig: Record<string, ApiProjectType> = {
|
||||
hostRelated: { default: { name: "BTDomain" } },
|
||||
sort: 33,
|
||||
},
|
||||
rainyun: {
|
||||
name: "雨云",
|
||||
icon: "rainyun",
|
||||
type: ["dns"],
|
||||
hostRelated: {
|
||||
sslcenter: { name: "证书中心" }
|
||||
},
|
||||
sort: 33,
|
||||
},
|
||||
plugin: {
|
||||
name: "插件",
|
||||
icon: "plugin",
|
||||
|
||||
@@ -62,8 +62,8 @@ import { testAccess, getPlugins } from "@/api/access";
|
||||
// import { useLocalStorage } from '@vueuse/core'
|
||||
|
||||
import ApiManageForm from "./components/ApiManageModel";
|
||||
import SvgIcon from "@components/SvgIcon";
|
||||
import TypeIcon from "@components/TypeIcon";
|
||||
import SvgIcon from "@/components/svgIcon";
|
||||
import TypeIcon from "@/components/typeIcon";
|
||||
import { noSideSpace } from "@lib/utils";
|
||||
import { JSX } from "vue/jsx-runtime";
|
||||
|
||||
@@ -1269,6 +1269,15 @@ export const useApiFormController = (
|
||||
})
|
||||
);
|
||||
break;
|
||||
case "rainyun":
|
||||
items.push(
|
||||
useFormInput("API Key", "config.api_key", {
|
||||
type: "password",
|
||||
showPasswordOn: "click",
|
||||
allowInput: noSideSpace,
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case "plugin":
|
||||
items.push(
|
||||
useFormCustom(() => {
|
||||
|
||||
@@ -143,6 +143,10 @@ export function createNodeFormConfig() {
|
||||
return [this.input($t('t_0_1747296173751'), 'siteName', { placeholder: $t('t_0_1748589752275') })]
|
||||
},
|
||||
|
||||
rainyunSSLCenterDeploy(){
|
||||
return [this.input("证书ID", 'cert_id', { placeholder:"雨云证书中心中显示的ID"})]
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建1Panel站点相关字段
|
||||
* @param valueRef 值引用
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NButton, NCard, NStep, NSteps, NText, NTooltip, NTabs, NTabPane, NInput
|
||||
import { useForm, useModalClose, useModalOptions, useMessage } from '@baota/naive-ui/hooks'
|
||||
import { useThemeCssVar } from '@baota/naive-ui/theme'
|
||||
import { useError } from '@baota/hooks/error'
|
||||
import { useStore } from '@components/FlowChart/useStore'
|
||||
import { useStore } from '@/components/flowChart/useStore'
|
||||
import { getSites, getPlugins } from '@api/access'
|
||||
|
||||
import { $t } from '@locales/index'
|
||||
@@ -18,12 +18,12 @@ import {
|
||||
filterDeployTypeOptions,
|
||||
} from '@workflowView/lib/DeployUtils'
|
||||
|
||||
import SvgIcon from '@components/SvgIcon'
|
||||
import DnsProviderSelect from '@components/DnsProviderSelect'
|
||||
import SvgIcon from '@/components/svgIcon'
|
||||
import DnsProviderSelect from '@/components/dnsProviderSelect'
|
||||
import SearchOutlined from '@vicons/antd/es/SearchOutlined'
|
||||
|
||||
import type { DeployNodeConfig, DeployNodeInputsConfig } from '@components/FlowChart/types'
|
||||
import type { DnsProviderType } from '@components/DnsProviderSelect/types'
|
||||
import type { DeployNodeConfig, DeployNodeInputsConfig } from '@/components/flowChart/types'
|
||||
import type { DnsProviderType } from '@/components/dnsProviderSelect/types'
|
||||
import type { VNode } from 'vue'
|
||||
|
||||
import styles from './index.module.css'
|
||||
@@ -234,6 +234,9 @@ export default defineComponent({
|
||||
case 'lecdn':
|
||||
config.push(...formConfig.leCdnDeploy())
|
||||
break
|
||||
case 'rainyun-sslcenter':
|
||||
config.push(...formConfig.rainyunSSLCenterDeploy())
|
||||
break
|
||||
case 'plugin':
|
||||
// 插件部署配置
|
||||
config.push(
|
||||
|
||||
3
go.mod
3
go.mod
@@ -119,6 +119,9 @@ require (
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/volcengine/volc-sdk-golang v1.0.216 // indirect
|
||||
|
||||
6
go.sum
6
go.sum
@@ -711,6 +711,12 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1210 h1:waS
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1210/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl v1.0.1124 h1:LQKAlxFb0sYiE8ojK5h9+seuFzogoJtYnXmiRF+4F4Q=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssl v1.0.1124/go.mod h1:tYbK0FbHVG+78od7eZpzczE8qk0JWKO/osTQWuiJ3Fo=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
|
||||
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
|
||||
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
|
||||
|
||||
Reference in New Issue
Block a user