Commit 0f12efd0 authored by Alexandre's avatar Alexandre

Display number of IP found

and output IP on error
parent ffd0d930
......@@ -616,14 +616,20 @@ else:
family = 0
ip_set = resolved_ips(netloc, port, family, opts.dot)
# print number of IPs found
if opts.verbose and opts.check:
print("Checking \"%s\" ..." % url)
print("%d IP found : %s" % (len(ip_set), ', '.join(ip_set)))
ok = True
i = 1 # ip counter
for ip in ip_set:
if opts.dot and opts.vhostname is not None:
extracheck = opts.vhostname
else:
extracheck = None
if opts.verbose and opts.check and ip:
print("Checking \"%s\" on %s ..." % (url, ip))
print("(%d/%d) checking IP : %s" % (i, len(ip_set), ip))
try:
if opts.dot:
conn = homer.ConnectionDOT(url, servername=extracheck, connect_to=ip,
......@@ -648,6 +654,8 @@ for ip in ip_set:
err = "Could not connect to \"%s\"" % url
if opts.connectTo is not None:
err += " on %s" % opts.connectTo
elif ip is not None:
err += " on %s" % ip
error(err)
except (homer.ConnectionException, homer.DOHException) as e:
error(e)
......@@ -664,6 +672,8 @@ for ip in ip_set:
input.close()
conn.end()
i += 1
if ok:
if opts.check or opts.pipelining:
print('OK')
......
......@@ -223,7 +223,7 @@ tests:
- '--dot'
- 'dot.bortzmeyer.fr'
- 'www.afnic.fr'
partstdout: "on 193.70.85.11 ...\nConnecting to 193.70.85.11 ..."
partstdout: "checking IP : 193.70.85.11\nConnecting to 193.70.85.11 ..."
- exe: './homer.py'
name: '[doh][check] Test that all the resolved IPs are tried, try another IP'
......@@ -236,7 +236,7 @@ tests:
- '--dot'
- 'dot.bortzmeyer.fr'
- 'www.afnic.fr'
partstdout: "on 2001:41d0:302:2200::180 ...\nConnecting to 2001:41d0:302:2200::180 ..."
partstdout: "checking IP : 2001:41d0:302:2200::180\nConnecting to 2001:41d0:302:2200::180 ..."
- exe: './homer.py'
name: '[dot][check] Test all the IPs, force IPv4'
......@@ -251,7 +251,7 @@ tests:
- '--dot'
- 'dns.google'
- 'framagit.org'
partstdout: "on 8.8.8.8 ...\nConnecting to 8.8.8.8 ..."
partstdout: "checking IP : 8.8.8.8\nConnecting to 8.8.8.8 ..."
- exe: './homer.py'
name: '[dot][check] Test all the IPs, force IPv4, check another IP'
......@@ -266,7 +266,7 @@ tests:
- '--dot'
- 'dns.google'
- 'framagit.org'
partstdout: "on 8.8.4.4 ...\nConnecting to 8.8.4.4 ..."
partstdout: "checking IP : 8.8.4.4\nConnecting to 8.8.4.4 ..."
- exe: './homer.py'
name: '[dot][check] Test all the IPs, force IPv6'
......@@ -281,7 +281,7 @@ tests:
- '--dot'
- 'dns.google'
- 'framagit.org'
partstdout: "on 2001:4860:4860::8844 ...\nConnecting to 2001:4860:4860::8844 ..."
partstdout: "checking IP : 2001:4860:4860::8844\nConnecting to 2001:4860:4860::8844 ..."
- exe: './homer.py'
name: '[dot][check] Test all the IPs, force IPv6, check another IP'
......@@ -296,7 +296,7 @@ tests:
- '--dot'
- 'dns.google'
- 'framagit.org'
partstdout: "on 2001:4860:4860::8888 ...\nConnecting to 2001:4860:4860::8888 ..."
partstdout: "checking IP : 2001:4860:4860::8888\nConnecting to 2001:4860:4860::8888 ..."
- exe: './homer.py'
name: '[doh][check] Test all the IPs, force IPv4'
......
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