DNS服务支持密钥管理

This commit is contained in:
GoEdgeLab
2021-07-25 09:43:47 +08:00
parent 31308b5b56
commit 11e6e128b0
6 changed files with 1485 additions and 3 deletions

View File

@@ -0,0 +1,69 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package dnsconfigs
type KeyAlgorithmType = string
const (
KeyAlgorithmTypeHmacSHA1 KeyAlgorithmType = "hmac-sha1."
KeyAlgorithmTypeHmacSHA224 KeyAlgorithmType = "hmac-sha224."
KeyAlgorithmTypeHmacSHA256 KeyAlgorithmType = "hmac-sha256."
KeyAlgorithmTypeHmacSHA384 KeyAlgorithmType = "hmac-sha384."
KeyAlgorithmTypeHmacSHA512 KeyAlgorithmType = "hmac-sha512."
)
type KeyAlgorithmDefinition struct {
Name string `json:"name"`
Code string `json:"code"`
}
func FindAllKeyAlgorithmTypes() []*KeyAlgorithmDefinition {
return []*KeyAlgorithmDefinition{
{
Name: "HmacSHA1",
Code: KeyAlgorithmTypeHmacSHA1,
},
{
Name: "HmacSHA224",
Code: KeyAlgorithmTypeHmacSHA224,
},
{
Name: "HmacSHA256",
Code: KeyAlgorithmTypeHmacSHA256,
},
{
Name: "HmacSHA384",
Code: KeyAlgorithmTypeHmacSHA384,
},
{
Name: "HmacSHA512",
Code: KeyAlgorithmTypeHmacSHA512,
},
}
}
func FindKeyAlgorithmTypeName(algoType KeyAlgorithmType) string {
for _, def := range FindAllKeyAlgorithmTypes() {
if def.Code == algoType {
return def.Name
}
}
return ""
}
type NSKeySecretType = string
const (
NSKeySecretTypeClear NSKeySecretType = "clear"
NSKeySecretTypeBase64 NSKeySecretType = "base64"
)
func FindKeySecretTypeName(secretType NSKeySecretType) string {
switch secretType {
case NSKeySecretTypeClear:
return "明文"
case NSKeySecretTypeBase64:
return "BASE64"
}
return ""
}

View File

@@ -5,9 +5,10 @@ package dnsconfigs
import "fmt"
type NSNodeConfig struct {
Id int64 `json:"id"`
ClusterId int64 `json:"clusterId"`
AccessLogRef *AccessLogRef `json:"accessLogRef"`
Id int64 `yaml:"id" json:"id"`
NodeId string `yaml:"nodeId" json:"nodeId"`
ClusterId int64 `yaml:"clusterId" json:"clusterId"`
AccessLogRef *AccessLogRef `yaml:"accessLogRef" json:"accessLogRef"`
paddedId string
}