From 339d6732d7ab763bc632ae0b7407c76cdcd0dbbb Mon Sep 17 00:00:00 2001
From: CityFun <31820853+zhengkunwang223@users.noreply.github.com>
Date: Fri, 29 Aug 2025 13:54:16 +0800
Subject: [PATCH] fix: fixed issue with push ssl to node failed (#10188)
---
agent/app/dto/request/website_ssl.go | 42 ++++++++-------
agent/app/service/website_ssl.go | 53 ++++++++-----------
frontend/src/api/interface/website.ts | 2 +
.../src/views/website/ssl/create/index.vue | 22 ++++++--
frontend/src/views/website/ssl/index.vue | 6 ++-
5 files changed, 68 insertions(+), 57 deletions(-)
diff --git a/agent/app/dto/request/website_ssl.go b/agent/app/dto/request/website_ssl.go
index a08b5ea9c..a67c2d9f5 100644
--- a/agent/app/dto/request/website_ssl.go
+++ b/agent/app/dto/request/website_ssl.go
@@ -9,26 +9,26 @@ type WebsiteSSLSearch struct {
}
type WebsiteSSLCreate struct {
- PrimaryDomain string `json:"primaryDomain" validate:"required"`
- OtherDomains string `json:"otherDomains"`
- Provider string `json:"provider" validate:"required"`
- AcmeAccountID uint `json:"acmeAccountId" validate:"required"`
- DnsAccountID uint `json:"dnsAccountId"`
- AutoRenew bool `json:"autoRenew"`
- KeyType string `json:"keyType"`
- Apply bool `json:"apply"`
- PushDir bool `json:"pushDir"`
- Dir string `json:"dir"`
- ID uint `json:"id"`
- Description string `json:"description"`
- DisableCNAME bool `json:"disableCNAME"`
- SkipDNS bool `json:"skipDNS"`
- Nameserver1 string `json:"nameserver1"`
- Nameserver2 string `json:"nameserver2"`
- ExecShell bool `json:"execShell"`
- Shell string `json:"shell"`
- PushNode bool `json:"pushNode"`
- Nodes []string `json:"nodes"`
+ PrimaryDomain string `json:"primaryDomain" validate:"required"`
+ OtherDomains string `json:"otherDomains"`
+ Provider string `json:"provider" validate:"required"`
+ AcmeAccountID uint `json:"acmeAccountId" validate:"required"`
+ DnsAccountID uint `json:"dnsAccountId"`
+ AutoRenew bool `json:"autoRenew"`
+ KeyType string `json:"keyType"`
+ Apply bool `json:"apply"`
+ PushDir bool `json:"pushDir"`
+ Dir string `json:"dir"`
+ ID uint `json:"id"`
+ Description string `json:"description"`
+ DisableCNAME bool `json:"disableCNAME"`
+ SkipDNS bool `json:"skipDNS"`
+ Nameserver1 string `json:"nameserver1"`
+ Nameserver2 string `json:"nameserver2"`
+ ExecShell bool `json:"execShell"`
+ Shell string `json:"shell"`
+ PushNode bool `json:"pushNode"`
+ Nodes string `json:"nodes"`
}
type WebsiteDNSReq struct {
@@ -107,6 +107,8 @@ type WebsiteSSLUpdate struct {
Nameserver2 string `json:"nameserver2"`
ExecShell bool `json:"execShell"`
Shell string `json:"shell"`
+ PushNode bool `json:"pushNode"`
+ Nodes string `json:"nodes"`
}
type WebsiteSSLUpload struct {
diff --git a/agent/app/service/website_ssl.go b/agent/app/service/website_ssl.go
index 4bfee04ea..70227d686 100644
--- a/agent/app/service/website_ssl.go
+++ b/agent/app/service/website_ssl.go
@@ -150,7 +150,7 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs
}
if create.PushNode && global.IsMaster && len(create.Nodes) > 0 {
websiteSSL.PushNode = true
- websiteSSL.Nodes = strings.Join(create.Nodes, ",")
+ websiteSSL.Nodes = create.Nodes
}
var domains []string
@@ -539,6 +539,13 @@ func (w WebsiteSSLService) Update(update request.WebsiteSSLUpdate) error {
} else {
updateParams["shell"] = ""
}
+ if update.PushNode {
+ updateParams["push_node"] = true
+ updateParams["nodes"] = update.Nodes
+ } else {
+ updateParams["push_node"] = false
+ updateParams["nodes"] = ""
+ }
if websiteSSL.Provider != constant.SelfSigned && websiteSSL.Provider != constant.Manual {
acmeAccount, err := websiteAcmeRepo.GetFirst(repo.WithByID(update.AcmeAccountID))
@@ -729,37 +736,19 @@ func (w WebsiteSSLService) SyncForRestart() error {
func (w WebsiteSSLService) ImportMasterSSL(create model.WebsiteSSL) error {
websiteSSL, _ := websiteSSLRepo.GetFirst(websiteSSLRepo.WithByMasterSSLID(create.ID))
- if websiteSSL == nil {
- websiteSSL = &model.WebsiteSSL{
- Status: constant.SSLReady,
- Provider: constant.FromMaster,
- PrimaryDomain: create.PrimaryDomain,
- StartDate: create.StartDate,
- ExpireDate: create.ExpireDate,
- KeyType: create.KeyType,
- Description: create.Description,
- MasterSSLID: create.ID,
- PrivateKey: create.PrivateKey,
- Pem: create.Pem,
- Type: create.Type,
- Organization: create.Organization,
- }
- if err := websiteSSLRepo.Create(context.TODO(), websiteSSL); err != nil {
- return err
- }
- } else {
- websiteSSL.PrimaryDomain = create.PrimaryDomain
- websiteSSL.StartDate = create.StartDate
- websiteSSL.ExpireDate = create.ExpireDate
- websiteSSL.KeyType = create.KeyType
- websiteSSL.Description = create.Description
- websiteSSL.PrivateKey = create.PrivateKey
- websiteSSL.Pem = create.Pem
- websiteSSL.Type = create.Type
- websiteSSL.Organization = create.Organization
- if err := websiteSSLRepo.Save(websiteSSL); err != nil {
- return err
- }
+ websiteSSL.Status = constant.SSLReady
+ websiteSSL.Provider = constant.FromMaster
+ websiteSSL.PrimaryDomain = create.PrimaryDomain
+ websiteSSL.StartDate = create.StartDate
+ websiteSSL.ExpireDate = create.ExpireDate
+ websiteSSL.KeyType = create.KeyType
+ websiteSSL.Description = create.Description
+ websiteSSL.PrivateKey = create.PrivateKey
+ websiteSSL.Pem = create.Pem
+ websiteSSL.Type = create.Type
+ websiteSSL.Organization = create.Organization
+ if err := websiteSSLRepo.Save(websiteSSL); err != nil {
+ return err
}
websites, _ := websiteRepo.GetBy(websiteRepo.WithWebsiteSSLID(websiteSSL.ID))
if len(websites) == 0 {
diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts
index 359a8acf1..7adb030fa 100644
--- a/frontend/src/api/interface/website.ts
+++ b/frontend/src/api/interface/website.ts
@@ -225,6 +225,8 @@ export namespace Website {
skipDNS: boolean;
execShell: boolean;
shell: string;
+ pushNode: boolean;
+ nodes: string;
}
export interface SSLDTO extends SSL {
diff --git a/frontend/src/views/website/ssl/create/index.vue b/frontend/src/views/website/ssl/create/index.vue
index 4f8dd96db..eaa7193cc 100644
--- a/frontend/src/views/website/ssl/create/index.vue
+++ b/frontend/src/views/website/ssl/create/index.vue
@@ -144,9 +144,9 @@
@@ -224,7 +224,7 @@ const rules = ref({
nameserver2: [Rules.ipv4],
shell: [Rules.requiredInput],
description: [checkMaxLength(128)],
- nodes: [Rules.requiredSelect],
+ pushNodes: [Rules.requiredSelect],
});
const websiteID = ref();
@@ -248,7 +248,8 @@ const initData = () => ({
execShell: false,
shell: '',
pushNode: false,
- nodes: [],
+ pushNodes: [],
+ nodes: '',
});
const ssl = ref(initData());
@@ -296,6 +297,13 @@ const acceptParams = (op: string, websiteSSL: Website.SSLDTO) => {
if (ssl.value.provider == 'selfSigned') {
rules.value.primaryDomain = [];
}
+ ssl.value.pushNode = websiteSSL.pushNode;
+ if (websiteSSL.nodes != '') {
+ ssl.value.pushNodes = websiteSSL.nodes
+ .split(',')
+ .map((item) => item.trim())
+ .filter((item) => item !== '');
+ }
}
ssl.value.websiteId = Number(id.value);
getAcmeAccounts();
@@ -356,6 +364,10 @@ const submit = async (formEl: FormInstance | undefined) => {
if (!valid) {
return;
}
+ let nodes = '';
+ if (ssl.value.pushNode) {
+ nodes = ssl.value.pushNodes.join(',');
+ }
loading.value = true;
if (operate.value == 'create') {
createSSL(ssl.value)
@@ -389,6 +401,8 @@ const submit = async (formEl: FormInstance | undefined) => {
nameserver2: ssl.value.nameserver2,
execShell: ssl.value.execShell,
shell: ssl.value.shell,
+ pushNode: ssl.value.pushNode,
+ nodes: nodes,
};
updateSSL(sslUpdate)
.then(() => {
diff --git a/frontend/src/views/website/ssl/index.vue b/frontend/src/views/website/ssl/index.vue
index fdc804e0d..4cdcaf9b9 100644
--- a/frontend/src/views/website/ssl/index.vue
+++ b/frontend/src/views/website/ssl/index.vue
@@ -128,7 +128,11 @@