Skip to content

Commit

Permalink
Merge pull request #34 from casperisfine/v6-parsing-failures
Browse files Browse the repository at this point in the history
Ipaddr#native must also coerce `@mask_addr`
  • Loading branch information
byroot committed Dec 3, 2021
2 parents 72a2649 + af48519 commit 0a4f319
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ipaddr.rb
Expand Up @@ -509,6 +509,9 @@ def set(addr, *family)
@addr = addr
if family[0]
@family = family[0]
if @family == Socket::AF_INET
@mask_addr &= IN4MASK
end
end
return self
end
Expand Down
5 changes: 5 additions & 0 deletions test/test_ipaddr.rb
Expand Up @@ -360,6 +360,11 @@ def test_include?

end

def test_native_coerce_mask_addr
assert_equal(IPAddr.new("0.0.0.2/255.255.255.255"), IPAddr.new("::2").native)
assert_equal(IPAddr.new("0.0.0.2/255.255.255.255").to_range, IPAddr.new("::2").native.to_range)
end

def test_loopback?
assert_equal(true, IPAddr.new('127.0.0.1').loopback?)
assert_equal(true, IPAddr.new('127.127.1.1').loopback?)
Expand Down

0 comments on commit 0a4f319

Please sign in to comment.