Skip to content

Commit

Permalink
Merge pull request #31 from jeremyevans/fix-drb-failures
Browse files Browse the repository at this point in the history
Fix include? and ipv4_mapped to allow drb tests to pass
  • Loading branch information
hsbt committed Oct 11, 2021
2 parents 94c3391 + 2059658 commit 5a25ded
Show file tree
Hide file tree
Showing 7 changed files with 1,169 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -7,7 +7,7 @@ jobs:
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
strategy:
matrix:
ruby: [ 3.0, 2.7, 2.6, 2.5, 2.4, 2.3, head, jruby-9.2.13.0, truffleruby-20.3.0 ]
ruby: [ "3.0", 2.7, 2.6, 2.5, 2.4, 2.3, head, jruby-9.2, jruby-9.3, truffleruby-20.3.0 ]
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
8 changes: 6 additions & 2 deletions lib/ipaddr.rb
Expand Up @@ -173,8 +173,10 @@ def mask(prefixlen)
# p net1.include?(net4) #=> false
# p net4.include?(net1) #=> true
def include?(other)
other = coerce_other(other)
return false unless other.family == family
range = to_range
other = coerce_other(other).to_range
other = other.to_range
range.begin <= other.begin && range.end >= other.end
end
alias === include?
Expand Down Expand Up @@ -316,7 +318,9 @@ def ipv4_mapped
if !ipv4?
raise InvalidAddressError, "not an IPv4 address: #{@addr}"
end
return self.clone.set(@addr | 0xffff00000000, Socket::AF_INET6)
clone = self.clone.set(@addr | 0xffff00000000, Socket::AF_INET6)
clone.instance_variable_set(:@mask_addr, @mask_addr | 0xffffffffffffffffffffffff00000000)
clone
end

# Returns a new ipaddr built by converting the native IPv4 address
Expand Down

0 comments on commit 5a25ded

Please sign in to comment.