mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Let's Encrypt Certificate Generation (#327)
* Manual rebase of get-certs branch * fix endpoints, add verbose flag * more stable pre-check behaviour * start of docs * docs for get-certs * don't require cert for dnscontrol * fix up directory paths * small doc tweaks
This commit is contained in:
@@ -2,6 +2,7 @@ package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DefaultTTL is applied to any DNS record without an explicit TTL.
|
||||
@@ -45,6 +46,10 @@ type Nameserver struct {
|
||||
Name string `json:"name"` // Normalized to a FQDN with NO trailing "."
|
||||
}
|
||||
|
||||
func (n *Nameserver) String() string {
|
||||
return n.Name
|
||||
}
|
||||
|
||||
// StringsToNameservers constructs a list of *Nameserver structs using a list of FQDNs.
|
||||
func StringsToNameservers(nss []string) []*Nameserver {
|
||||
nservers := []*Nameserver{}
|
||||
@@ -59,3 +64,18 @@ type Correction struct {
|
||||
F func() error `json:"-"`
|
||||
Msg string
|
||||
}
|
||||
|
||||
// DomainContainingFQDN finds the best domain from the dns config for the given record fqdn.
|
||||
// It will chose the domain whose name is the longest suffix match for the fqdn.
|
||||
func (config *DNSConfig) DomainContainingFQDN(fqdn string) *DomainConfig {
|
||||
fqdn = strings.TrimSuffix(fqdn, ".")
|
||||
longestLength := 0
|
||||
var d *DomainConfig
|
||||
for _, dom := range config.Domains {
|
||||
if (dom.Name == fqdn || strings.HasSuffix(fqdn, "."+dom.Name)) && len(dom.Name) > longestLength {
|
||||
longestLength = len(dom.Name)
|
||||
d = dom
|
||||
}
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
Reference in New Issue
Block a user