forked from TrueCloudLab/lego
Add dns-timeout support.
This commit is contained in:
parent
b119bc45fb
commit
88932f9167
3 changed files with 14 additions and 2 deletions
|
@ -26,6 +26,9 @@ var RecursiveNameservers = []string{
|
||||||
"google-public-dns-b.google.com:53",
|
"google-public-dns-b.google.com:53",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DNSTimeout is used to override the default DNS timeout of 10 seconds.
|
||||||
|
var DNSTimeout = 10 * time.Second
|
||||||
|
|
||||||
// DNS01Record returns a DNS record which will fulfill the `dns-01` challenge
|
// DNS01Record returns a DNS record which will fulfill the `dns-01` challenge
|
||||||
func DNS01Record(domain, keyAuth string) (fqdn string, value string, ttl int) {
|
func DNS01Record(domain, keyAuth string) (fqdn string, value string, ttl int) {
|
||||||
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
|
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
|
||||||
|
@ -161,10 +164,11 @@ func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (
|
||||||
// Will retry the request based on the number of servers (n+1)
|
// Will retry the request based on the number of servers (n+1)
|
||||||
for i := 1; i <= len(nameservers)+1; i++ {
|
for i := 1; i <= len(nameservers)+1; i++ {
|
||||||
ns := nameservers[i%len(nameservers)]
|
ns := nameservers[i%len(nameservers)]
|
||||||
in, err = dns.Exchange(m, ns)
|
udp := &dns.Client{Net: "udp", Timeout: DNSTimeout}
|
||||||
|
in, _, err = udp.Exchange(m, ns)
|
||||||
|
|
||||||
if err == dns.ErrTruncated {
|
if err == dns.ErrTruncated {
|
||||||
tcp := &dns.Client{Net: "tcp"}
|
tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout}
|
||||||
// If the TCP request suceeds, the err will reset to nil
|
// If the TCP request suceeds, the err will reset to nil
|
||||||
in, _, err = tcp.Exchange(m, ns)
|
in, _, err = tcp.Exchange(m, ns)
|
||||||
}
|
}
|
||||||
|
|
4
cli.go
4
cli.go
|
@ -150,6 +150,10 @@ func main() {
|
||||||
Name: "http-timeout",
|
Name: "http-timeout",
|
||||||
Usage: "Set the HTTP timeout value to a specific value in seconds. The default is 10 seconds.",
|
Usage: "Set the HTTP timeout value to a specific value in seconds. The default is 10 seconds.",
|
||||||
},
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "dns-timeout",
|
||||||
|
Usage: "Set the DNS timeout value to a specific value in seconds. The default is 10 seconds.",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.Run(os.Args)
|
err = app.Run(os.Args)
|
||||||
|
|
|
@ -37,6 +37,10 @@ func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) {
|
||||||
acme.HTTPTimeout = time.Duration(c.GlobalInt("http-timeout")) * time.Second
|
acme.HTTPTimeout = time.Duration(c.GlobalInt("http-timeout")) * time.Second
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.GlobalIsSet("dns-timeout") {
|
||||||
|
acme.DNSTimeout = time.Duration(c.GlobalInt("dns-timeout")) * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
err := checkFolder(c.GlobalString("path"))
|
err := checkFolder(c.GlobalString("path"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger().Fatalf("Could not check/create path: %s", err.Error())
|
logger().Fatalf("Could not check/create path: %s", err.Error())
|
||||||
|
|
Loading…
Reference in a new issue