def wait_for_message
loop do
type, buffer = @session.wait_for_message
case type
when USERAUTH_BANNER
message = buffer.read_string
language = buffer.read_string
if @log.debug?
@log.debug "got USERAUTH_BANNER (#{message}:#{language})"
end
@on_banner.call( message, language )
when USERAUTH_FAILURE
authentications = buffer.read_string
@allowed_auth_methods = authentications.split(/,/)
partial_success = buffer.read_bool
return OpenStruct.new( :message_type => type,
:authentications => authentications,
:partial_success => partial_success )
when USERAUTH_SUCCESS
return OpenStruct.new( :message_type => type )
when SERVICE_ACCEPT
return OpenStruct.new( :message_type => type,
:service_name => buffer.read_string )
when 60..79
return OpenStruct.new( :message_type => type,
:buffer => buffer )
else
raise Net::SSH::Exception,
"unexpected message type '#{type}' (#{buffer.to_s})"
end
end
end