Class: Capistrano::Configuration::Connections::GatewayConnectionFactory
- Inherits:
-
Object
- Object
- Capistrano::Configuration::Connections::GatewayConnectionFactory
- Defined in:
- lib/capistrano/configuration/connections.rb
Overview
:nodoc:
Instance Method Summary collapse
- #connect_to(server) ⇒ Object
-
#initialize(gateway, options) ⇒ GatewayConnectionFactory
constructor
A new instance of GatewayConnectionFactory.
Constructor Details
#initialize(gateway, options) ⇒ GatewayConnectionFactory
Returns a new instance of GatewayConnectionFactory.
25 26 27 28 29 30 31 32 33 |
# File 'lib/capistrano/configuration/connections.rb', line 25 def initialize(gateway, ) Thread.abort_on_exception = true server = ServerDefinition.new(gateway) @options = @gateway = SSH.connection_strategy(server, ) do |host, user, | Net::SSH::Gateway.new(host, user, ) end end |
Instance Method Details
#connect_to(server) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/capistrano/configuration/connections.rb', line 35 def connect_to(server) @options[:logger].debug "establishing connection to `#{server}' via gateway" if @options[:logger] local_host = ServerDefinition.new("127.0.0.1", :user => server.user, :port => @gateway.open(server.host, server.port || 22)) session = SSH.connect(local_host, @options) session.xserver = server @options[:logger].trace "connected: `#{server}' (via gateway)" if @options[:logger] session end |