Skip to content

Commit

Permalink
Merge pull request #11 from PierluigiGreto/fix_address_family
Browse files Browse the repository at this point in the history
handle OSError errno 97 when ipv6 is disabled
  • Loading branch information
choppsv1 authored May 8, 2018
2 parents 46367ea + 586f5cc commit b49c74d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sshutil/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ def __init__(self,
# Bind first to IPv6, if the OS supports binding per AF then the IPv4
# will succeed, otherwise the IPv6 will support both AF.
for pname, host, proto in [("IPv6", '::', socket.AF_INET6), ("IPv4", '', socket.AF_INET)]:
protosocket = socket.socket(proto, socket.SOCK_STREAM)
try:
protosocket = socket.socket(proto, socket.SOCK_STREAM)
except OSError as e:
if e.errno == errno.EAFNOSUPPORT:
continue
raise
protosocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if self.debug:
logger.debug("Server binding to proto %s port %s", str(pname), str(port))
Expand Down

0 comments on commit b49c74d

Please sign in to comment.