module EthWatcher
Constants
- VERSION
Public Class Methods
spawn_threads(count:)
click to toggle source
# File lib/eth_watcher.rb, line 29 def self.spawn_threads(count:) count.times do Thread.new do loop do begin packet = PacketGen.parse(@capture.next_packet.to_s) next unless packet.headers.first.ethertype packet = packet.headers[0] @semaphore.synchronize { puts packet.src << " -> " << packet.dst } rescue # YOLO! end end end end end
start_capture(interface:, snaplen:, promisc:)
click to toggle source
# File lib/eth_watcher.rb, line 21 def self.start_capture(interface:, snaplen:, promisc:) @capture = Pcap.open_live(interface, snaplen, promisc, 0) end