Methods
Public Class methods
[ show source ]
# File lib/net/ssh/service/agentforward/driver.rb, line 25 25: def initialize( connection, buffers, log, agent ) 26: @connection = connection 27: @buffers = buffers 28: @log = log 29: @agent = agent 30: @data = '' 31: 32: @connection.add_channel_open_handler( 33: "auth-agent@openssh.com", &method(:do_open_channel) ) 34: end
Public Instance methods
Called if we have any data to forward to the agent. Examines the accumulated data to see if we have a complete packet, based on the length field (the first four bytes as a network long).
[ show source ]
# File lib/net/ssh/service/agentforward/driver.rb, line 59 59: def call_agent 60: # if we have enough data to check the length of this packet 61: if @data.length >= 4 62: packet_length = @data[0..3].unpack('N').first 63: # send the complete packet to the agent and read the 64: # response 65: if @data.length == (4 + packet_length) 66: @agent.send_raw_packet @data 67: buffer = @agent.read_raw_packet 68: end 69: end 70: buffer 71: end
handle CHANNEL_DATA packets received on the agent-forward channel - pass complete received packets to the agent.
[ show source ]
# File lib/net/ssh/service/agentforward/driver.rb, line 46 46: def do_data( channel, data ) 47: @data = @data + data 48: reply = call_agent 49: if reply 50: channel.send_data reply 51: @data = '' 52: end 53: end
[ show source ]
# File lib/net/ssh/service/agentforward/driver.rb, line 40 40: def do_open_channel( connection, channel, data ) 41: channel.on_data &method(:do_data) 42: end
[ show source ]
# File lib/net/ssh/service/agentforward/driver.rb, line 36 36: def request 37: @connection.channel_request( 'auth-agent-req@openssh.com' ) 38: end