Included Modules

Arachni::RPC::EM::Protocol

Provides helper transport methods for `Arachni::RPC::Message` transmission.

@author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>

Constants

MAX_CHUNK_SIZE

Send a maximum of 16kb of data per tick.

Public Instance Methods

receive_data( data ) click to toggle source

Receives data from the network.

Rhe data will be chunks of a serialized object which will be buffered until the whole transmission has finished.

It will then unserialize it and pass it to {receive_object}.

# File lib/arachni/rpc/em/protocol.rb, line 40
def receive_data( data )
    # Break out early if the request is sent by an unverified peer and SSL
    # peer verification has been enabled.
    if ssl_opts? && !verified_peer? && @role == :server
        e = Arachni::RPC::Exceptions::SSLPeerVerificationFailed.new( 'Could not verify peer.' )
        send_response Response.new( :obj => {
            'exception' => e.to_s,
            'backtrace' => e.backtrace,
            'type'      => 'SSLPeerVerificationFailed'
        })

        log( :error, 'SSL', " Could not verify peer. ['#{peer_ip_addr}']." )
        return
    end

    (@buf ||= '') << data

    while @buf.size >= 4
        if @buf.size >= 4 + ( size = @buf.unpack( 'N' ).first )
            @buf.slice!( 0, 4 )
            receive_object( unserialize( @buf.slice!( 0, size ) ) )
        else
            break
        end
    end
end
send_message( msg ) click to toggle source

@param [Arachni::RPC::Message] msg

Message to send to the peer.
# File lib/arachni/rpc/em/protocol.rb, line 26
def send_message( msg )
    ::EM.schedule { send_object( msg.prepare_for_tx ) }
end
Also aliased as: send_request, send_response
send_request( msg ) click to toggle source
Alias for: send_message
send_response( msg ) click to toggle source
Alias for: send_message

[Validate]

Generated with the Darkfish Rdoc Generator 2.