Skip to content

Feature: Add Dual-Stack support with IPv6 preference#309

Merged
richardpenman merged 1 commit intorichardpenman:masterfrom
devl00p:outbound_ipv6
Jan 9, 2026
Merged

Feature: Add Dual-Stack support with IPv6 preference#309
richardpenman merged 1 commit intorichardpenman:masterfrom
devl00p:outbound_ipv6

Conversation

@devl00p
Copy link
Copy Markdown
Contributor

@devl00p devl00p commented Jan 5, 2026

Description

This PR modernizes the NICClient network logic by introducing Dual-Stack (IPv4/IPv6) support.

Previously, the library was forced to use socket.AF_INET (IPv4), making it unable to connect to WHOIS servers over IPv6 or leverage IPv6-only environments.

The core of this change is a refactoring of the connection logic into a centralized _connect method that uses socket.getaddrinfo with socket.AF_UNSPEC.

Key Changes

  • Centralized Connection Logic: Introduced _connect(hostname, timeout) to handle DNS resolution and connection attempts. This replaces the scattered get_socket() + connect() calls in whois() and findwhois_iana().
  • IPv6 Preference: Added a prefer_ipv6 toggle in NICClient.__init__. When enabled, the client sorts resolved addresses to prioritize AF_INET6 (IPv6) over AF_INET (IPv4).
  • Robust Fallback (Happy Eyeballs-ish): If a connection to an IPv6 address fails (e.g., no route to host), the client automatically falls back to the next available address (IPv4) in the list.
  • CLI Exposure: Added the --prefer-ipv6 flag to the command-line interface.

@richardpenman
Copy link
Copy Markdown
Owner

Thanks!

@richardpenman richardpenman merged commit c316661 into richardpenman:master Jan 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants