summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-08 20:24:55 +0000
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-08 20:24:55 +0000
commitc5a3cfc0092f86f101b4bc6825a3b77bc8ee1de6 (patch)
tree3b24d48306dd2583e67a7888b0f91358d1921121 /scripts
parent833508908486f8ff5747d914e945afed5f0eb896 (diff)
downloadvyatta-op-c5a3cfc0092f86f101b4bc6825a3b77bc8ee1de6.tar.gz
vyatta-op-c5a3cfc0092f86f101b4bc6825a3b77bc8ee1de6.zip
ping: T2109: fix/add name resolution
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ping10
1 files changed, 8 insertions, 2 deletions
diff --git a/scripts/ping b/scripts/ping
index e41e334..e8b0471 100755
--- a/scripts/ping
+++ b/scripts/ping
@@ -16,6 +16,7 @@
import os
import sys
+import socket
import ipaddress
options = {
@@ -205,9 +206,14 @@ if __name__ == '__main__':
matched = complete(option)
sys.stdout.write(options[matched[0]]['type'])
sys.exit(0)
-
+
+ try:
+ ip = socket.gethostbyname(host)
+ except socket.gaierror:
+ sys.exit(f'ping: Unknown host: {host}')
+
try:
- version = ipaddress.ip_address(host).version
+ version = ipaddress.ip_address(ip).version
except ValueError:
sys.exit(f'ping: Unknown host: {host}')