'The use of gethostbyname/gethostbyaddr here is questionable, but it is
the easiest way to sort out the discrepancies between the output
formats of both versions of netcat'

def resolveHost(self, host):

    if (re.search('^\\d{1,3}(?:\\.\\d{1,3}){3}', host) is not None):
        try:
            result = socket.gethostbyaddr(host)
            return (host, result[0])
        except:
            return (host, None)
    else:
        try:
            result = socket.gethostbyname(host)
            return (result, host)
        except:
            return (None, host)
