module Packetz

Defined in:

packetz.cr
packetz/capture.cr
packetz/interfaces.cr
packetz/libpcap.cr
packetz/version.cr

Constant Summary

VERSION = "0.1.0"

Class Method Summary

Class Method Detail

def self.capture(interface = Packetz.interfaces.default, snapshot_length = 65535, promiscuous_mode = false, timeout_ms = 1, monitor_mode = false) #

The #capture method provides a delicious, syntactic sugar to be able to access the underlying Capture module to perform live packet captures.


[View source]
def self.capture(interface = Packetz.interfaces.default, snapshot_length = 65535, promiscuous_mode = false, timeout_ms = 1, monitor_mode = false, &) #

When the #capture method is used within a block syntax, then it can quickly start yielding packets to the underlying block. This is an optional way to start capturing packets right away.


[View source]
def self.interfaces #

The #interfaces method provides a sweet, syntactic sugar to be able to access the underlying Interfaces module for information about network interfaces.

To get the first, default ( non-loopback ) interface name on your system:

Packetz.interfaces.default
# => "eth0"

To access all of the interfaces on your system as an array:

Packetz.interfaces.all
# => ["en0", "lo0", "vboxnet0", "vboxnet1"]

To enumerate through each of the interfaces on your system:

Packetz.interfaces.each do |interface|
  puts interface
end

[View source]