Skip to content

Commit

Permalink
Merge pull request #1 from CvX/unmasked-string
Browse files Browse the repository at this point in the history
Handle unmasked address in non-string cases
  • Loading branch information
composerinteralia committed Sep 14, 2020
2 parents 537a09c + 445c765 commit b06488d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ def initialize(addr = '::', family = Socket::AF_UNSPEC)
when Socket::AF_INET, Socket::AF_INET6
set(addr.to_i, family)
@mask_addr = (family == Socket::AF_INET) ? IN4MASK : IN6MASK
@unmasked_addr = @addr
return
when Socket::AF_UNSPEC
raise AddressFamilyError, "address family must be specified"
Expand Down
1 change: 1 addition & 0 deletions test/test_ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,5 +428,6 @@ def test_unmasked
assert_equal("1.2.3.4", IPAddr.new("1.2.3.4/8").to_unmasked_string)
assert_equal("0001:0002:0000:0000:0000:0000:0000:0003", IPAddr.new("1:2::3").to_unmasked_string)
assert_equal("0001:0002:0000:0000:0000:0000:0000:0003", IPAddr.new("1:2::3/16").to_unmasked_string)
assert_equal("1.2.3.4", IPAddr.new(IPAddr.new("1.2.3.4").to_i, Socket::AF_INET).to_unmasked_string)
end
end

0 comments on commit b06488d

Please sign in to comment.