Class: HttpLoader::Client::Slowloris

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/http_loader/client/slowloris.rb

Overview

Handles deliberate thread-hogging Slowloris tactics.

Instance Method Summary collapse

Constructor Details

#initialize(config, logger) ⇒ Slowloris

Returns a new instance of Slowloris.



13
14
15
16
# File 'lib/http_loader/client/slowloris.rb', line 13

def initialize(config, logger)
  @config = config
  @logger = logger
end

Instance Method Details

#run(client_index, uri, http, start_time) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/http_loader/client/slowloris.rb', line 19

def run(client_index, uri, http, start_time)
  return unless @config.slowloris_delay.positive?

  # We must use T.unsafe because @socket is a protected state variable natively
  socket_wrapper = T.unsafe(http).instance_variable_get(:@socket)
  return unless socket_wrapper

  io = socket_wrapper.io
  fire_initial_payload(io, uri)
  maintain_hold(client_index, io, start_time)
end