summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kocialkowski2024-05-10 21:40:44 +0200
committerPaul Kocialkowski2024-05-10 21:40:44 +0200
commit047f989866a51974ed206620fc1c25447a2454ea (patch)
treea58b08bbc3ce74da2fe1ee8b08ad2d640afc95e0
parent57205fbb273847b14e8edcf7288199a86d985220 (diff)
host-control: Use local name when resolvable
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rwxr-xr-xhost-control10
1 files changed, 7 insertions, 3 deletions
diff --git a/host-control b/host-control
index f337bf1..7e1f571 100755
--- a/host-control
+++ b/host-control
@@ -83,10 +83,14 @@ class host_control():
# host
def host_address(self, host):
- if "address" in host:
- return host["address"]
- else:
+ try:
+ socket.getaddrinfo(host["name"], None)
return host["name"]
+ except OSError:
+ if "address" in host:
+ return host["address"]
+ else:
+ return host["name"]
def host_lookup(self, name):
for h in self.hosts: