File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 66
77 "github.com/caddyserver/caddy/v2"
88 "github.com/caddyserver/certmagic"
9- "github.com/liujed/goutil/optionals"
109)
1110
1211type DNSConfig struct {
@@ -15,7 +14,11 @@ type DNSConfig struct {
1514 Provider certmagic.DNSProvider `json:"-"`
1615
1716 // The TTL to use for the DNS TXT records when answering challenges.
18- TTL optionals.Optional [caddy.Duration ] `json:"ttl"`
17+ //
18+ // XXX This should be an Optional[caddy.Duration], but Caddy's documentation
19+ // generator can handle neither generics nor types with custom JSON
20+ // representations.
21+ TTL * caddy.Duration `json:"ttl,omitempty"`
1922
2023 // Custom DNS resolvers to prefer over system/built-in defaults. Often
2124 // necessary to configure when using split-horizon DNS.
Original file line number Diff line number Diff line change @@ -209,9 +209,9 @@ func (h *Handler) handleDNSRequest(
209209 }
210210
211211 // Build the DNS record to create/delete.
212- ttl := time .Duration (h . DNS . TTL . GetOrDefault ( 0 ) )
213- if mode == hmCleanup {
214- ttl = 0
212+ ttl := time .Duration (0 )
213+ if mode != hmCleanup && h . DNS . TTL != nil {
214+ ttl = time . Duration ( * h . DNS . TTL )
215215 }
216216 records := []libdns.Record {
217217 libdns.TXT {
@@ -297,7 +297,8 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
297297 if err != nil {
298298 return err
299299 }
300- h .DNS .TTL = optionals .Some (caddy .Duration (parsedTTL ))
300+ caddyTTL := caddy .Duration (parsedTTL )
301+ h .DNS .TTL = & caddyTTL
301302
302303 case "resolvers" :
303304 h .DNS .Resolvers = d .RemainingArgs ()
You can’t perform that action at this time.
0 commit comments