From b86453408c79826e617e462359c551e9295fa0ec Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 6 Jul 2021 15:31:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96API=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/web/actions/default/api/node/index.go | 11 +++++++---- internal/web/actions/default/api/node/update.go | 2 +- web/views/@default/api/node/index.html | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/web/actions/default/api/node/index.go b/internal/web/actions/default/api/node/index.go index e2b8ed43..be8e463a 100644 --- a/internal/web/actions/default/api/node/index.go +++ b/internal/web/actions/default/api/node/index.go @@ -32,6 +32,7 @@ func (this *IndexAction) RunGet(params struct { } // 监听地址 + var hasHTTPS = false httpConfig := &serverconfigs.HTTPProtocolConfig{} if len(node.HttpJSON) > 0 { err = json.Unmarshal(node.HttpJSON, httpConfig) @@ -47,6 +48,7 @@ func (this *IndexAction) RunGet(params struct { this.ErrorPage(err) return } + hasHTTPS = len(httpsConfig.Listen) > 0 } // 监听地址 @@ -56,7 +58,6 @@ func (this *IndexAction) RunGet(params struct { // 证书信息 certs := []*sslconfigs.SSLCertConfig{} - sslPolicyId := int64(0) if httpsConfig.SSLPolicyRef != nil && httpsConfig.SSLPolicyRef.SSLPolicyId > 0 { sslPolicyConfigResp, err := this.RPC().SSLPolicyRPC().FindEnabledSSLPolicyConfig(this.AdminContext(), &pb.FindEnabledSSLPolicyConfigRequest{SslPolicyId: httpsConfig.SSLPolicyRef.SSLPolicyId}) if err != nil { @@ -65,8 +66,6 @@ func (this *IndexAction) RunGet(params struct { } sslPolicyConfigJSON := sslPolicyConfigResp.SslPolicyJSON if len(sslPolicyConfigJSON) > 0 { - sslPolicyId = httpsConfig.SSLPolicyRef.SSLPolicyId - sslPolicy := &sslconfigs.SSLPolicy{} err = json.Unmarshal(sslPolicyConfigJSON, sslPolicy) if err != nil { @@ -112,6 +111,10 @@ func (this *IndexAction) RunGet(params struct { if httpsConfig.IsOn && len(httpsConfig.Listen) > 0 { restAccessAddrs = append(restAccessAddrs, httpsConfig.Listen...) } + + if !hasHTTPS { + hasHTTPS = len(httpsConfig.Listen) > 0 + } } } @@ -124,7 +127,7 @@ func (this *IndexAction) RunGet(params struct { "accessAddrs": accessAddrs, "restIsOn": node.RestIsOn, "restAccessAddrs": restAccessAddrs, - "hasHTTPS": sslPolicyId > 0, + "hasHTTPS": hasHTTPS, "certs": certs, } diff --git a/internal/web/actions/default/api/node/update.go b/internal/web/actions/default/api/node/update.go index bcd458a9..bc71b4e6 100644 --- a/internal/web/actions/default/api/node/update.go +++ b/internal/web/actions/default/api/node/update.go @@ -127,7 +127,7 @@ func (this *UpdateAction) RunGet(params struct { this.Show() } -// 保存基础设置 +// RunPost 保存基础设置 func (this *UpdateAction) RunPost(params struct { NodeId int64 Name string diff --git a/web/views/@default/api/node/index.html b/web/views/@default/api/node/index.html index 9886a00c..3cd494b3 100644 --- a/web/views/@default/api/node/index.html +++ b/web/views/@default/api/node/index.html @@ -24,7 +24,10 @@ HTTPS证书 - +
+ +
+ 还没有设置证书,可能会导致HTTPS相关服务不可用。