feat: implement CLI flags and configuration handling (HAN-382) (#8)
CI / test (push) Failing after 3m57s
CI / test (push) Failing after 3m57s
This commit was merged in pull request #8.
This commit is contained in:
+12
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user