-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_test.go
More file actions
32 lines (28 loc) · 871 Bytes
/
Copy pathexport_test.go
File metadata and controls
32 lines (28 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package acidns
import (
"time"
"github.com/lestrrat-go/acidns/resolvconf"
)
// RateLimitDebugLen returns the number of buckets the rate-limiter is
// currently tracking across all shards. Test-only.
func RateLimitDebugLen(h Handler) int {
l, ok := h.(*limiter)
if !ok {
return -1
}
return l.pool.Len()
}
// SystemResolverConfigFromFile loads path via resolvconf, then runs
// the same option-application pipeline as [WithSystemResolvers] so a
// test can verify the propagation of Timeout / Attempts /
// nameservers without depending on /etc/resolv.conf being present.
// Test-only.
func SystemResolverConfigFromFile(path string) (perAttempt time.Duration, attempts int, err error) {
cfg, lerr := resolvconf.Load(path)
if lerr != nil {
return 0, 0, lerr
}
c := resolverConfig{}
applyResolvconfToConfig(&c, cfg)
return c.perAttempt, c.attempts, nil
}