DNS节点可以自动升级

This commit is contained in:
GoEdgeLab
2021-07-22 18:42:57 +08:00
parent 90da95a285
commit 40a3a0f66d
15 changed files with 96 additions and 47 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/TeaOSLab/EdgeAPI/internal/db/models/authority"
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
plusutils "github.com/TeaOSLab/EdgePlus/pkg/utils"
)
// AuthorityKeyService 版本认证
@@ -44,6 +45,15 @@ func (this *AuthorityKeyService) ReadAuthorityKey(ctx context.Context, req *pb.R
return &pb.ReadAuthorityKeyResponse{AuthorityKey: nil}, nil
}
if len(key.Value) == 0 {
return &pb.ReadAuthorityKeyResponse{AuthorityKey: nil}, nil
}
m, err := plusutils.Decode([]byte(key.Value))
if err != nil {
return nil, err
}
macAddresses := []string{}
if len(key.MacAddresses) > 0 {
err = json.Unmarshal([]byte(key.MacAddresses), &macAddresses)
@@ -54,8 +64,8 @@ func (this *AuthorityKeyService) ReadAuthorityKey(ctx context.Context, req *pb.R
return &pb.ReadAuthorityKeyResponse{AuthorityKey: &pb.AuthorityKey{
Value: key.Value,
DayFrom: key.DayFrom,
DayTo: key.DayTo,
DayFrom: m.GetString("dayFrom"),
DayTo: m.GetString("dayTo"),
Hostname: key.Hostname,
MacAddresses: macAddresses,
Company: key.Company,