Tantalor93 / dnspyre

CLI tool for a high QPS DNS benchmark
https://tantalor93.github.io/dnspyre/
MIT License
107 stars 10 forks source link

Configurable exit code #238

Closed PenelopeFudd closed 5 months ago

PenelopeFudd commented 5 months ago

Describe the feature I'd like to have dnspyre return a nonzero exit code if any requests failed. Different people might have different definitions of failure at different times (e.g. connect timeout, nxdomain, duplicate answers, wrong answers, bad certificate, etc), so the parameter might take an argument: --fail="timeout,nxdomain"

Why do you need this feature I have a program that does binary searches. It'll run a specified program and fill in a specified parameter with a number, and based on the return code of the program, will search until it finds the number where the program just starts to fail:

bsearch -l low -h high -- command args args {} args args
  This will find the largest number that can be used in place of the {},
  in the range of low to high.

  Options:
    -l low : the low number of the range to test
    -h high : the high number of the range to test

Without this feature, I have to write a wrapper script that runs dnspyre and then greps for a success or failure string.

For an example, see the --fail argument for curl.

Thanks!

PS: This looks like the best DNS benchmarking program out there! DNSperf / DNSRes are hard to use, Flamethrower is hard in a different way, and DNS shotgun is... weird? Dnspyre looks polished, and it has all the protocols I'm looking for.

Tantalor93 commented 5 months ago

Hello @PenelopeFudd 🙂 thanks for suggesting this enhancement, I think this enhancement makes sense and I like your suggestion to introduce a new flag --fail that will configure conditions upon which the dnspyre will exit with non-zero status

I can image supporting these conditions:

and I will allow users to specify any combination of these conditions (like dnspyre --fail=ioerror,error google.com)

do you think this makes sense @PenelopeFudd?

This looks like the best DNS benchmarking program out there!

Thanks, glad to hear that 🙂

PenelopeFudd commented 5 months ago

Yes, that's exactly it, thank you!

Tantalor93 commented 5 months ago

Hello @PenelopeFudd, I have released a new version v3.1.0 of dnspyre, that now supports --fail flag, you can check the documentation https://tantalor93.github.io/dnspyre/failoncondition.html for usage, hope it fits your use case! Thank you!

PenelopeFudd commented 5 months ago

Er, one more request: --fail any, if any kind of error is found? Otherwise it's rather long to specify --fail ioerror --fail error --fail negative --fail idmismatch.

Tantalor93 commented 5 months ago

hmm, I understand, that it can be a little bit tedious to list all the conditions.

I am struggling with the semantics of such option any, it can be interpreted in many ways. Should it fail if there is any IOerror and DNS error, or should it also fail when there is a negative answer ? Negative answers usually are not a problem of the server but of the client asking for something that does not exist. Should truncated answers be considered also under the any option?

PenelopeFudd commented 5 months ago

It's true that it could be interpreted in many ways, although I was thinking of the basic "any of the errors that could be specified with --fail", as a way to see if everything is perfect or not. If I start looking into negative or truncated answers, then it'd be time to explicitly list what counts as an error.