mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-24 17:58:56 +08:00
fix: fixed issue with push ssl to node failed (#10188)
This commit is contained in:
parent
b0dbfb4c7c
commit
339d6732d7
5 changed files with 68 additions and 57 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -225,6 +225,8 @@ export namespace Website {
|
|||
skipDNS: boolean;
|
||||
execShell: boolean;
|
||||
shell: string;
|
||||
pushNode: boolean;
|
||||
nodes: string;
|
||||
}
|
||||
|
||||
export interface SSLDTO extends SSL {
|
||||
|
|
|
|||
|
|
@ -144,9 +144,9 @@
|
|||
<PushtoNode
|
||||
v-if="isMaster && isMasterProductPro"
|
||||
:push-node="ssl.pushNode"
|
||||
:nodes="ssl.nodes"
|
||||
:nodes="ssl.pushNodes"
|
||||
@update:push-node="ssl.pushNode = $event"
|
||||
@update:nodes="ssl.nodes = $event"
|
||||
@update:nodes="ssl.pushNodes = $event"
|
||||
/>
|
||||
</div>
|
||||
</el-form>
|
||||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,11 @@
|
|||
<el-table-column :label="$t('ssl.autoRenew')" width="100px">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
:disabled="row.provider === 'dnsManual' || row.provider === 'manual'"
|
||||
:disabled="
|
||||
row.provider === 'dnsManual' ||
|
||||
row.provider === 'manual' ||
|
||||
row.provider === 'fromMaster'
|
||||
"
|
||||
v-model="row.autoRenew"
|
||||
@change="updateConfig(row)"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue