8. Console

The console allows to execute and interact with a running haka daemon. It is possible to get some statistics or to drop a connection for instance.

8.1. Starting the console

The console is started using hakactl console. On connection, a prompt allows to write Lua commands. The completion is also available to guide the user and list the available functions.

This section provides the list of all available commands.

8.2. Returned data

Most functions return an object containing all requested data. This object named List have many features to enable advanced scripting.

object List

Collection of elements.

<List>[field] → value
Parameters:
  • field (string) – Field to retrieve.
Returns:
  • value – Value for the field.

Get a field value for the given field.

<List>:get(key) → list
Parameters:
  • key – Key to retrieve.
Returns:
  • list (List) – New list containing only the requested element.

Select only one element from a list.

<List>:filter(f) → list
Parameters:
  • f (function) – Function returning true for element to keep.
Returns:
  • list (List) – New list containing only the element not filtered out.

Filter out and only keep some elements of the list.

The function f follows this prototype:

f(elem) → should_keep
<List>:sort(order, invert=false) → list
Parameters:
  • order (string or function) – String of the field to use for sorting or order function.
  • invert (boolean) – Invert the result.
Returns:
  • list (List) – New list containing only the element not filtered out.

Sort the element of the list.

This object is used by various console commands. Each of them will list the available fields as well as the extra method available when it is the case.

8.3. General utilities

threads() → list
Returns:
  • list (List) – Threads information.

Get information about the haka threads (id, packet statistics, byte statistics...).

rules() → list
Returns:
  • list (List) – Rules information.

Get information about the loaded rules (name, event...).

events() → list
Returns:
  • list (List) – Events information.

Get information about all events registered in haka.

setloglevel(level[, module])
Parameters:
  • level (string) – Log level ('debug', 'info', 'warning', 'error' or 'fatal').
  • module (string) – Module name if needed.

Change the logging level of haka.

stop()

Cleanly stop the running haka.

8.4. Protocol utilities

8.4.1. UDP

udp.connections(show_dropped=false) → list
Parameters:
  • show_dropped (boolean) – true if also the dropped connections should be listed.
Returns:

Get information about all udp connections currently known in haka (ips, ports, statistics, state...).

Some extra method are available on this list:

object UdpConnList
Extends:List 
<UdpConnList>:drop()

Drop all connections that are part of the list. This can be used to drop one connection or more.

8.4.2. TCP

tcp.connections(show_dropped=false) → list
Parameters:
  • show_dropped (boolean) – true if also the dropped connections should be listed.
Returns:

Get information about all tcp connections currently known in haka (ips, ports, statistics, state...).

Some extra method are available on this list:

object TcpConnList
Extends:List 
<TcpConnList>:drop()

Drop all connections that are part of the list. This can be used to drop one connection or more.

<TcpConnList>:reset()

Reset all connections that are part of the list. This can be used to reset one connection or more.