You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# TODO: refactor this
ip_range = url_list.map do |x|
range = nil
# Parse IP ranges
if x =~ %r{^[0-9\.\-\/]+$} && x !~ %r{^[\d\.]+$}
begin
# CIDR notation
if x =~ %r{\d+\.\d+\.\d+\.\d+/\d+$}
range = IPAddr.new(x).to_range.map(&:to_s)
# x.x.x.x-x
elsif x =~ %r{^(\d+\.\d+\.\d+\.\d+)-(\d+)$}
start_ip = IPAddr.new(Regexp.last_match(1), Socket::AF_INET)
end_ip = IPAddr.new("#{start_ip.to_s.split('.')[0..2].join('.')}.#{Regexp.last_match(2)}", Socket::AF_INET)
range = (start_ip..end_ip).map(&:to_s)
# x.x.x.x-x.x.x.x
elsif x =~ %r{^(\d+\.\d+\.\d+\.\d+)-(\d+\.\d+\.\d+\.\d+)$}
start_ip = IPAddr.new(Regexp.last_match(1), Socket::AF_INET)
end_ip = IPAddr.new(Regexp.last_match(2), Socket::AF_INET)
range = (start_ip..end_ip).map(&:to_s)
end
rescue => e
# Something went horribly wrong parsing the target IP range
raise "Error parsing target IP range: #{e}"
end
end
range
end.compact.flatten
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: