DNS支持TSIG

This commit is contained in:
刘祥超
2021-07-25 15:08:17 +08:00
parent 2c72d28c48
commit 5fffc8a833
6 changed files with 178 additions and 9 deletions

View File

@@ -125,3 +125,46 @@ func (this *NSKeyService) ListEnabledNSKeys(ctx context.Context, req *pb.ListEna
}
return &pb.ListEnabledNSKeysResponse{NsKeys: pbKeys}, nil
}
// ListNSKeysAfterVersion 根据版本列出一组密钥
func (this *NSKeyService) ListNSKeysAfterVersion(ctx context.Context, req *pb.ListNSKeysAfterVersionRequest) (*pb.ListNSKeysAfterVersionResponse, error) {
_, err := this.ValidateNSNode(ctx)
if err != nil {
return nil, err
}
var tx = this.NullTx()
if req.Size <= 0 {
req.Size = 2000
}
keys, err := nameservers.SharedNSKeyDAO.ListKeysAfterVersion(tx, req.Version, req.Size)
if err != nil {
return nil, err
}
var pbKeys = []*pb.NSKey{}
for _, key := range keys {
var pbDomain *pb.NSDomain
var pbZone *pb.NSZone
if key.DomainId > 0 {
pbDomain = &pb.NSDomain{Id: int64(key.DomainId)}
}
if key.ZoneId > 0 {
pbZone = &pb.NSZone{Id: int64(key.ZoneId)}
}
pbKeys = append(pbKeys, &pb.NSKey{
Id: int64(key.Id),
IsOn: key.IsOn == 1,
Name: "",
Algo: key.Algo,
Secret: key.Secret,
SecretType: key.SecretType,
IsDeleted: key.State == nameservers.NSKeyStateDisabled,
Version: int64(key.Version),
NsDomain: pbDomain,
NsZone: pbZone,
})
}
return &pb.ListNSKeysAfterVersionResponse{NsKeys: pbKeys}, nil
}