Skip to content
Snippets Groups Projects
Commit f562a7f7 authored by Mike Mackintosh's avatar Mike Mackintosh
Browse files

add multicast and loopback checks

parent 4c759982
No related branches found
No related tags found
No related merge requests found
...@@ -598,6 +598,34 @@ module IPAddress; ...@@ -598,6 +598,34 @@ module IPAddress;
[self.class.new("224.0.0.0/4")].any? {|i| i.include? self} [self.class.new("224.0.0.0/4")].any? {|i| i.include? self}
end end
#
# Checks if an IPv4 address objects belongs
# to a multicast network RFC3171
#
# Example:
#
# ip = IPAddress "224.0.0.0/4"
# ip.multicast?
# #=> true
#
def multicast?
[self.class.new("224.0.0.0/4")].any? {|i| i.include? self}
end
#
# Checks if an IPv4 address objects belongs
# to a loopback network RFC1122
#
# Example:
#
# ip = IPAddress "127.0.0.1"
# ip.loopback?
# #=> true
#
def loopback?
[self.class.new("127.0.0.0/8")].any? {|i| i.include? self}
end
# #
# Returns the IP address in in-addr.arpa format # Returns the IP address in in-addr.arpa format
# for DNS lookups # for DNS lookups
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment