feat: implement CLI flags and configuration handling (HAN-382) (#8)
CI / test (push) Failing after 3m57s

This commit was merged in pull request #8.
This commit is contained in:
2026-06-07 16:08:39 +00:00
parent feb5c68b39
commit 876542b2de
5 changed files with 708 additions and 28 deletions
+12 -10
View File
@@ -10,18 +10,20 @@ import (
)
type QueryConfig struct {
UDPSize int
Timeout time.Duration
Retries int
UseTCP bool
UDPSize int
Timeout time.Duration
Retries int
UseTCP bool
AllowTCP bool
}
func DefaultQueryConfig() *QueryConfig {
return &QueryConfig{
UDPSize: DefaultEDNS0UDPSize(),
Timeout: 5 * time.Second,
Retries: 3,
UseTCP: false,
UDPSize: DefaultEDNS0UDPSize(),
Timeout: 5 * time.Second,
Retries: 3,
UseTCP: false,
AllowTCP: true,
}
}
@@ -110,7 +112,7 @@ func QueryWithExchange(ctx context.Context, server net.IP, name string, qtype ui
continue
}
if resp.Truncated {
if resp.Truncated && cfg.AllowTCP {
resp, err = exchangeFn(ctx, serverStr, msg, true)
if err != nil {
lastErr = err
@@ -178,7 +180,7 @@ func IterativeQueryWithExchange(ctx context.Context, server net.IP, name string,
continue
}
if resp.Truncated {
if resp.Truncated && cfg.AllowTCP {
resp, err = exchangeFn(ctx, serverStr, msg, true)
if err != nil {
lastErr = err