Module: EthWatcher
- Defined in:
- lib/eth_watcher.rb,
lib/eth_watcher/version.rb
Constant Summary collapse
- VERSION =
"1.0.5"
Class Method Summary collapse
Class Method Details
.spawn_threads(count:) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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:) ⇒ Object
21 22 23 |
# File 'lib/eth_watcher.rb', line 21 def self.start_capture(interface:, snaplen:, promisc:) @capture = Pcap.open_live(interface, snaplen, promisc, 0) end |