feat(cli): Add dig compatible error exit code 9
This patch implements the error exit code for "No reply from server" that dig uses to indicate that it was unable to resolve an address due to the inability to reach any resolver. References: https://linux.die.net/man/1/digpull/57/head
parent
0da9178683
commit
9386c589bf
|
@ -148,16 +148,25 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve Queries.
|
// Resolve Queries.
|
||||||
var responses []resolvers.Response
|
var (
|
||||||
|
responses []resolvers.Response
|
||||||
|
responseErrors []error
|
||||||
|
)
|
||||||
for _, q := range app.Questions {
|
for _, q := range app.Questions {
|
||||||
for _, rslv := range app.Resolvers {
|
for _, rslv := range app.Resolvers {
|
||||||
resp, err := rslv.Lookup(q)
|
resp, err := rslv.Lookup(q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Logger.WithError(err).Error("error looking up DNS records")
|
app.Logger.WithError(err).Error("error looking up DNS records")
|
||||||
|
responseErrors = append(responseErrors, err)
|
||||||
}
|
}
|
||||||
responses = append(responses, resp)
|
responses = append(responses, resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(responses) == 0 && len(responseErrors) > 0 {
|
||||||
|
app.Logger.Exit(9)
|
||||||
|
}
|
||||||
|
|
||||||
app.Output(responses)
|
app.Output(responses)
|
||||||
|
|
||||||
// Quitting.
|
// Quitting.
|
||||||
|
|
Loading…
Reference in New Issue