Class: BetterCap::Discovery::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/bettercap/discovery/thread.rb

Overview

Class responsible to actively discover targets on the network.

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ Thread

Initialize the class using the ctx BetterCap::Context instance.


18
19
20
21
22
# File 'lib/bettercap/discovery/thread.rb', line 18

def initialize( ctx )
  @ctx     = ctx
  @running = false
  @thread  = nil
end

Instance Method Details

#startObject

Start the active network discovery thread.


25
26
27
28
# File 'lib/bettercap/discovery/thread.rb', line 25

def start
  @running = true
  @thread  = ::Thread.new { worker }
end

#stopObject

Stop the active network discovery thread.


31
32
33
34
35
36
37
38
39
40
# File 'lib/bettercap/discovery/thread.rb', line 31

def stop
  @running = false
  if @thread != nil
    Logger.info( 'Stopping network discovery thread ...' ) unless @ctx.options.core.arpcache
    begin
      @thread.exit
    rescue
    end
  end
end