Class: VagrantPlugins::Skytap::Model::ForwardedPort
- Defined in:
- lib/vagrant-skytap/model/forwarded_port.rb
Overview
This is based on code from the VirtualBox provider.
Instance Attribute Summary collapse
-
#auto_correct ⇒ Boolean
readonly
If true, this port should be auto-corrected.
-
#guest_ip ⇒ String
readonly
The IP that the forwarded port will connect to on the guest machine.
-
#guest_port ⇒ Integer
readonly
The port on the guest to be exposed on the host.
-
#host_ip ⇒ String
readonly
The IP that the forwarded port will bind to on the host machine.
-
#host_port ⇒ Integer
readonly
The port on the host used to access the port on the guest.
-
#id ⇒ String
readonly
The unique ID for the forwarded port.
-
#protocol ⇒ String
readonly
The protocol to forward.
Instance Method Summary collapse
-
#correct_host_port(new_port) ⇒ Object
This corrects the host port and changes it to the given new port.
-
#initialize(id, host_port, guest_port, options) ⇒ ForwardedPort
constructor
A new instance of ForwardedPort.
-
#internal_ssh_port? ⇒ Boolean
Returns true if this is the SSH port used internally by Vagrant.
-
#privileged_host_port? ⇒ Boolean
Returns true if the host port is privileged.
Constructor Details
#initialize(id, host_port, guest_port, options) ⇒ ForwardedPort
Returns a new instance of ForwardedPort.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 63 def initialize(id, host_port, guest_port, ) @id = id @guest_port = guest_port @host_port = host_port ||= {} @auto_correct = false @auto_correct = [:auto_correct] if .key?(:auto_correct) @guest_ip = [:guest_ip] || nil @host_ip = [:host_ip] || nil @protocol = [:protocol] || "tcp" end |
Instance Attribute Details
#auto_correct ⇒ Boolean (readonly)
If true, this port should be auto-corrected.
31 32 33 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 31 def auto_correct @auto_correct end |
#guest_ip ⇒ String (readonly)
The IP that the forwarded port will connect to on the guest machine.
46 47 48 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 46 def guest_ip @guest_ip end |
#guest_port ⇒ Integer (readonly)
The port on the guest to be exposed on the host.
51 52 53 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 51 def guest_port @guest_port end |
#host_ip ⇒ String (readonly)
The IP that the forwarded port will bind to on the host machine.
56 57 58 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 56 def host_ip @host_ip end |
#host_port ⇒ Integer (readonly)
The port on the host used to access the port on the guest.
61 62 63 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 61 def host_port @host_port end |
#id ⇒ String (readonly)
The unique ID for the forwarded port.
36 37 38 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 36 def id @id end |
#protocol ⇒ String (readonly)
The protocol to forward.
41 42 43 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 41 def protocol @protocol end |
Instance Method Details
#correct_host_port(new_port) ⇒ Object
This corrects the host port and changes it to the given new port.
79 80 81 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 79 def correct_host_port(new_port) @host_port = new_port end |
#internal_ssh_port? ⇒ Boolean
Returns true if this is the SSH port used internally by Vagrant.
94 95 96 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 94 def internal_ssh_port? (guest_port == 22 && host_port == 2222) || id == "ssh" end |
#privileged_host_port? ⇒ Boolean
Returns true if the host port is privileged.
86 87 88 |
# File 'lib/vagrant-skytap/model/forwarded_port.rb', line 86 def privileged_host_port? host_port <= 1024 end |