Pep8 fixes
This commit is contained in:
parent
93dce43e86
commit
06f9704820
|
@ -29,6 +29,7 @@ import socket
|
||||||
SSH_PORT = 22
|
SSH_PORT = 22
|
||||||
proxy_re = re.compile(r"^(proxycommand)\s*=*\s*(.*)", re.I)
|
proxy_re = re.compile(r"^(proxycommand)\s*=*\s*(.*)", re.I)
|
||||||
|
|
||||||
|
|
||||||
class LazyFqdn(object):
|
class LazyFqdn(object):
|
||||||
"""
|
"""
|
||||||
Returns the host's fqdn on request as string.
|
Returns the host's fqdn on request as string.
|
||||||
|
@ -41,21 +42,26 @@ class LazyFqdn(object):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.fqdn is None:
|
if self.fqdn is None:
|
||||||
#
|
#
|
||||||
# If the SSH config contains AddressFamily, use that when determining
|
# If the SSH config contains AddressFamily, use that when
|
||||||
# the local host's FQDN. Using socket.getfqdn() from the standard
|
# determining the local host's FQDN. Using socket.getfqdn() from
|
||||||
# library is the most general solution, but can result in noticeable
|
# the standard library is the most general solution, but can
|
||||||
# delays on some platforms when IPv6 is misconfigured or not available,
|
# result in noticeable delays on some platforms when IPv6 is
|
||||||
# as it calls getaddrinfo with no address family specified, so both
|
# misconfigured or not available, as it calls getaddrinfo with no
|
||||||
# IPv4 and IPv6 are checked.
|
# address family specified, so both IPv4 and IPv6 are checked.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Handle specific option
|
# Handle specific option
|
||||||
fqdn = None
|
fqdn = None
|
||||||
address_family = self.config.get('addressfamily', 'any').lower()
|
address_family = self.config.get('addressfamily', 'any').lower()
|
||||||
if address_family != 'any':
|
if address_family != 'any':
|
||||||
family = socket.AF_INET if address_family == 'inet' else socket.AF_INET6
|
family = socket.AF_INET if address_family == 'inet' \
|
||||||
results = socket.getaddrinfo(host, None, family,
|
else socket.AF_INET6
|
||||||
socket.SOCK_DGRAM, socket.IPPROTO_IP, socket.AI_CANONNAME)
|
results = socket.getaddrinfo(host,
|
||||||
|
None,
|
||||||
|
family,
|
||||||
|
socket.SOCK_DGRAM,
|
||||||
|
socket.IPPROTO_IP,
|
||||||
|
socket.AI_CANONNAME)
|
||||||
for res in results:
|
for res in results:
|
||||||
af, socktype, proto, canonname, sa = res
|
af, socktype, proto, canonname, sa = res
|
||||||
if canonname and '.' in canonname:
|
if canonname and '.' in canonname:
|
||||||
|
@ -68,6 +74,7 @@ class LazyFqdn(object):
|
||||||
self.fqdn = fqdn
|
self.fqdn = fqdn
|
||||||
return self.fqdn
|
return self.fqdn
|
||||||
|
|
||||||
|
|
||||||
class SSHConfig (object):
|
class SSHConfig (object):
|
||||||
"""
|
"""
|
||||||
Representation of config information as stored in the format used by
|
Representation of config information as stored in the format used by
|
||||||
|
|
Loading…
Reference in New Issue