Repository navigation
Conversation
@datibbaw I think
|
Returns the hexadecimal representation of the address value, right adjusted to the address size (8 characters for IPv4, 32 for IPv6). This is used for e.g. SPF macro expansions. Co-Authored-By: Claude Code <noreply@anthropic.com>
The ipv4_compat tests use assert_warning, which is provided by test-unit-ruby-core's CoreAssertions module rather than the test-unit gem itself. Require core_assertions and include the module into the test case so those tests actually run instead of erroring. Co-Authored-By: Claude Code <noreply@anthropic.com>
Thanks @taketo1113. The |
Adds
IPAddr#to_hex, which returns the hexadecimal representation of the address value, right adjusted to the address size — 8 characters for IPv4, 32 for IPv6:Motivation: consumers that need the padded hex form of an address — most notably SPF macro expansions (RFC 7208
%{ir}), but also DNS reverse-name construction and protocol encodings — currently have to reimplement the family-dependent padding themselves:Having this in the library would help reduce the external branching in other projects.
I decided to make this raise an
AddressFamilyErrordespite it being impossible to create an instance of a family type outside of IPv4 or IPv6, after all we may have IPv8 at some point 😸