[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Add a function to test whether we have ipv6 support.



commit 31c4ad44f5f124f3e69d480a1b4d99ecd86dd10e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu May 9 11:45:02 2019 -0400

    Add a function to test whether we have ipv6 support.
---
 lib/chutney/Host.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/chutney/Host.py b/lib/chutney/Host.py
new file mode 100644
index 0000000..75573d6
--- /dev/null
+++ b/lib/chutney/Host.py
@@ -0,0 +1,20 @@
+
+import socket
+import chutney.Util
+
+@chutney.Util.memoized
+def is_ipv6_supported():
+    """Return true iff ipv6 is supported on this host."""
+    try:
+        s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
+        s.bind(("::1", 0))
+        s.listen(128)
+        a = s.getsockname()
+        s2 = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
+        s2.settimeout(1)
+        s2.connect(a)
+        return True
+    except socket.error:
+        return False
+
+



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits