<commit_before>
Hellopacket
===========

Introduction
------------
Every language implements its own "helloworld".
Haka is a language, therefore here is its own helloworld called
"hellopacket".

This "hellopacket" reads a pcap file, then print some tcp/ip packet fields.

How-to
------
Launch ``hakapcap`` with pcapfile and lua script file as arguments.

.. parsed-literal::

    $ cd |haka_install_path|/share/haka/sample/tutorial/hellopacket
    $ hakapcap hellopacket.pcap hellopacket.lua

Hakacap will process the pcap file accordingly to lua configfile, you will see at
first some infos about the starting of haka, then the packets and stream found in
pcap file:

.. code-block:: bash

    info  core: load module 'packet/pcap.ho'
        Pcap Module, Arkoon Network Security
    info  core: loading rule file 'hellopacket.lua'
    info  core: initializing thread 0
    info  pcap: openning file 'hellopacket.pcap'
    info  core: registering new dissector: 'ipv4'
    info  core: registering new dissector: 'tcp'
    info  core: registering new dissector: 'tcp-connection'
    info  core: 1 rule(s) on hook 'ipv4-up'
    info  core: 1 rule(s) on hook 'tcp-connection-new'
    info  core: 2 rule(s) registered
    
    info  core: starting single threaded processing
    
    info  debug: Hello packet from 192.168.10.1 to 192.168.10.99
    info  debug: Hello TCP connection from 192.168.10.1:47161 to 192.168.10.99:3000
    info  debug: Hello packet from 192.168.10.99 to 192.168.10.1
    info  debug: Hello packet from 192.168.10.1 to 192.168.10.99
    info  debug: Hello packet from 192.168.10.1 to 192.168.10.99
    info  debug: Hello packet from 192.168.10.99 to 192.168.10.1
    info  debug: Hello packet from 192.168.10.1 to 192.168.10.99
    info  debug: Hello packet from 192.168.10.99 to 192.168.10.1
    info  debug: Hello packet from 192.168.10.1 to 192.168.10.99
    info  core:  unload module 'Pcap Module'

We can see each packet and TCP connection saying hello to the world.
You can open the pcap file with wireshark or any other network tool to see the same informations.

The lua config file is self-documented:

.. literalinclude:: ../../../sample/tutorial/hellopacket/hellopacket.lua
   :language: lua
   :tab-width: 4

Haka is very powerful because all of these fields can be used through the lua programming language
without any limit.
<commit_msg>Add color for output in hellopacket doc<commit_after>
Hellopacket
===========

Introduction
------------
Every language implements its own "helloworld".
Haka is a language, therefore here is its own helloworld called
"hellopacket".

This "hellopacket" reads a pcap file, then print some tcp/ip packet fields.

How-to
------
Launch ``hakapcap`` with pcapfile and lua script file as arguments.

.. parsed-literal::

    $ cd |haka_install_path|/share/haka/sample/tutorial/hellopacket
    $ hakapcap hellopacket.pcap hellopacket.lua

Hakacap will process the pcap file accordingly to lua configfile, you will see at
first some infos about the starting of haka, then the packets and stream found in
pcap file:

.. ansi-block::
    :string_escape:

    \x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0mload module 'packet/pcap.ho'
        Pcap Module, Arkoon Network Security
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0mloading rule file 'hellopacket.lua'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0minitializing thread 0
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mpcap:\x1b[0m \x1b[0mopenning file 'hellopacket.pcap'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0mregistering new dissector: 'ipv4'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0mregistering new dissector: 'tcp'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0mregistering new dissector: 'tcp-connection'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0m1 rule(s) on hook 'ipv4-up'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0m1 rule(s) on hook 'tcp-connection-new'
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0m2 rule(s) registered
    
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m \x1b[0mstarting single threaded processing
    
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.1 to 192.168.10.99
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mTCP connection from 192.168.10.1:47161 to 192.168.10.99:3000
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.99 to 192.168.10.1
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.1 to 192.168.10.99
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.1 to 192.168.10.99
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.99 to 192.168.10.1
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.1 to 192.168.10.99
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.99 to 192.168.10.1
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mHello:\x1b[0m \x1b[0mpacket from 192.168.10.1 to 192.168.10.99
    \x1b[0m\x1b[1minfo\x1b[0m  \x1b[36mcore:\x1b[0m  \x1b[0munload module 'Pcap Module'
    \x1b[0m


We can see each packet and TCP connection saying hello to the world.
You can open the pcap file with wireshark or any other network tool to see the same informations.

The lua config file is self-documented:

.. literalinclude:: ../../../sample/tutorial/hellopacket/hellopacket.lua
   :language: lua
   :tab-width: 4

Haka is very powerful because all of these fields can be used through the lua programming language
without any limit.

{'fraction_non_alphanumeric': 0.12079348211122919, 'fraction_numerical': 0.11459440311725115, 'mean_word_length': 3.425548589341693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 36, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '237901', 'n_tokens_mistral': 2658, 'n_tokens_neox': 2346, 'n_words': 586}