Skip to content

feat: add IPv6 support via IO::Socket::IP#66

Draft
toddr-bot wants to merge 2 commits into
mainfrom
koan.toddr.bot/ipv6-support
Draft

feat: add IPv6 support via IO::Socket::IP#66
toddr-bot wants to merge 2 commits into
mainfrom
koan.toddr.bot/ipv6-support

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Apr 14, 2026

Copy link
Copy Markdown

What

Add transparent IPv6 support by preferring IO::Socket::IP over IO::Socket::INET.

Why

Net::Daemon only supports IPv4. IO::Socket::IP has been in Perl core since 5.20 (2014) and is a drop-in replacement that enables dual-stack IPv4/IPv6 listening with zero configuration change. This lets daemon subclasses accept IPv6 clients without any code modification.

How

  • $Net::Daemon::INET_CLASS is resolved once at load time: IO::Socket::IP if available, IO::Socket::INET otherwise. Both Daemon.pm and Test.pm use this class for TCP server sockets.
  • Accept() now handles IPv4-mapped IPv6 addresses (::ffff:x.x.x.x) that appear on dual-stack sockets. The bare IPv4 address is extracted for gethostbyaddr() and added to the ACL pattern list, so existing IPv4 regex masks keep working unchanged.
  • Guard peerhost() calls with a proto check — IO::Socket::UNIX doesn't implement this method.

Testing

  • All 19 existing tests pass (76 subtests), including config.t (ACL tests) and unix_clients.t
  • New t/ipv6.t with 7 assertions: class selection, IPv4-mapped Accept() normalization, deny rules

🤖 Generated with Claude Code


Quality Report

Changes: 3 files changed, 127 insertions(+), 7 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

toddr-bot and others added 2 commits April 14, 2026 12:56
Prefer IO::Socket::IP (core since Perl 5.20) over IO::Socket::INET for
transparent dual-stack IPv4/IPv6 support. Falls back to IO::Socket::INET
on older Perls, preserving backward compatibility.

Key changes:
- Daemon.pm/Test.pm: use $INET_CLASS resolved at load time
- Accept(): handle IPv4-mapped IPv6 addresses (::ffff:x.x.x.x) so
  existing IPv4 ACL masks continue to work on dual-stack sockets
- New t/ipv6.t: 7 tests covering class selection and ACL normalization
- POD: document IPv6 support and --localaddr IPv6 usage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
IO::Socket::IP with no LocalAddr may bind to :: (dual-stack IPv6)
on some platforms. Test clients use IO::Socket::INET to connect to
127.0.0.1, which can't reach an IPv6-only listener on Windows.
Default the test server's LocalAddr to 127.0.0.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant