Provides helper transport methods for `Arachni::RPC::Message` transmission.
@author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
Send a maximum of 16kb of data per tick.
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
@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
Generated with the Darkfish Rdoc Generator 2.