Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Commit

Permalink
Fixed a bug in discovery agents.
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Feb 16, 2016
1 parent 16b3499 commit 741ce92
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/bettercap/discovery/agents/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def initialize( ctx, address = nil )
ip = ip.succ
end
else
unless skip_address?(@address)
if skip_address?(@address)
Logger.debug "Skipping #{@address} ..."
else
Logger.debug "Probing #{@address} ..."
@ctx.packets.push( get_probe(@address) )
end
end
Expand All @@ -46,11 +49,20 @@ def initialize( ctx, address = nil )
# Return true if +ip+ must be skipped during discovery, otherwise false.
def skip_address?(ip)
# don't send probes to the gateway
( ip == @ctx.gateway or \
# don't send probes to our device
ip == @local_ip or \
# don't stress endpoints we already discovered
!@ctx.find_target( ip.to_s, nil ).nil? )
if ip == @ctx.gateway
return true
# don't send probes to our device
elsif ip == @local_ip
return true
# don't stress endpoints we already discovered
else
target = @ctx.find_target( ip.to_s, nil )
# known target?
return false if target.nil?
# do we still need to get the mac for this target?
return ( target.mac.nil?? false : true )
end

end

# Each Discovery::Agent::Base derived class should implement this method.
Expand Down

0 comments on commit 741ce92

Please sign in to comment.