Skip to content

Commit

Permalink
Pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lndbrg committed Feb 28, 2013
1 parent 93dce43 commit 06f9704
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions paramiko/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SSH_PORT = 22
proxy_re = re.compile(r"^(proxycommand)\s*=*\s*(.*)", re.I)


class LazyFqdn(object):
"""
Returns the host's fqdn on request as string.
Expand All @@ -41,21 +42,26 @@ def __init__(self, config):
def __str__(self):
if self.fqdn is None:
#
# If the SSH config contains AddressFamily, use that when determining
# the local host's FQDN. Using socket.getfqdn() from the standard
# library is the most general solution, but can result in noticeable
# delays on some platforms when IPv6 is misconfigured or not available,
# as it calls getaddrinfo with no address family specified, so both
# IPv4 and IPv6 are checked.
# If the SSH config contains AddressFamily, use that when
# determining the local host's FQDN. Using socket.getfqdn() from
# the standard library is the most general solution, but can
# result in noticeable delays on some platforms when IPv6 is
# misconfigured or not available, as it calls getaddrinfo with no
# address family specified, so both IPv4 and IPv6 are checked.
#

# Handle specific option
fqdn = None
address_family = self.config.get('addressfamily', 'any').lower()
if address_family != 'any':
family = socket.AF_INET if address_family == 'inet' else socket.AF_INET6
results = socket.getaddrinfo(host, None, family,
socket.SOCK_DGRAM, socket.IPPROTO_IP, socket.AI_CANONNAME)
family = socket.AF_INET if address_family == 'inet' \
else socket.AF_INET6
results = socket.getaddrinfo(host,
None,
family,
socket.SOCK_DGRAM,
socket.IPPROTO_IP,
socket.AI_CANONNAME)
for res in results:
af, socktype, proto, canonname, sa = res
if canonname and '.' in canonname:
Expand All @@ -68,6 +74,7 @@ def __str__(self):
self.fqdn = fqdn
return self.fqdn


class SSHConfig (object):
"""
Representation of config information as stored in the format used by
Expand Down

0 comments on commit 06f9704

Please sign in to comment.