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
module RFC1918 | |
def is_rfc1918_address(ip) | |
unless ip =~ /^(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})$/ | |
raise "#{ip} is not an IP address" | |
end | |
octets = [$1, $2, $3, $4].map &:to_i | |
raise "#{ip} is a bad IP address" unless octets.all? {|o| o < 256} | |
# The Internet Assigned Numbers Authority (IANA) has reserved the |