Add IPv6 support #339 thanks to @bert128
parent
b2a53dc896
commit
89035e06a5
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import socket
|
||||
from os.path import isfile
|
||||
# from traceback import format_exc
|
||||
from threading import BoundedSemaphore
|
||||
|
@ -11,6 +12,17 @@ sem = BoundedSemaphore(1)
|
|||
global_failed_logins = 0
|
||||
user_failed_logins = {}
|
||||
|
||||
def gethost_addrinfo(hostname):
|
||||
try:
|
||||
for res in socket.getaddrinfo(hostname, None, socket.AF_INET6,
|
||||
socket.SOCK_DGRAM, socket.IPPROTO_IP, socket.AI_CANONNAME):
|
||||
af, socktype, proto, canonname, sa = res
|
||||
except socket.gaierror:
|
||||
for res in socket.getaddrinfo(hostname, None, socket.AF_INET,
|
||||
socket.SOCK_DGRAM, socket.IPPROTO_IP, socket.AI_CANONNAME):
|
||||
af, socktype, proto, canonname, sa = res
|
||||
|
||||
return sa[0]
|
||||
|
||||
def requires_admin(func):
|
||||
def _decorator(self, *args, **kwargs):
|
||||
|
@ -37,7 +49,7 @@ class connection(object):
|
|||
self.local_ip = None
|
||||
|
||||
try:
|
||||
self.host = gethostbyname(self.hostname)
|
||||
self.host = gethost_addrinfo(self.hostname)
|
||||
if self.args.kerberos:
|
||||
self.host = self.hostname
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in New Issue