Commit 63d193fa authored by alex's avatar alex
Browse files

Merge branch 'usage' into 'master'

Explain options in usage

See merge request bortzmeyer/homer!17
parents 791a95bc d54c5ad5
......@@ -101,7 +101,51 @@ def error(msg=None, exit=True):
def usage(msg=None):
if msg:
print(msg,file=sys.stderr)
print("Usage: %s [--dot] url-or-servername domain-name [DNS type]" % sys.argv[0], file=sys.stderr)
print("Usage: %s [options] url-or-servername [domain-name [DNS type]]" % sys.argv[0], file=sys.stderr)
print("""Options
-t --dot Use DoT (by default use DoH)
-P --post --POST Use HTTP POST method for all transfers (DoH only)
-e --head --HEAD Use HTTP HEAD method for all transfers (DoH only)
-r --repeat <N> Perform N times the query. If used with -f, read up to
<N> rows of the <file>.
-d --delay <T> Time to wait in seconds between each synchronous
request (only with --repeat)
-f --file <file> Read domain names from <file>, one per row with an
optional DNS type
--check Perform a set of predefined tests.
--mandatory-level <level>
Define the <level> of test to perform (only with
--check)
Available <level> : legal, necessary, nicetohave
--multistreams Use HTTP/2 streams, needs an input file with -f
(DoH only)
--sync Process received queries synchronously (only with
--multistreams)
--no-display-results
Disable output of DNS response (only with
--multistreams)
--time Display the time elapsed for the query (only with
--multistreams)
--dnssec Request DNSSEC data (signatures)
--noedns Disable EDNS, default is to indicate EDNS support
--ecs Send ECS to authoritative servers, default is to
refuse it
--key <key> Authenticate a DoT resolver with its public <key> in
base64 (DoT only)
--nosni Do not perform SNI (DoT only)
-V --vhost <vhost> Use a specific virtual host
-k --insecure Do not check the certificate
-4 --v4only Force IPv4 resolution of url-or-servername
-6 --v6only Force IPv6 resolution of url-or-servername
-v --verbose Make the program more talkative
--debug Make the program even more talkative than -v
-h --help Print this message
url-or-servername The URL or domain name of the DoT/DoH server
domain-name The domain name to resolve, not required if -f is
provided
DNS type The DNS record type to resolve, default AAAA
""", file=sys.stderr)
print("See the README.md for more details.", file=sys.stderr)
def is_valid_hostname(name):
......@@ -881,8 +925,9 @@ if not monitoring:
message = None
try:
optlist, args = getopt.getopt (sys.argv[1:], "hvPkeV:r:f:d:t46",
["help", "verbose", "debug", "dot", "head",
"insecure", "POST", "vhost=", "multistreams",
["help", "verbose", "debug", "dot",
"head", "HEAD", "post", "POST",
"insecure", "vhost=", "multistreams",
"sync", "no-display-results", "time",
"dnssec", "noedns", "ecs", "repeat=", "file=", "delay=",
"key=", "nosni",
......@@ -948,9 +993,11 @@ if not monitoring:
mandatory_level = value
else:
error("Unknown option %s" % option)
except getopt.error as reason:
except (getopt.error, ValueError) as reason:
usage(reason)
sys.exit(1)
if delay is not None and multistreams:
error("--delay makes no sense with multistreams")
if tests <= 1 and delay is not None:
error("--delay makes no sense if there is no repetition")
if post and head:
......@@ -1049,9 +1096,6 @@ else: # Monitoring plugin
if dot and (post or head):
print("POST or HEAD makes no sense for DoT")
sys.exit(STATE_UNKNOWN)
if dot and multistreams:
print("Multi-streams makes no sense for DoT")
sys.exit(STATE_UNKNOWN)
if dot and path:
print("URL path makes no sense for DoT")
sys.exit(STATE_UNKNOWN)
......@@ -1161,7 +1205,7 @@ for connectTo in ip_set:
conn.perform_multi()
conn.first_handle = conn.all_handles[0]
start2 = time.time()
if delay is not None:
if delay is not None and not multistreams:
time.sleep(delay)
if multistreams:
conn.perform_multi()
......
......@@ -18,14 +18,14 @@ tests:
args:
- '-h'
retcode: 0
partstderr: 'url-or-servername domain-name [DNS type]'
partstderr: 'url-or-servername [domain-name [DNS type]]'
stdout: ''
- exe: './homer.py'
args:
- '--zzz'
retcode: 1
partstderr: 'url-or-servername domain-name [DNS type]'
partstderr: 'url-or-servername [domain-name [DNS type]]'
stdout: ''
- exe: './homer.py'
......@@ -131,7 +131,7 @@ tests:
- 'check'
- 'fail'
- 'slow'
timeout: 10
timeout: 12
args:
- '--check'
- 'https://doh.42l.fr/dns-query'
......@@ -944,7 +944,19 @@ tests:
stdout: ''
- exe: './homer.py'
name: '[doh] POST'
name: '[doh] POST --post'
markers:
- 'doh'
args:
- '--post'
- 'https://doh.bortzmeyer.fr'
- 'framagit.org'
retcode: 0
stderr: ''
partstdout: '2a01:4f8:'
- exe: './homer.py'
name: '[doh] POST --POST'
markers:
- 'doh'
args:
......@@ -956,7 +968,19 @@ tests:
partstdout: '2a01:4f8:'
- exe: './homer.py'
name: '[doh] HEAD'
name: '[doh] POST -P'
markers:
- 'doh'
args:
- '-P'
- 'https://doh.bortzmeyer.fr'
- 'framagit.org'
retcode: 0
stderr: ''
partstdout: '2a01:4f8:'
- exe: './homer.py'
name: '[doh] HEAD --head'
markers:
- 'doh'
args:
......@@ -967,6 +991,30 @@ tests:
stderr: ''
partstdout: 'HEAD'
- exe: './homer.py'
name: '[doh] HEAD --HEAD'
markers:
- 'doh'
args:
- '--HEAD'
- 'https://doh.bortzmeyer.fr'
- 'framagit.org'
retcode: 0
stderr: ''
partstdout: 'HEAD'
- exe: './homer.py'
name: '[doh] HEAD -e'
markers:
- 'doh'
args:
- '-e'
- 'https://doh.bortzmeyer.fr'
- 'framagit.org'
retcode: 0
stderr: ''
partstdout: 'HEAD'
- exe : './homer.py'
name: '[doh] Multistreams with DoT (error)'
markers:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment