Class: Nonnative::InvalidDataSocketPair

Inherits:
SocketPair
  • Object
show all
Defined in:
lib/nonnative/invalid_data_socket_pair.rb

Overview

Socket-pair variant used by the fault-injection proxy to simulate corrupted/incoherent traffic.

When active, data written to the upstream socket is corrupted by shuffling the characters in the payload before forwarding.

This behavior is enabled by calling FaultInjectionProxy#invalid_data.

Instance Method Summary collapse

Methods inherited from SocketPair

#connect, #initialize

Constructor Details

This class inherits a constructor from Nonnative::SocketPair

Instance Method Details

#write(socket, data) ⇒ Integer

Writes corrupted data to the socket by shuffling characters.

Parameters:

  • socket (IO)

    the socket to write to

  • data (String)

    the original payload

Returns:

  • (Integer)

    number of bytes written



20
21
22
23
24
25
26
# File 'lib/nonnative/invalid_data_socket_pair.rb', line 20

def write(socket, data)
  Nonnative.logger.info "shuffling socket data '#{socket.inspect}' for 'invalid_data' pair"

  data = data.chars.shuffle.join

  super
end