Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --retries global to a name and try with other name servers in a given layer #451

Merged
merged 25 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3c81465
re-work for retries
phillip-stephens Sep 19, 2024
fc26240
added network timeout
phillip-stephens Sep 19, 2024
46580dd
add comments
phillip-stephens Sep 19, 2024
b4a6885
consolidated cachedRetryingLookup and retryingLookup into single fn, …
phillip-stephens Sep 19, 2024
d9c4d03
better iterateOnAuth handling
phillip-stephens Sep 19, 2024
cfb7235
handle status error in iterateOnAuths
phillip-stephens Sep 19, 2024
801e688
remove unused status
phillip-stephens Sep 19, 2024
d3a7ad9
Merge remote-tracking branch 'origin/main' into phillip/93-domain-ret…
phillip-stephens Sep 19, 2024
297e75e
update README
phillip-stephens Sep 19, 2024
c8a6c1b
update retries in cli
phillip-stephens Sep 19, 2024
71a963b
properly handle the NetworkTimeout
phillip-stephens Sep 19, 2024
b63e4ab
PR cleanup
phillip-stephens Sep 19, 2024
0117ece
fix defaults for network timeout
phillip-stephens Sep 20, 2024
dc0413d
fix todo in comment
phillip-stephens Sep 20, 2024
d90e02a
reset nonqueried map if all nameservers are queried
phillip-stephens Sep 20, 2024
62925fc
Merge remote-tracking branch 'origin/main' into phillip/93-domain-ret…
phillip-stephens Sep 20, 2024
f6a3c6b
Merge branch 'main' into phillip/93-domain-retries
phillip-stephens Sep 20, 2024
d6e465a
fix merge issues
phillip-stephens Sep 20, 2024
a1f8214
Merge branch 'phillip/93-domain-retries' of github.com:zmap/zdns into…
phillip-stephens Sep 20, 2024
49368bf
comment theorized root cause of issue
phillip-stephens Sep 20, 2024
e3945dd
Merge branch 'main' into phillip/93-domain-retries
zakird Sep 27, 2024
1f5b451
Merge branch 'main' into phillip/93-domain-retries
phillip-stephens Sep 30, 2024
3b42ef9
resolve compile issues and sanity check the retry logic
phillip-stephens Sep 30, 2024
b7b6c0b
more global retry handling
phillip-stephens Sep 30, 2024
3d1d06e
update default timeouts and retries in cli.go
phillip-stephens Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ routines. This architecture has several caveats:

* `--timeout` The maximum amount of time ZDNS will spend on a single name
* `--iteration-timeout` The maximum amount of time ZDNS will spend on a single iteration step (ex: resolving google.com at the .com layer)
* `--retries` The number of retries ZDNS will make against a single nameserver before giving up for that name
* `--network-timeout` The maximum amount of time ZDNS will wait for a response from a nameserver
* `--retries=N` If a connection to a specific nameserver fails in `--iterative`, ZDNS will retry with another un-queried name server at that layer.
Retries are per-name, so if `--retries=1` then ZDNS will retry a name against a new nameserver once during it's full iteration process. If all nameservers have been queried
then a random nameserver will be chosen.
* `--name-servers` The list of nameservers to use for lookups, mostly useful with `--iterative=false`


Expand Down
7 changes: 4 additions & 3 deletions src/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ type GeneralOptions struct {
LookupAllNameServers bool `long:"all-nameservers" description:"Perform the lookup via all the nameservers for the domain."`
CacheSize int `long:"cache-size" default:"10000" description:"how many items can be stored in internal recursive cache"`
GoMaxProcs int `long:"go-processes" default:"0" description:"number of OS processes (GOMAXPROCS by default)"`
IterationTimeout int `long:"iteration-timeout" default:"4" description:"timeout for a single iterative step in an iterative query, in seconds. Only applicable with --iterative"`
IterationTimeout int `long:"iteration-timeout" default:"8" description:"timeout for a single iterative step in an iterative query, in seconds. Only applicable with --iterative"`
IterativeResolution bool `long:"iterative" description:"Perform own iteration instead of relying on recursive resolver"`
MaxDepth int `long:"max-depth" default:"10" description:"how deep should we recurse when performing iterative lookups"`
NameServerMode bool `long:"name-server-mode" description:"Treats input as nameservers to query with a static query rather than queries to send to a static name server"`
NameServersString string `long:"name-servers" description:"List of DNS servers to use. Can be passed as comma-delimited string or via @/path/to/file. If no port is specified, defaults to 53."`
UseNanoseconds bool `long:"nanoseconds" description:"Use nanosecond resolution timestamps in output"`
NetworkTimeout int `long:"network-timeout" default:"2" description:"timeout for round trip network operations, in seconds"`
DisableFollowCNAMEs bool `long:"no-follow-cnames" description:"do not follow CNAMEs/DNAMEs in the lookup process"`
Retries int `long:"retries" default:"1" description:"how many times should zdns retry query if timeout or temporary failure"`
Retries int `long:"retries" default:"3" description:"how many times should zdns retry query against a new nameserver if timeout or temporary failure"`
Threads int `short:"t" long:"threads" default:"100" description:"number of lightweight go threads"`
Timeout int `long:"timeout" default:"15" description:"timeout for resolving a individual name, in seconds"`
Timeout int `long:"timeout" default:"20" description:"timeout for resolving a individual name, in seconds"`
Version bool `long:"version" short:"v" description:"Print the version of zdns and exit"`
}

Expand Down
1 change: 1 addition & 0 deletions src/cli/worker_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func populateResolverConfig(gc *CLIConf) *zdns.ResolverConfig {
}

config.Timeout = time.Second * time.Duration(gc.Timeout)
config.NetworkTimeout = time.Second * time.Duration(gc.NetworkTimeout)
config.IterativeTimeout = time.Second * time.Duration(gc.IterationTimeout)
config.LookupAllNameServers = gc.LookupAllNameServers
config.FollowCNAMEs = !gc.DisableFollowCNAMEs // ZFlags only allows default-false bool flags. We'll invert here.
Expand Down
4 changes: 2 additions & 2 deletions src/modules/bindversion/bindversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var queries []QueryRecord
// DoSingleDstServerLookup(r *Resolver, q Question, nameServer string, isIterative bool) (*SingleQueryResult, Trace, Status, error)
type MockLookup struct{}

func (ml MockLookup) DoSingleDstServerLookup(r *zdns.Resolver, question zdns.Question, nameServer *zdns.NameServer, isIterative bool) (*zdns.SingleQueryResult, zdns.Trace, zdns.Status, error) {
queries = append(queries, QueryRecord{q: question, NameServer: nameServer})
func (ml MockLookup) DoDstServersLookup(r *zdns.Resolver, question zdns.Question, nameServers []zdns.NameServer, isIterative bool) (*zdns.SingleQueryResult, zdns.Trace, zdns.Status, error) {
queries = append(queries, QueryRecord{q: question, NameServer: &nameServers[0]})
if res, ok := mockResults[question.Name]; ok {
return res, nil, zdns.StatusNoError, nil
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/dmarc/dmarc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var queries []QueryRecord

type MockLookup struct{}

func (ml MockLookup) DoSingleDstServerLookup(r *zdns.Resolver, question zdns.Question, nameServer *zdns.NameServer, isIterative bool) (*zdns.SingleQueryResult, zdns.Trace, zdns.Status, error) {
queries = append(queries, QueryRecord{question, nameServer})
func (ml MockLookup) DoDstServersLookup(r *zdns.Resolver, question zdns.Question, nameServers []zdns.NameServer, isIterative bool) (*zdns.SingleQueryResult, zdns.Trace, zdns.Status, error) {
queries = append(queries, QueryRecord{question, &nameServers[0]})
if res, ok := mockResults[question.Name]; ok {
return res, nil, zdns.StatusNoError, nil
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/spf/spf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var queries []QueryRecord

type MockLookup struct{}

func (ml MockLookup) DoSingleDstServerLookup(r *zdns.Resolver, question zdns.Question, nameServer *zdns.NameServer, isIterative bool) (*zdns.SingleQueryResult, zdns.Trace, zdns.Status, error) {
queries = append(queries, QueryRecord{question, nameServer})
func (ml MockLookup) DoDstServersLookup(r *zdns.Resolver, question zdns.Question, nameServers []zdns.NameServer, isIterative bool) (*zdns.SingleQueryResult, zdns.Trace, zdns.Status, error) {
queries = append(queries, QueryRecord{question, &nameServers[0]})
if res, ok := mockResults[question.Name]; ok {
return res, nil, zdns.StatusNoError, nil
} else {
Expand Down
Loading