From 2f47e9527a3327364e6ec99b5d9918f39045b2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 3 Dec 2020 21:07:12 +0800 Subject: [PATCH] =?UTF-8?q?[HTTPS]=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=8C=89=E9=92=AE=E7=94=B3=E8=AF=B7=E5=85=8D?= =?UTF-8?q?=E8=B4=B9=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/server_dao.go | 15 ++++++++ internal/rpc/services/service_server.go | 50 ++++++++++++++++--------- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/internal/db/models/server_dao.go b/internal/db/models/server_dao.go index dab9b758..475f503f 100644 --- a/internal/db/models/server_dao.go +++ b/internal/db/models/server_dao.go @@ -413,6 +413,21 @@ func (this *ServerDAO) InitServerWeb(serverId int64) (int64, error) { return webId, nil } +// 查找ServerNames配置 +func (this *ServerDAO) FindServerNames(serverId int64) (serverNamesJSON []byte, err error) { + col, err := this.Query(). + Pk(serverId). + Result("serverNames"). + FindStringCol("") + if err != nil { + return nil, err + } + if len(col) == 0 || col == "null" { + return []byte("[]"), nil + } + return []byte(col), nil +} + // 修改ServerNames配置 func (this *ServerDAO) UpdateServerNames(serverId int64, config []byte) error { if serverId <= 0 { diff --git a/internal/rpc/services/service_server.go b/internal/rpc/services/service_server.go index b531d51f..ade2a442 100644 --- a/internal/rpc/services/service_server.go +++ b/internal/rpc/services/service_server.go @@ -330,6 +330,20 @@ func (this *ServerService) UpdateServerReverseProxy(ctx context.Context, req *pb return this.Success() } +// 查找服务的域名设置 +func (this *ServerService) FindServerNames(ctx context.Context, req *pb.FindServerNamesRequest) (*pb.FindServerNamesResponse, error) { + _, err := this.ValidateAdmin(ctx, 0) + if err != nil { + return nil, err + } + + serverNamesJSON, err := models.SharedServerDAO.FindServerNames(req.ServerId) + if err != nil { + return nil, err + } + return &pb.FindServerNamesResponse{ServerNamesJSON: serverNamesJSON}, nil +} + // 修改域名服务 func (this *ServerService) UpdateServerNames(ctx context.Context, req *pb.UpdateServerNamesRequest) (*pb.RPCSuccess, error) { // 校验请求 @@ -417,23 +431,23 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb. } result = append(result, &pb.Server{ - Id: int64(server.Id), - IsOn: server.IsOn == 1, - Type: server.Type, - Config: []byte(server.Config), - Name: server.Name, - Description: server.Description, - HttpJSON: []byte(server.Http), - HttpsJSON: []byte(server.Https), - TcpJSON: []byte(server.Tcp), - TlsJSON: []byte(server.Tls), - UnixJSON: []byte(server.Unix), - UdpJSON: []byte(server.Udp), - IncludeNodes: []byte(server.IncludeNodes), - ExcludeNodes: []byte(server.ExcludeNodes), - ServerNamesJON: []byte(server.ServerNames), - CreatedAt: int64(server.CreatedAt), - DnsName: server.DnsName, + Id: int64(server.Id), + IsOn: server.IsOn == 1, + Type: server.Type, + Config: []byte(server.Config), + Name: server.Name, + Description: server.Description, + HttpJSON: []byte(server.Http), + HttpsJSON: []byte(server.Https), + TcpJSON: []byte(server.Tcp), + TlsJSON: []byte(server.Tls), + UnixJSON: []byte(server.Unix), + UdpJSON: []byte(server.Udp), + IncludeNodes: []byte(server.IncludeNodes), + ExcludeNodes: []byte(server.ExcludeNodes), + ServerNamesJSON: []byte(server.ServerNames), + CreatedAt: int64(server.CreatedAt), + DnsName: server.DnsName, Cluster: &pb.NodeCluster{ Id: int64(server.ClusterId), Name: clusterName, @@ -531,7 +545,7 @@ func (this *ServerService) FindEnabledServer(ctx context.Context, req *pb.FindEn Description: server.Description, DnsName: server.DnsName, Config: []byte(server.Config), - ServerNamesJON: []byte(server.ServerNames), + ServerNamesJSON: []byte(server.ServerNames), HttpJSON: []byte(server.Http), HttpsJSON: []byte(server.Https), TcpJSON: []byte(server.Tcp),