Sha256: 3e455796bb5cbacf87f2421bf43215fda11f19bd9bf73eddd7324c2cdc7fb5d7
Contents?: true
Size: 607 Bytes
Versions: 10
Compression:
Stored size: 607 Bytes
Contents
require "ipaddr" module Vagrant module Util module NetworkIP DEFAULT_MASK = "255.255.255.0".freeze LOGGER = Log4r::Logger.new("vagrant::util::NetworkIP") # Returns the network address of the given IP and subnet. # # @return [String] def network_address(ip, subnet) begin IPAddr.new(ip).mask(subnet).to_s rescue IPAddr::InvalidPrefixError LOGGER.warn("Provided mask '#{subnet}' is invalid. Falling back to using mask '#{DEFAULT_MASK}'") IPAddr.new(ip).mask(DEFAULT_MASK).to_s end end end end end
Version data entries
10 entries across 10 versions & 3 rubygems