diff options
author | Scott Kuhl <kuhl@mtu.edu> | 2022-02-04 11:22:56 -0500 |
---|---|---|
committer | Scott Kuhl <kuhl@mtu.edu> | 2022-02-04 15:20:25 -0500 |
commit | 0c3b615736a008cfeea43575a5403075c783b5b3 (patch) | |
tree | 65bac71ee66bcd30707eb37b548949437c37ef51 | |
parent | c783fdb472588a18775ccc7cd3214f3b1806335d (diff) |
Improve message when bind fails with a IPv6 address
The comments at the end of issue #673 shows an example where sshuttle
exits with an OSError exception when it cannot bind to an IPv6
address. This patch makes a suggestion to try the --disable-ipv6
option instead of the cryptic error message.
-rw-r--r-- | sshuttle/client.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sshuttle/client.py b/sshuttle/client.py index 83b96c7..51af6a0 100644 --- a/sshuttle/client.py +++ b/sshuttle/client.py @@ -164,7 +164,22 @@ class MultiListener: self.bind_called = True if address_v6 is not None: self.v6 = socket.socket(socket.AF_INET6, self.type, self.proto) - self.v6.bind(address_v6) + try: + self.v6.bind(address_v6) + except OSError as e: + if e.errno == errno.EADDRNOTAVAIL: + # On an IPv6 Linux machine, this situation occurs + # if you run the following prior to running + # sshuttle: + # + # echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 + # echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6 + raise Fatal("Could not bind to an IPv6 socket with " + "address %s and port %s. " + "Potential workaround: Run sshuttle " + "with '--disable-ipv6'." + % (str(address_v6[0]), str(address_v6[1]))) + raise e else: self.v6 = None if address_v4 is not None: |