lib/wmap/utils/utils.rb
# Test if it's a legitimate IP4 address
Test if it's a legitimate IP4 address
Test if it ' s a legitimate IP4 address
def is_ip? (ip)
		puts "Validate the IP format is valid: #{ip}" if @verbose
		begin
			ip=ip.strip
			raise "This is an URL: #{ip}" if is_url?(ip)
			if ip =~ /\d+\.\d+\.\d+.\d+/ and ip !~ /\/\d+/
				octs=ip.split('.')
				return false unless octs.size==4
				octs.map { |x| return false unless x.to_i >=0 and x.to_i <=255 }
			else
				return false
			end
			puts "Confirmed as a valid IP: #{ip}" if @verbose
			return true
		rescue => ee
			puts "Exception on method is_ip? for #{ip}: #{ee}" if @verbose
			return false
		end
	end
def is_ip? ( ip ) puts "Validate the IP format is valid: #{ip}" if @verbose begin ip = ip . strip raise "This is an URL: #{ip}" if is_url? ( ip ) if ip =~ / \d + \. \d + \. \d +. \d + / and ip !~ / \/ \d + / octs = ip . split ( '.' ) return false unless octs . size == 4 octs . map { | x | return false unless x . to_i >= 0 and x . to_i <= 255 } else return false end puts "Confirmed as a valid IP: #{ip}" if @verbose return true rescue => ee puts "Exception on method is_ip? for #{ip}: #{ee}" if @verbose return false end end
Test if it's a legitimate IP4 address
Test if it ' s a legitimate IP4 address
ip
<not_specific>