mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-11 01:50:27 +08:00
优化代码
This commit is contained in:
@@ -320,18 +320,6 @@ func (this *RPCClient) IPListRPC() pb.IPListServiceClient {
|
|||||||
return pb.NewIPListServiceClient(this.pickConn())
|
return pb.NewIPListServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *RPCClient) ReportNodeRPC() pb.ReportNodeServiceClient {
|
|
||||||
return pb.NewReportNodeServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) ReportNodeGroupRPC() pb.ReportNodeGroupServiceClient {
|
|
||||||
return pb.NewReportNodeGroupServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) ReportResultRPC() pb.ReportResultServiceClient {
|
|
||||||
return pb.NewReportResultServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) IPItemRPC() pb.IPItemServiceClient {
|
func (this *RPCClient) IPItemRPC() pb.IPItemServiceClient {
|
||||||
return pb.NewIPItemServiceClient(this.pickConn())
|
return pb.NewIPItemServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
@@ -448,42 +436,6 @@ func (this *RPCClient) LatestItemRPC() pb.LatestItemServiceClient {
|
|||||||
return pb.NewLatestItemServiceClient(this.pickConn())
|
return pb.NewLatestItemServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *RPCClient) NSClusterRPC() pb.NSClusterServiceClient {
|
|
||||||
return pb.NewNSClusterServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSNodeRPC() pb.NSNodeServiceClient {
|
|
||||||
return pb.NewNSNodeServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSDomainRPC() pb.NSDomainServiceClient {
|
|
||||||
return pb.NewNSDomainServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSRecordRPC() pb.NSRecordServiceClient {
|
|
||||||
return pb.NewNSRecordServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSKeyRPC() pb.NSKeyServiceClient {
|
|
||||||
return pb.NewNSKeyServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSRouteRPC() pb.NSRouteServiceClient {
|
|
||||||
return pb.NewNSRouteServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSAccessLogRPC() pb.NSAccessLogServiceClient {
|
|
||||||
return pb.NewNSAccessLogServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSRPC() pb.NSServiceClient {
|
|
||||||
return pb.NewNSServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) NSQuestionOptionRPC() pb.NSQuestionOptionServiceClient {
|
|
||||||
return pb.NewNSQuestionOptionServiceClient(this.pickConn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *RPCClient) MetricItemRPC() pb.MetricItemServiceClient {
|
func (this *RPCClient) MetricItemRPC() pb.MetricItemServiceClient {
|
||||||
return pb.NewMetricItemServiceClient(this.pickConn())
|
return pb.NewMetricItemServiceClient(this.pickConn())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,19 +43,7 @@ func (this *CreatePopupAction) RunGet(params struct{}) {
|
|||||||
this.Data["paramCustomHTTPSecret"] = rands.HexString(32)
|
this.Data["paramCustomHTTPSecret"] = rands.HexString(32)
|
||||||
|
|
||||||
// EdgeDNS集群列表
|
// EdgeDNS集群列表
|
||||||
nsClustersResp, err := this.RPC().NSClusterRPC().FindAllEnabledNSClusters(this.AdminContext(), &pb.FindAllEnabledNSClustersRequest{})
|
this.Data["nsClusters"] = []maps.Map{}
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nsClusterMaps := []maps.Map{}
|
|
||||||
for _, nsCluster := range nsClustersResp.NsClusters {
|
|
||||||
nsClusterMaps = append(nsClusterMaps, maps.Map{
|
|
||||||
"id": nsCluster.Id,
|
|
||||||
"name": nsCluster.Name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.Data["nsClusters"] = nsClusterMaps
|
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
@@ -82,9 +70,6 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
ParamCloudFlareAPIKey string
|
ParamCloudFlareAPIKey string
|
||||||
ParamCloudFlareEmail string
|
ParamCloudFlareEmail string
|
||||||
|
|
||||||
// Local EdgeDNS
|
|
||||||
ParamLocalEdgeDNSClusterId int64
|
|
||||||
|
|
||||||
// CustomHTTP
|
// CustomHTTP
|
||||||
ParamCustomHTTPURL string
|
ParamCustomHTTPURL string
|
||||||
ParamCustomHTTPSecret string
|
ParamCustomHTTPSecret string
|
||||||
@@ -137,11 +122,6 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
Email("请输入正确格式的邮箱地址")
|
Email("请输入正确格式的邮箱地址")
|
||||||
apiParams["apiKey"] = params.ParamCloudFlareAPIKey
|
apiParams["apiKey"] = params.ParamCloudFlareAPIKey
|
||||||
apiParams["email"] = params.ParamCloudFlareEmail
|
apiParams["email"] = params.ParamCloudFlareEmail
|
||||||
case "localEdgeDNS":
|
|
||||||
params.Must.
|
|
||||||
Field("ParamLocalEdgeDNSClusterId", params.ParamLocalEdgeDNSClusterId).
|
|
||||||
Gt(0, "请选择域名服务集群")
|
|
||||||
apiParams["clusterId"] = params.ParamLocalEdgeDNSClusterId
|
|
||||||
case "customHTTP":
|
case "customHTTP":
|
||||||
params.Must.
|
params.Must.
|
||||||
Field("paramCustomHTTPURL", params.ParamCustomHTTPURL).
|
Field("paramCustomHTTPURL", params.ParamCustomHTTPURL).
|
||||||
|
|||||||
@@ -40,22 +40,11 @@ func (this *ProviderAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 本地EdgeDNS相关
|
// 本地EdgeDNS相关
|
||||||
var localEdgeDNSMap = maps.Map{}
|
localEdgeDNSMap, err := this.readEdgeDNS(provider, apiParams)
|
||||||
if provider.Type == "localEdgeDNS" {
|
|
||||||
nsClusterId := apiParams.GetInt64("clusterId")
|
|
||||||
nsClusterResp, err := this.RPC().NSClusterRPC().FindEnabledNSCluster(this.AdminContext(), &pb.FindEnabledNSClusterRequest{NsClusterId: nsClusterId})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nsCluster := nsClusterResp.NsCluster
|
|
||||||
if nsCluster != nil {
|
|
||||||
localEdgeDNSMap = maps.Map{
|
|
||||||
"id": nsCluster.Id,
|
|
||||||
"name": nsCluster.Name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Data["provider"] = maps.Map{
|
this.Data["provider"] = maps.Map{
|
||||||
"id": provider.Id,
|
"id": provider.Id,
|
||||||
|
|||||||
13
internal/web/actions/default/dns/providers/provider_ext.go
Normal file
13
internal/web/actions/default/dns/providers/provider_ext.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build !plus
|
||||||
|
|
||||||
|
package providers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (this *ProviderAction) readEdgeDNS(provider *pb.DNSProvider, apiParams maps.Map) (maps.Map, error) {
|
||||||
|
return maps.Map{}, nil
|
||||||
|
}
|
||||||
@@ -68,19 +68,7 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
|||||||
this.Data["types"] = typeMaps
|
this.Data["types"] = typeMaps
|
||||||
|
|
||||||
// EdgeDNS集群列表
|
// EdgeDNS集群列表
|
||||||
nsClustersResp, err := this.RPC().NSClusterRPC().FindAllEnabledNSClusters(this.AdminContext(), &pb.FindAllEnabledNSClustersRequest{})
|
this.Data["nsClusters"] = []maps.Map{}
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nsClusterMaps := []maps.Map{}
|
|
||||||
for _, nsCluster := range nsClustersResp.NsClusters {
|
|
||||||
nsClusterMaps = append(nsClusterMaps, maps.Map{
|
|
||||||
"id": nsCluster.Id,
|
|
||||||
"name": nsCluster.Name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.Data["nsClusters"] = nsClusterMaps
|
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
@@ -109,9 +97,6 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
ParamCloudFlareAPIKey string
|
ParamCloudFlareAPIKey string
|
||||||
ParamCloudFlareEmail string
|
ParamCloudFlareEmail string
|
||||||
|
|
||||||
// Local EdgeDNS
|
|
||||||
ParamLocalEdgeDNSClusterId int64
|
|
||||||
|
|
||||||
// CustomHTTP
|
// CustomHTTP
|
||||||
ParamCustomHTTPURL string
|
ParamCustomHTTPURL string
|
||||||
ParamCustomHTTPSecret string
|
ParamCustomHTTPSecret string
|
||||||
@@ -166,11 +151,6 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
Email("请输入正确格式的邮箱地址")
|
Email("请输入正确格式的邮箱地址")
|
||||||
apiParams["apiKey"] = params.ParamCloudFlareAPIKey
|
apiParams["apiKey"] = params.ParamCloudFlareAPIKey
|
||||||
apiParams["email"] = params.ParamCloudFlareEmail
|
apiParams["email"] = params.ParamCloudFlareEmail
|
||||||
case "localEdgeDNS":
|
|
||||||
params.Must.
|
|
||||||
Field("ParamLocalEdgeDNSClusterId", params.ParamLocalEdgeDNSClusterId).
|
|
||||||
Gt(0, "请选择域名服务集群")
|
|
||||||
apiParams["clusterId"] = params.ParamLocalEdgeDNSClusterId
|
|
||||||
case "customHTTP":
|
case "customHTTP":
|
||||||
params.Must.
|
params.Must.
|
||||||
Field("paramCustomHTTPURL", params.ParamCustomHTTPURL).
|
Field("paramCustomHTTPURL", params.ParamCustomHTTPURL).
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package certs
|
package certs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
@@ -37,29 +36,11 @@ func (this *DeleteAction) RunPost(params struct {
|
|||||||
this.Fail("此证书正在被某些API节点引用,请先修改API节点后再删除")
|
this.Fail("此证书正在被某些API节点引用,请先修改API节点后再删除")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否正在被用户节点使用
|
err = this.filterDelete(params.CertId)
|
||||||
if teaconst.IsPlus {
|
|
||||||
countResp, err = this.RPC().UserNodeRPC().CountAllEnabledUserNodesWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledUserNodesWithSSLCertIdRequest{SslCertId: params.CertId})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if countResp.Count > 0 {
|
|
||||||
this.Fail("此证书正在被某些用户节点引用,请先修改相关用户节点后再删除")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否正在被NS集群使用
|
|
||||||
if teaconst.IsPlus {
|
|
||||||
countResp, err = this.RPC().NSClusterRPC().CountAllNSClustersWithSSLCertId(this.AdminContext(), &pb.CountAllNSClustersWithSSLCertIdRequest{SslCertId: params.CertId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if countResp.Count > 0 {
|
|
||||||
this.Fail("此证书正在被某些DNS集群节点引用,请先修改相关DNS集群设置后再删除")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = this.RPC().SSLCertRPC().DeleteSSLCert(this.AdminContext(), &pb.DeleteSSLCertRequest{SslCertId: params.CertId})
|
_, err = this.RPC().SSLCertRPC().DeleteSSLCert(this.AdminContext(), &pb.DeleteSSLCertRequest{SslCertId: params.CertId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
8
internal/web/actions/default/servers/certs/delete_ext.go
Normal file
8
internal/web/actions/default/servers/certs/delete_ext.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build !plus
|
||||||
|
|
||||||
|
package certs
|
||||||
|
|
||||||
|
func (this *DeleteAction) filterDelete(certId int64) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user