Sha256: 5958f54ba43612adf92bfb01234400dc0368dcd7c84e33033ea9b18a0622735c

Contents?: true

Size: 1.95 KB

Versions: 62

Compression:

Stored size: 1.95 KB

Contents

module VagrantPlugins
  module ProviderVirtualBox
    module Model
      # Represents a single forwarded port for VirtualBox. This has various
      # helpers and defaults for a forwarded port.
      class ForwardedPort
        # The NAT adapter on which to attach the forwarded port.
        #
        # @return [Integer]
        attr_reader :adapter

        # If true, this port should be auto-corrected.
        #
        # @return [Boolean]
        attr_reader :auto_correct

        # The unique ID for the forwarded port.
        #
        # @return [String]
        attr_reader :id

        # The protocol to forward.
        #
        # @return [String]
        attr_reader :protocol

        # The IP that the forwarded port will connect to on the guest machine.
        #
        # @return [String]
        attr_reader :guest_ip

        # The port on the guest to be exposed on the host.
        #
        # @return [Integer]
        attr_reader :guest_port

        # The IP that the forwarded port will bind to on the host machine.
        #
        # @return [String]
        attr_reader :host_ip

        # The port on the host used to access the port on the guest.
        #
        # @return [Integer]
        attr_reader :host_port

        def initialize(id, host_port, guest_port, options)
          @id         = id
          @guest_port = guest_port
          @host_port  = host_port

          options ||= {}
          @auto_correct = false
          @auto_correct = options[:auto_correct] if options.key?(:auto_correct)
          @adapter  = (options[:adapter] || 1).to_i
          @guest_ip = options[:guest_ip] || nil
          @host_ip = options[:host_ip] || nil
          @protocol = options[:protocol] || "tcp"
        end

        # This corrects the host port and changes it to the given new port.
        #
        # @param [Integer] new_port The new port
        def correct_host_port(new_port)
          @host_port = new_port
        end
      end
    end
  end
end

Version data entries

62 entries across 55 versions & 7 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/providers/virtualbox/model/forwarded_port.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.3.3.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.3.2.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.19.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.18.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.16.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.14.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.10.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.9.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.8.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.7.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.6.2 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.6.1 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.6.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.5.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.4.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.3.0 plugins/providers/virtualbox/model/forwarded_port.rb
vagrant-unbundled-2.2.2.0 plugins/providers/virtualbox/model/forwarded_port.rb