Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix include? and ipv4_mapped to allow drb tests to pass #31

Merged
merged 4 commits into from Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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