mirror of
https://github.com/go-acme/lego.git
synced 2024-12-05 03:58:54 +02:00
commit
30a7a8e882
@ -26,6 +26,9 @@ var RecursiveNameservers = []string{
|
||||
"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
|
||||
func DNS01Record(domain, keyAuth string) (fqdn string, value string, ttl int) {
|
||||
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)
|
||||
for i := 1; i <= len(nameservers)+1; i++ {
|
||||
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 {
|
||||
tcp := &dns.Client{Net: "tcp"}
|
||||
tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout}
|
||||
// If the TCP request suceeds, the err will reset to nil
|
||||
in, _, err = tcp.Exchange(m, ns)
|
||||
}
|
||||
|
4
cli.go
4
cli.go
@ -150,6 +150,10 @@ func main() {
|
||||
Name: "http-timeout",
|
||||
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)
|
||||
|
@ -37,6 +37,10 @@ func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) {
|
||||
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"))
|
||||
if err != nil {
|
||||
logger().Fatalf("Could not check/create path: %s", err.Error())
|
||||
|
Loading…
Reference in New Issue
Block a user