This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.
()
| 101 | |
| 102 | |
| 103 | def allowed_gai_family() -> socket.AddressFamily: |
| 104 | """This function is designed to work in the context of |
| 105 | getaddrinfo, where family=socket.AF_UNSPEC is the default and |
| 106 | will perform a DNS search for both IPv6 and IPv4 records.""" |
| 107 | |
| 108 | family = socket.AF_INET |
| 109 | if HAS_IPV6: |
| 110 | family = socket.AF_UNSPEC |
| 111 | return family |
| 112 | |
| 113 | |
| 114 | def _has_ipv6(host: str) -> bool: |
no outgoing calls