gofmt -s ncdomain/convert.go

pull/46/head
JeremyRand 7 years ago
parent 1fb4007fa7
commit 26b4c4c637
No known key found for this signature in database
GPG Key ID: B3F2D165786D6570

@ -31,21 +31,21 @@ const defaultTTL = 600
// Therefore when qualifying names in a Value yourself you must check if the // Therefore when qualifying names in a Value yourself you must check if the
// input string is "=" and if so, replace it with "" first. // input string is "=" and if so, replace it with "" first.
type Value struct { type Value struct {
IP []net.IP IP []net.IP
IP6 []net.IP IP6 []net.IP
NS []string NS []string
Alias string Alias string
HasAlias bool // True if Alias was specified. Necessary as "" is a valid relative alias. HasAlias bool // True if Alias was specified. Necessary as "" is a valid relative alias.
Translate string Translate string
HasTranslate bool // True if Translate was specified. Necessary as "" is a valid relative value for Translate. HasTranslate bool // True if Translate was specified. Necessary as "" is a valid relative value for Translate.
DS []*dns.DS DS []*dns.DS
TXT [][]string TXT [][]string
SRV []*dns.SRV SRV []*dns.SRV
Hostmaster string // "hostmaster@example.com" Hostmaster string // "hostmaster@example.com"
MX []*dns.MX // header name is left blank MX []*dns.MX // header name is left blank
TLSA []*dns.TLSA TLSA []*dns.TLSA
TLSAGenerated []x509.Certificate // Certs can be dehydrated in the blockchain, they will be put here without SAN values. SAN must be filled in before use. TLSAGenerated []x509.Certificate // Certs can be dehydrated in the blockchain, they will be put here without SAN values. SAN must be filled in before use.
Map map[string]*Value // may contain and "*", will not contain "" Map map[string]*Value // may contain and "*", will not contain ""
// set if the value is at the top level (alas necessary for relname interpretation) // set if the value is at the top level (alas necessary for relname interpretation)
IsTopLevel bool IsTopLevel bool
@ -249,28 +249,26 @@ func (v *Value) appendSRVs(out []dns.RR, suffix, apexSuffix string) ([]dns.RR, e
return out, nil return out, nil
} }
func (v *Value) appendTLSA(out []dns.RR, suffix, apexSuffix string) ([]dns.RR, error) { func (v *Value) appendTLSA(out []dns.RR, suffix, apexSuffix string) ([]dns.RR, error) {
for _, tlsa := range v.TLSA { for _, tlsa := range v.TLSA {
out = append(out, tlsa) out = append(out, tlsa)
} }
for _, cert := range v.TLSAGenerated { for _, cert := range v.TLSAGenerated {
template := cert template := cert
_, nameNoPort := util.SplitDomainTail(suffix) _, nameNoPort := util.SplitDomainTail(suffix)
_, nameNoPortOrProtocol := util.SplitDomainTail(nameNoPort) _, nameNoPortOrProtocol := util.SplitDomainTail(nameNoPort)
derBytes, err := certdehydrate.FillRehydratedCertTemplate(template, nameNoPortOrProtocol) derBytes, err := certdehydrate.FillRehydratedCertTemplate(template, nameNoPortOrProtocol)
if err != nil { if err != nil {
// TODO: add debug output here // TODO: add debug output here
continue continue
} }
derBytesHex := hex.EncodeToString(derBytes) derBytesHex := hex.EncodeToString(derBytes)
out = append(out, &dns.TLSA{ out = append(out, &dns.TLSA{
Hdr: dns.RR_Header{Name: suffix, Rrtype: dns.TypeTLSA, Class: dns.ClassINET, Hdr: dns.RR_Header{Name: suffix, Rrtype: dns.TypeTLSA, Class: dns.ClassINET,
Ttl: defaultTTL}, Ttl: defaultTTL},
@ -279,9 +277,9 @@ func (v *Value) appendTLSA(out []dns.RR, suffix, apexSuffix string) ([]dns.RR, e
MatchingType: uint8(0), MatchingType: uint8(0),
Certificate: strings.ToUpper(derBytesHex), Certificate: strings.ToUpper(derBytesHex),
}) })
} }
return out, nil return out, nil
} }
@ -854,14 +852,14 @@ func parseTLSADehydrated(tlsa1dehydrated interface{}, v *Value) error {
if err != nil { if err != nil {
return fmt.Errorf("Error parsing dehydrated certificate: %s", err) return fmt.Errorf("Error parsing dehydrated certificate: %s", err)
} }
template, err := certdehydrate.RehydrateCert(dehydrated) template, err := certdehydrate.RehydrateCert(dehydrated)
if err != nil { if err != nil {
return fmt.Errorf("Error rehydrating certificate: %s", err) return fmt.Errorf("Error rehydrating certificate: %s", err)
} }
v.TLSAGenerated = append(v.TLSAGenerated, *template) v.TLSAGenerated = append(v.TLSAGenerated, *template)
return nil return nil
} }
@ -927,7 +925,7 @@ func parseTLSA(rv map[string]interface{}, v *Value, errFunc ErrorFunc) {
var tlsa1m map[string]interface{} var tlsa1m map[string]interface{}
if _, ok := tlsa1.([]interface{}); ok { if _, ok := tlsa1.([]interface{}); ok {
tlsa1m = map[string]interface{} { tlsa1m = map[string]interface{}{
"dane": tlsa1, "dane": tlsa1,
} }
} else { } else {

Loading…
Cancel
Save