Skip to content

Commit

Permalink
Update hostname resolution code to support Windows. (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
Crash-GHaun committed Sep 2, 2020
1 parent d539d8d commit 953273c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rqd/rqd/rqutil.py
Expand Up @@ -26,6 +26,7 @@
from builtins import str
from builtins import object
import functools
import logging as log
import os
import platform
import random
Expand Down Expand Up @@ -145,13 +146,13 @@ def getHostIp():

def getHostname():
"""Returns the machine's fully qualified domain name"""
if platform.system() == "Linux":
try:
if rqd.rqconstants.RQD_USE_IP_AS_HOSTNAME:
return getHostIp()
else:
# This may not work in windows/mac, need to test
return socket.gethostbyaddr(socket.gethostname())[0].split('.')[0]
else:
except (socket.herror, socket.gaierror):
log.warning("Failed to resolve hostname to IP, falling back to local hostname")
return socket.gethostname()


Expand Down

0 comments on commit 953273c

Please sign in to comment.