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.


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

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

Instance Method Details

#startObject

Start the active network discovery thread.


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

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

#stopObject

Stop the active network discovery thread.


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

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