lib/wmap/utils/utils.rb
# Simple test to determine if the entry is in valid network cidr format
Simple test to determine if the entry is in valid network cidr format
Simple test to determine if the entry is in valid network cidr format
def is_cidr?(cidr)
		puts "Validate if the entry is valid CIDR format: #{cidr}" if @verbose
		begin
		cidr=cidr.strip
			if cidr =~  /^(\d+\.\d+\.\d+.\d+)\/(\d+)$/
				ip=$1
				mask=$2.to_i
				if is_ip?(ip)
					if mask >0 and mask <=32
						puts "confirmed as a valid CIDR entry: #{cidr}" if @verbose
						return true
					else
						return false
					end
				else
					return false
				end
			else
				return false
			end
		rescue => ee
			puts "Exception on method #{__method__}: #{ee}" if @verbose
			return false
		end
	end
def is_cidr? ( cidr ) puts "Validate if the entry is valid CIDR format: #{cidr}" if @verbose begin cidr = cidr . strip if cidr =~ / ^( \d + \. \d + \. \d +. \d +) \/ ( \d +)$ / ip = $1 mask = $2 . to_i if is_ip? ( ip ) if mask > 0 and mask <= 32 puts "confirmed as a valid CIDR entry: #{cidr}" if @verbose return true else return false end else return false end else return false end rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose return false end end
Simple test to determine if the entry is in valid network cidr format
Simple test to determine if the entry is in valid network cidr format
cidr
<not_specific>