+# cache IP adresses
+HostToIPCache = {}
+def HostToIP(Host):
+ global HostToIPCache
+ if not Host in HostToIPCache:
+ IPAdressesT = None
+ try:
+ IPAdressesT = list(set([ (a[0],a[4][0]) for a in socket.getaddrinfo(Host, None)]))
+ except socket.gaierror, (code):
+ if code[0] != -2: raise
+ IPAdresses = []
+ for addr in IPAdressesT:
+ if addr[0] == socket.AF_INET: IPAdresses += [addr[1], "::ffff:"+addr[1]]
+ else: IPAdresses += [addr[1]]
+ HostToIPCache[Host] = IPAdresses
+ return HostToIPCache[Host]
+
+