Created
September 8, 2012 17:45
-
-
Save Leechael/3677837 to your computer and use it in GitHub Desktop.
Added `:both` support for forward_port protocol configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- virtualbox_4_1.rb.orig 2012-09-09 01:24:56.000000000 +0800 | |
+++ virtualbox_4_1.rb 2012-09-09 01:39:32.000000000 +0800 | |
@@ -135,15 +135,22 @@ | |
def forward_ports(ports) | |
args = [] | |
ports.each do |options| | |
- pf_builder = [options[:name], | |
- options[:protocol] || "tcp", | |
- "", | |
- options[:hostport], | |
- "", | |
- options[:guestport]] | |
+ protocols = { | |
+ :both => ["tcp", "udp"], | |
+ :tcp => ["tcp"], | |
+ :udp => ["udp"] | |
+ } | |
+ protocols[options[:protocol] || :tcp].each do |protocol| | |
+ pf_builder = [protocol + options[:name], | |
+ protocol, | |
+ "", | |
+ options[:hostport], | |
+ "", | |
+ options[:guestport]] | |
- args.concat(["--natpf#{options[:adapter] || 1}", | |
- pf_builder.join(",")]) | |
+ args.concat(["--natpf#{options[:adapter] || 1}", | |
+ pf_builder.join(",")]) | |
+ end | |
end | |
execute("modifyvm", @uuid, *args) if !args.empty? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment