v3.4.0 593c1c3

dns_config.go RawHistoryFolder

1package publictls
2
3import (
4	"fmt"
5	"net"
6	"strconv"
7	"strings"
8	"time"
9
10	"github.com/bnema/gordon/internal/domain"
11)
12
13const (
14	DefaultDNSPropagationTimeout = 5 * time.Minute
15	DefaultDNSPollingInterval    = 5 * time.Second
16)
17
18var DefaultDNSResolvers = []string{"1.1.1.1:53", "8.8.8.8:53"}
19
20// DNSConfig controls public DNS visibility checks used by ACME DNS-01.
21// These are recursive resolvers, not authoritative DNS providers.
22type DNSConfig struct {
23	Resolvers          []string
24	PropagationTimeout time.Duration
25	PollingInterval    time.Duration
26}
27
28// DefaultDNSConfig returns Gordon's default public DNS check configuration.
29func DefaultDNSConfig() DNSConfig {
30	resolvers := append([]string(nil), DefaultDNSResolvers...)
31	return DNSConfig{
32		Resolvers:          resolvers,
33		PropagationTimeout: DefaultDNSPropagationTimeout,
34		PollingInterval:    DefaultDNSPollingInterval,
35	}
36}
37
38// Validate checks DNSConfig for ACME DNS-01 usage and normalizes resolver whitespace.
39func (c *DNSConfig) Validate() error {
40	if len(c.Resolvers) == 0 {
41		return fmt.Errorf("%w: dns.resolvers must contain at least one resolver", domain.ErrDNSConfigInvalid)
42	}
43	for i, resolver := range c.Resolvers {
44		trimmed := strings.TrimSpace(resolver)
45		if trimmed == "" {
46			return fmt.Errorf("%w: invalid dns.resolvers[%d]: empty resolver", domain.ErrDNSConfigInvalid, i)
47		}
48		host, port, err := net.SplitHostPort(trimmed)
49		if err != nil {
50			return fmt.Errorf("%w: invalid dns.resolvers[%d]: %q: expected host:port: %v", domain.ErrDNSConfigInvalid, i, trimmed, err)
51		}
52		if host == "" {
53			return fmt.Errorf("%w: invalid dns.resolvers[%d]: %q: host must not be empty", domain.ErrDNSConfigInvalid, i, trimmed)
54		}
55		portNumber, err := strconv.Atoi(port)
56		if err != nil || portNumber < 1 || portNumber > 65535 {
57			return fmt.Errorf("%w: invalid dns.resolvers[%d]: %q: port must be a number between 1 and 65535", domain.ErrDNSConfigInvalid, i, trimmed)
58		}
59		c.Resolvers[i] = trimmed
60	}
61	if c.PropagationTimeout <= 0 {
62		return fmt.Errorf("%w: dns.propagation_timeout must be positive", domain.ErrDNSConfigInvalid)
63	}
64	if c.PollingInterval <= 0 {
65		return fmt.Errorf("%w: dns.polling_interval must be positive", domain.ErrDNSConfigInvalid)
66	}
67	if c.PollingInterval >= c.PropagationTimeout {
68		return fmt.Errorf("%w: dns.polling_interval must be less than dns.propagation_timeout", domain.ErrDNSConfigInvalid)
69	}
70	return nil
71}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close