Pure ruby network capture API
$ gem install pcapz
require "pcapz" # start packet capture cap = Pcapz.capture.new # CTRL+C Exit trap "SIGINT" do cap.stop! end cap.packets do |packet| # do something with packet puts packet.size end
Currently this has only been implemented/tested on macOS and Linux.
The gem is available as open source under the terms of the MIT License.