From 72b249fd190990076b73c7e69ace7ff3cd9d10c9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 25 Dec 2011 15:36:15 -0800 Subject: [PATCH] Do port forwarding threshold check in the `call` method --- lib/vagrant/action/vm/forward_ports.rb | 29 +++++++++++--------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/vagrant/action/vm/forward_ports.rb b/lib/vagrant/action/vm/forward_ports.rb index de8a0fe7c..1e9bb6da2 100644 --- a/lib/vagrant/action/vm/forward_ports.rb +++ b/lib/vagrant/action/vm/forward_ports.rb @@ -4,15 +4,22 @@ module Vagrant class ForwardPorts def initialize(app,env) @app = app - @env = env - - threshold_check end #-------------------------------------------------------------- - # Prepare Helpers - These functions are not involved in actually - # executing the action + # Execution #-------------------------------------------------------------- + def call(env) + @env = env + + # Warn if we're port forwarding to any privileged ports... + threshold_check + + env[:ui].info I18n.t("vagrant.actions.vm.forward_ports.forwarding") + forward_ports(env[:vm]) + + @app.call(env) + end # This method checks for any forwarded ports on the host below # 1024, which causes the forwarded ports to fail. @@ -25,18 +32,6 @@ module Vagrant end end - #-------------------------------------------------------------- - # Execution - #-------------------------------------------------------------- - def call(env) - @env = env - - env[:ui].info I18n.t("vagrant.actions.vm.forward_ports.forwarding") - forward_ports(env[:vm]) - - @app.call(env) - end - def forward_ports(vm) ports = []