Skip to content

Respect explicit families for bracketed and scoped IPv6 addresses - #128

Open
ac1982 wants to merge 1 commit into
ruby:masterfrom
ac1982:fix/explicit-family-ipv6-literals
Open

ac1982 wants to merge 1 commit into
ruby:masterfrom
ac1982:fix/explicit-family-ipv6-literals

Conversation

@ac1982

@ac1982 ac1982 commented Oct 10, 2026

Copy link
Copy Markdown

Fixes #62.

The constructor forces family to AF_INET6 when it finds brackets or a zone ID. This overwrites an explicitly supplied AF_INET, so IPAddr.new('[::]', Socket::AF_INET) succeeds even though the undecorated IPv6 spelling raises AddressFamilyError.

Keep the requested family and reject a conflict before parsing the address. Automatic family detection and explicitly requested IPv6 continue to work; bracketed IPv4 addresses remain invalid.

The regression covers bracketed, scoped, combined, and CIDR forms, including unsupported explicit families and positive IPv6 cases. It fails before the change. bundle exec rake test passes on Ruby 3.3.8 / Linux arm64: 39 tests, 583 assertions, no failures/errors/omissions. git diff --check passes. Other Ruby versions and macOS were not run locally.

AI assistance: OpenAI Codex investigated, implemented, and ran these checks.

@ac1982
ac1982 requested a review from knu as a code owner October 10, 2026 07:43

This branch has not been deployed

No deployments
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.

IPAddr.new accepts certain IPv6 literals when AF_INET is specified

1 participant