Class TbxSniffer

An object that will intercept packets

Methods

TbxSniffer:new (key) Constructs a new TbxSniffer
TbxSniffer:sniffer_callback (pkt) The callback function for the sniffer
TbxSniffer:start ([cb]) Start sniffing and calls the callback function for each new packet.
TbxSniffer:stop () Stop sniffing
TbxSniffer:recv ([timeout]) Receive a packet


Methods

TbxSniffer:new (key)
Constructs a new TbxSniffer

Parameters:

  • key table a list of arguments that will be passed to iptables

Returns:

    TbxSniffer

Usage:

    TbxSniffer.new({'-p', 'tcp', '--dport', '80'}, callback_func)
TbxSniffer:sniffer_callback (pkt)
The callback function for the sniffer

Parameters:

  • pkt Packet the received packet

Returns:

    num x any value but 0 will stop the Sniffer
TbxSniffer:start ([cb])
Start sniffing and calls the callback function for each new packet. Will never return unless stop is called from another thread or if it was started in non-blocking mode.

Parameters:

  • cb function a function callback, see sniffer_callback, to operate in blokcing mode. Omit to be non-blocking. (optional)
TbxSniffer:stop ()
Stop sniffing
TbxSniffer:recv ([timeout])
Receive a packet

Parameters:

  • timeout num number of second to wait, can be decimal, or omit to block (optional)

Returns:

    Packet p the received packet, or nil if timed out
generated by LDoc 1.4.6 Last updated 2017-10-04 11:48:45