lib/chef_metal/transport/ssh.rb in chef-metal-0.8.2 vs lib/chef_metal/transport/ssh.rb in chef-metal-0.9

- old
+ new

@@ -102,12 +102,14 @@ def make_url_available_to_remote(local_url) uri = URI(local_url) host = Socket.getaddrinfo(uri.host, uri.scheme, nil, :STREAM)[0][3] if host == '127.0.0.1' || host == '[::1]' - # TODO IPv6 - Chef::Log.debug("Forwarding local server 127.0.0.1:#{uri.port} to port #{uri.port} on #{username}@#{host}") - session.forward.remote(uri.port, "127.0.0.1", uri.port) + unless session.forward.active_remotes.any? { |port, bind| port == uri.port && bind == '127.0.0.1' } + # TODO IPv6 + Chef::Log.debug("Forwarding local server 127.0.0.1:#{uri.port} to port #{uri.port} on #{username}@#{host}") + session.forward.remote(uri.port, '127.0.0.1', uri.port) + end end local_url end def disconnect