plugins/providers/virtualbox/action/network.rb in vagrant-unbundled-2.3.2.0 vs plugins/providers/virtualbox/action/network.rb in vagrant-unbundled-2.3.3.0

- old
+ new

@@ -19,10 +19,12 @@ # Location of the VirtualBox networks configuration file VBOX_NET_CONF = "/etc/vbox/networks.conf".freeze # Version of VirtualBox that introduced hostonly network range restrictions HOSTONLY_VALIDATE_VERSION = Gem::Version.new("6.1.28") + # Version of VirtualBox on darwin platform that ignores restrictions + DARWIN_IGNORE_HOSTONLY_VALIDATE_VERSION = Gem::Version.new("7.0.0") # Default valid range for hostonly networks HOSTONLY_DEFAULT_RANGE = [IPAddr.new("192.168.56.0/21").freeze].freeze include Vagrant::Util::NetworkIP include Vagrant::Util::ScopedHashOverride @@ -477,14 +479,11 @@ #----------------------------------------------------------------- # Hostonly Helper Functions #----------------------------------------------------------------- # This creates a host only network for the given configuration. def hostonly_create_network(config) - @env[:machine].provider.driver.create_host_only_network( - adapter_ip: config[:adapter_ip], - netmask: config[:netmask] - ) + @env[:machine].provider.driver.create_host_only_network(config) end # This finds a matching host only network for the given configuration. def hostonly_find_matching_network(config) this_netaddr = network_address(config[:ip], config[:netmask]) if config[:ip] @@ -515,10 +514,14 @@ # ranges. It only validates if the network configuration file exists. # This was introduced in 6.1.28 so previous version won't have restrictions # placed on the valid ranges def validate_hostonly_ip!(ip, driver) return if Gem::Version.new(driver.version) < HOSTONLY_VALIDATE_VERSION || - Vagrant::Util::Platform.windows? + ( + Vagrant::Util::Platform.darwin? && + Gem::Version.new(driver.version) >= DARWIN_IGNORE_HOSTONLY_VALIDATE_VERSION + ) || + Vagrant::Util::Platform.windows? ip = IPAddr.new(ip.to_s) if !ip.is_a?(IPAddr) valid_ranges = load_net_conf return if valid_ranges.any?{ |range| range.include?(ip) } raise Vagrant::Errors::VirtualBoxInvalidHostSubnet,