Created
July 15, 2022 07:21
-
-
Save hogelog/d7ed9317649c4adcee3b097a7852ac06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ipaddr" | |
text = ARGF.read | |
cidrs = [] | |
while (match = text.match(%r[(\d+\.\d+\.\d+\.\d+/\d+)])) | |
cur = IPAddr.new(match[1]) | |
cur_addrs = cur.to_range.to_a | |
cidrs.each do |cidr| | |
puts "overlap: #{cur} x #{cidr}" if cur_addrs.any?{|cur_addr| cidr.to_range.cover?(cur_addr) } | |
end | |
cidrs << cur | |
cidrs.uniq! | |
text = match.post_match | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment