HTTP timeouts to API, and self-validation mutex to nameserver ops
This commit is contained in:
parent
b7d9f44765
commit
22c41911ce
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/joohoi/acme-dns/pkg/acmedns"
|
"github.com/joohoi/acme-dns/pkg/acmedns"
|
||||||
|
|
||||||
@ -71,6 +72,9 @@ func (a *AcmednsAPI) Start(dnsservers []acmedns.AcmednsNS) {
|
|||||||
Handler: c.Handler(api),
|
Handler: c.Handler(api),
|
||||||
TLSConfig: cfg,
|
TLSConfig: cfg,
|
||||||
ErrorLog: stderrorlog,
|
ErrorLog: stderrorlog,
|
||||||
|
ReadTimeout: 5 * time.Second,
|
||||||
|
WriteTimeout: 10 * time.Second,
|
||||||
|
IdleTimeout: 120 * time.Second,
|
||||||
}
|
}
|
||||||
a.Logger.Infow("Listening HTTPS",
|
a.Logger.Infow("Listening HTTPS",
|
||||||
"host", host,
|
"host", host,
|
||||||
@ -82,6 +86,9 @@ func (a *AcmednsAPI) Start(dnsservers []acmedns.AcmednsNS) {
|
|||||||
Handler: c.Handler(api),
|
Handler: c.Handler(api),
|
||||||
TLSConfig: cfg,
|
TLSConfig: cfg,
|
||||||
ErrorLog: stderrorlog,
|
ErrorLog: stderrorlog,
|
||||||
|
ReadTimeout: 5 * time.Second,
|
||||||
|
WriteTimeout: 10 * time.Second,
|
||||||
|
IdleTimeout: 120 * time.Second,
|
||||||
}
|
}
|
||||||
a.Logger.Infow("Listening HTTPS",
|
a.Logger.Infow("Listening HTTPS",
|
||||||
"host", host,
|
"host", host,
|
||||||
|
|||||||
@ -24,6 +24,7 @@ type Nameserver struct {
|
|||||||
OwnDomain string
|
OwnDomain string
|
||||||
NotifyStartedFunc func()
|
NotifyStartedFunc func()
|
||||||
SOA dns.RR
|
SOA dns.RR
|
||||||
|
mu sync.RWMutex
|
||||||
personalAuthKey string
|
personalAuthKey string
|
||||||
Domains map[string]Records
|
Domains map[string]Records
|
||||||
errChan chan error
|
errChan chan error
|
||||||
|
|||||||
@ -4,11 +4,15 @@ import "github.com/miekg/dns"
|
|||||||
|
|
||||||
// SetOwnAuthKey sets the ACME challenge token for completing dns validation for acme-dns server itself
|
// SetOwnAuthKey sets the ACME challenge token for completing dns validation for acme-dns server itself
|
||||||
func (n *Nameserver) SetOwnAuthKey(key string) {
|
func (n *Nameserver) SetOwnAuthKey(key string) {
|
||||||
|
n.mu.Lock()
|
||||||
|
defer n.mu.Unlock()
|
||||||
n.personalAuthKey = key
|
n.personalAuthKey = key
|
||||||
}
|
}
|
||||||
|
|
||||||
// answerOwnChallenge answers to ACME challenge for acme-dns own certificate
|
// answerOwnChallenge answers to ACME challenge for acme-dns own certificate
|
||||||
func (n *Nameserver) answerOwnChallenge(q dns.Question) ([]dns.RR, error) {
|
func (n *Nameserver) answerOwnChallenge(q dns.Question) ([]dns.RR, error) {
|
||||||
|
n.mu.RLock()
|
||||||
|
defer n.mu.RUnlock()
|
||||||
r := new(dns.TXT)
|
r := new(dns.TXT)
|
||||||
r.Hdr = dns.RR_Header{Name: q.Name, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 1}
|
r.Hdr = dns.RR_Header{Name: q.Name, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 1}
|
||||||
r.Txt = append(r.Txt, n.personalAuthKey)
|
r.Txt = append(r.Txt, n.personalAuthKey)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user