Skip to content

Commit 0744bcf

Browse files
authored
Merge pull request #48 from CESNET/devel
Bump version to 2.2.0
2 parents 5515554 + 1749984 commit 0744bcf

File tree

123 files changed

+12801
-825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+12801
-825
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
image: ['ubuntu:18.04', 'ubuntu:19.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye', 'centos:7', 'centos:8', 'fedora:29', 'fedora:30', 'fedora:31']
18+
image: ['ubuntu:18.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye', 'centos:7', 'centos:8']
1919

2020
name: Build on ${{ matrix.image }}
2121
container: ${{ matrix.image }}
@@ -29,18 +29,26 @@ jobs:
2929
apt-get update
3030
apt-get -y install git gcc g++ cmake make libxml2-dev liblz4-dev libzstd-dev
3131
apt-get -y install python3-docutils zlib1g-dev pkg-config
32+
apt-get -y install librdkafka-dev
33+
env:
34+
DEBIAN_FRONTEND: noninteractive
35+
- name: Enable additional repositories (CentOS 8)
36+
if: startsWith(matrix.image, 'centos:8')
37+
run: |
38+
dnf -y install 'dnf-command(config-manager)'
39+
dnf config-manager --set-enabled appstream powertools
3240
- name: Install dependencies for libfds and IPFIXcol2 (CentOS)
3341
if: startsWith(matrix.image, 'centos')
3442
run: |
3543
yum -y install epel-release
3644
yum -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
37-
yum -y install zlib-devel pkgconfig
45+
yum -y install zlib-devel pkgconfig librdkafka-devel
3846
yum -y install python3-docutils || yum -y install python-docutils
39-
- name: Install depedencies for libfds and IPFIXcol2 (Fedora)
47+
- name: Install dependencies for libfds and IPFIXcol2 (Fedora)
4048
if: startsWith(matrix.image, 'fedora')
4149
run: |
4250
dnf -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
43-
dnf -y install python3-docutils zlib-devel pkgconfig
51+
dnf -y install python3-docutils zlib-devel pkgconfig librdkafka-devel
4452
4553
# Build libfds library ------------------------------------------------------------------
4654
# Note: Master against master branch. Otherwise against debug branch.

.github/workflows/packages.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
image: ['ubuntu:18.04', 'ubuntu:19.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye']
19+
image: ['ubuntu:18.04', 'ubuntu:20.04', 'debian:stretch', 'debian:buster', 'debian:bullseye']
2020

2121
name: Build DEBs on ${{ matrix.image }}
2222
container: ${{ matrix.image }}
2323

2424
steps:
2525
- uses: actions/checkout@v1
2626
- name: Define global variables
27-
run: echo "::set-output name=zip_file::libfds-${IMAGE//:/}-$GITHUB_SHA.zip"
27+
run: echo "::set-output name=zip_file::ipfixcol2-${IMAGE//:/}-$GITHUB_SHA.zip"
2828
shell: bash
2929
env:
3030
IMAGE: ${{ matrix.image }}
@@ -35,8 +35,10 @@ jobs:
3535
run: |
3636
apt-get update
3737
apt-get -y install git gcc g++ cmake make libxml2-dev liblz4-dev libzstd-dev
38-
apt-get -y install python3-docutils zlib1g-dev pkg-config
38+
apt-get -y install python3-docutils zlib1g-dev pkg-config librdkafka-dev
3939
apt-get -y install debhelper devscripts build-essential fakeroot zip
40+
env:
41+
DEBIAN_FRONTEND: noninteractive
4042

4143
# Build LIBFDS DEB package ---------------------------------------------------------------
4244
- name: Checkout libfds library - master branch
@@ -83,7 +85,7 @@ jobs:
8385
strategy:
8486
fail-fast: false
8587
matrix:
86-
image: ['centos:7', 'centos:8', 'fedora:29', 'fedora:30', 'fedora:31']
88+
image: ['centos:7', 'centos:8']
8789

8890
name: Build RPMs on ${{ matrix.image }}
8991
container: ${{ matrix.image }}
@@ -92,25 +94,30 @@ jobs:
9294
- uses: actions/checkout@v1
9395
- name: Prepare environment and variables
9496
run: |
95-
echo "::set-output name=zip_file::libfds-${IMAGE//:/}-$GITHUB_SHA.zip"
97+
echo "::set-output name=zip_file::ipfixcol2-${IMAGE//:/}-$GITHUB_SHA.zip"
9698
mkdir -p build/libfds_repo
9799
env:
98100
IMAGE: ${{ matrix.image }}
99101
id: vars
100102

101103
# Dependencies ---------------------------------------------------------------------------
104+
- name: Enable additional repositories (CentOS 8)
105+
if: startsWith(matrix.image, 'centos:8')
106+
run: |
107+
dnf -y install 'dnf-command(config-manager)'
108+
dnf config-manager --set-enabled appstream powertools
102109
- name: Install dependencies for libfds and IPFIXcol2 (CentOS)
103110
if: startsWith(matrix.image, 'centos')
104111
run: |
105112
yum -y install epel-release
106113
yum -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
107-
yum -y install zlib-devel pkgconfig rpm-build
114+
yum -y install zlib-devel pkgconfig rpm-build librdkafka-devel
108115
yum -y install python3-docutils || yum -y install python-docutils
109116
- name: Install depedencies for libfds and IPFIXcol2 (Fedora)
110117
if: startsWith(matrix.image, 'fedora')
111118
run: |
112119
dnf -y install git gcc gcc-c++ cmake make libxml2-devel lz4-devel libzstd-devel
113-
dnf -y install python3-docutils zlib-devel pkgconfig rpm-build
120+
dnf -y install python3-docutils zlib-devel pkgconfig rpm-build librdkafka-devel
114121
115122
# Build LIBFDS RPM package ---------------------------------------------------------------
116123
- name: Checkout libfds library - master branch

CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ endif()
1414

1515
# Versions and other informations
1616
set(IPFIXCOL_VERSION_MAJOR 2)
17-
set(IPFIXCOL_VERSION_MINOR 1)
17+
set(IPFIXCOL_VERSION_MINOR 2)
1818
set(IPFIXCOL_VERSION_PATCH 0)
1919
set(IPFIXCOL_VERSION
2020
${IPFIXCOL_VERSION_MAJOR}.${IPFIXCOL_VERSION_MINOR}.${IPFIXCOL_VERSION_PATCH})
@@ -38,6 +38,8 @@ if (NOT COMPILER_SUPPORT_GNUXX11)
3838
message(FATAL_ERROR "Compiler does NOT support C++11 with GNU extension")
3939
endif()
4040

41+
42+
4143
# ------------------------------------------------------------------------------
4244
# Set default build type if not specified by user
4345
set(DEFAULT_BUILD_TYPE "Release")
@@ -76,6 +78,23 @@ if (ENABLE_TESTS AND ENABLE_TESTS_COVERAGE)
7678
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
7779
endif()
7880

81+
## -----------------------------------------------------------------------------
82+
# Find libfds
83+
find_package(LibFds 0.2.0 REQUIRED)
84+
85+
# Find rst2man
86+
if (ENABLE_DOC_MANPAGE)
87+
find_package(Rst2Man)
88+
if (NOT RST2MAN_FOUND)
89+
message(FATAL_ERROR "rst2man is not available")
90+
endif()
91+
endif()
92+
93+
# Find pthreads
94+
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
95+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
96+
find_package(Threads REQUIRED)
97+
7998
# ------------------------------------------------------------------------------
8099
# Project components
81100
add_subdirectory(include)
@@ -86,6 +105,7 @@ add_subdirectory(pkg)
86105
if (ENABLE_TESTS)
87106
enable_testing()
88107
add_subdirectory(tests/unit)
108+
add_subdirectory(tests/modules)
89109
endif()
90110

91111
# ------------------------------------------------------------------------------

CMakeModules/FindLibRDKafka.cmake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# LIBRDKAFKA_FOUND - System has librdkafka
2+
# LIBRDKAFKA_INCLUDE_DIRS - The librdkafka include directories
3+
# LIBRDKAFKA_LIBRARIES - The libraries needed to use librdkafka
4+
# LIBRDKAFKA_DEFINITIONS - Compiler switches required for using librdkafka
5+
6+
# use pkg-config to get the directories and then use these values
7+
# in the find_path() and find_library() calls
8+
find_package(PkgConfig)
9+
if (PKG_CONFIG_FOUND)
10+
pkg_check_modules(PC_RDKAFKA QUIET rdkafka)
11+
set(LIBRDKAFKA_DEFINITIONS ${PC_RDKAFKA_CFLAGS_OTHER})
12+
endif()
13+
14+
find_path(
15+
KAFKA_INCLUDE_DIR librdkafka/rdkafka.h
16+
HINTS ${PC_RDKAFKA_INCLUDEDIR} ${PC_RDKAFKA_INCLUDE_DIRS}
17+
PATH_SUFFIXES include
18+
)
19+
20+
find_library(
21+
KAFKA_LIBRARY NAMES rdkafka librdkafka
22+
HINTS ${PC_RDKAFKA_LIBDIR} ${PC_RDKAFKA_LIBRARY_DIRS}
23+
PATH_SUFFIXES lib lib64
24+
)
25+
26+
if (PC_RDKAFKA_VERSION)
27+
# Version extracted from pkg-config
28+
set(KAFKA_VERSION_STRING ${PC_RDKAFKA_VERSION})
29+
elseif(KAFKA_INCLUDE_DIR AND KAFKA_LIBRARY)
30+
# Try to get the version of the installed library
31+
try_run(
32+
KAFKA_RES_RUN KAFKA_RES_COMP
33+
${CMAKE_CURRENT_BINARY_DIR}/try_run/kafka_version_test/
34+
${PROJECT_SOURCE_DIR}/CMakeModules/try_run/kafka_version.c
35+
CMAKE_FLAGS
36+
-DLINK_LIBRARIES=${KAFKA_LIBRARY}
37+
-DINCLUDE_DIRECTORIES=${KAFKA_INCLUDE_DIR}
38+
RUN_OUTPUT_VARIABLE KAFKA_VERSION_VAR
39+
)
40+
41+
if (KAFKA_RES_COMP AND KAFKA_RES_RUN EQUAL 0)
42+
# Successfully compiled and executed with return code 0
43+
set(KAFKA_VERSION_STRING ${KAFKA_VERSION_VAR})
44+
endif()
45+
endif()
46+
47+
# handle the QUIETLY and REQUIRED arguments and set LIBRDKAFKA_FOUND to TRUE
48+
# if all listed variables are TRUE
49+
include(FindPackageHandleStandardArgs)
50+
find_package_handle_standard_args(LibRDKafka
51+
REQUIRED_VARS KAFKA_LIBRARY KAFKA_INCLUDE_DIR
52+
VERSION_VAR KAFKA_VERSION_STRING
53+
)
54+
55+
set(LIBRDKAFKA_LIBRARIES ${KAFKA_LIBRARY})
56+
set(LIBRDKAFKA_INCLUDE_DIRS ${KAFKA_INCLUDE_DIR})
57+
mark_as_advanced(KAFKA_INCLUDE_DIR KAFKA_LIBRARY)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <librdkafka/rdkafka.h>
2+
#include <stdio.h>
3+
4+
int
5+
main(int argc, char *argv[])
6+
{
7+
const char *ver_str = rd_kafka_version_str();
8+
if (!ver_str) {
9+
return 1;
10+
}
11+
12+
printf("%s", ver_str);
13+
return 0;
14+
}

README.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,28 @@ No problem, pick any combination of plugins.
2929
Available plugins
3030
-----------------
3131

32-
**Input plugins** - receive IPFIX data. Each can be configured to to listen on a specific
32+
**Input plugins** - receive NetFlow/IPFIX data. Each can be configured to listen on a specific
3333
network interface and a port. Multiple instances of these plugins can run concurrently.
3434

35-
- `UDP <src/plugins/input/udp>`_ - receives NetFlow v5/v9 and IPFIX over UDP
36-
- `TCP <src/plugins/input/tcp>`_ - receives IPFIX over TCP
35+
- `UDP <src/plugins/input/udp>`_ - receive NetFlow v5/v9 and IPFIX over UDP
36+
- `TCP <src/plugins/input/tcp>`_ - receive IPFIX over TCP
37+
- `FDS File <src/plugins/input/fds>`_ - read flow data from FDS File (efficient long-term storage)
38+
- `IPFIX File <src/plugins/input/ipfix>`_ - read flow data from IPFIX File
3739

3840
**Intermediate plugins** - modify, enrich and filter flow records.
3941

40-
- `anonymization <src/plugins/intermediate/anonymization/>`_ - anonymize IP addresses
42+
- `Anonymization <src/plugins/intermediate/anonymization/>`_ - anonymize IP addresses
4143
(in flow records) with Crypto-PAn algorithm
4244

4345
**Output plugins** - store or forward your flows.
4446

45-
- `FDS file <src/plugins/output/fds>`_ - store all flows in FDS file format (efficient long-term storage)
47+
- `FDS File <src/plugins/output/fds>`_ - store all flows in FDS file format (efficient long-term storage)
48+
- `Forwarder <src/plugins/output/forwarder>`_ - forward flows as IPFIX to one or mode subcollectors
49+
- `IPFIX File <src/plugins/output/ipfix>`_ - store all flows in IPFIX File format
4650
- `JSON <src/plugins/output/json>`_ - convert flow records to JSON and send/store them
51+
- `JSON-Kafka <src/plugins/output/json-kafka>`_ - convert flow records to JSON and send them to Apache Kafka
4752
- `Viewer <src/plugins/output/viewer>`_ - convert IPFIX into plain text and print
4853
it on standard output
49-
- `IPFIX file <src/plugins/output/ipfix>`_ - store all flows in IPFIX File format
5054
- `Time Check <src/plugins/output/timecheck>`_ - flow timestamp check
5155
- `Dummy <src/plugins/output/dummy>`_ - simple output module example
5256
- `lnfstore <extra_plugins/output/lnfstore>`_ (*) - store all flows in nfdump compatible
@@ -79,24 +83,31 @@ Second, install build dependencies of the collector
7983

8084
.. code-block::
8185
82-
yum install gcc gcc-c++ cmake make python3-docutils zlib-devel
86+
yum install gcc gcc-c++ cmake make python3-docutils zlib-devel librdkafka-devel
8387
# Optionally: doxygen pkgconfig
8488
85-
* Note: latest systems (e.g. Fedora) use ``dnf`` instead of ``yum``.
89+
* Note: latest systems (e.g. Fedora/CentOS 8) use ``dnf`` instead of ``yum``.
8690
* Note: package ``python3-docutils`` may by also named as ``python-docutils`` or ``python2-docutils``
8791
* Note: package ``pkgconfig`` may by also named as ``pkg-config``
92+
* Note: CentOS 8 requires additional system repositories (``appstream`` and ``powertools``) to be enabled:
93+
94+
.. code-block::
95+
96+
dnf config-manager --set-enabled appstream powertools
8897
8998
**Debian/Ubuntu:**
9099

91100
.. code-block::
92101
93-
apt-get install gcc g++ cmake make python3-docutils zlib1g-dev
102+
apt-get install gcc g++ cmake make python3-docutils zlib1g-dev librdkafka-dev
94103
# Optionally: doxygen pkg-config
95104
96105
Finally, build and install the collector:
97106

98107
.. code-block:: bash
99108
109+
$ git clone https://github.com/CESNET/ipfixcol2.git
110+
$ cd ipfixcol2
100111
$ mkdir build && cd build && cmake ..
101112
$ make
102113
# make install

doc/data/configs/tcp2unirec.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Receive flow data over TCP, convert them into UniRec format and send via
2+
Receive flow data over TCP, convert them into UniRec format and send via
33
TCP TRAP communication interface (port 8000).
44
-->
55
<ipfixcol2>
@@ -23,6 +23,7 @@
2323
<params>
2424
<!-- UniRec template -->
2525
<uniRecFormat>TIME_FIRST,TIME_LAST,SRC_IP,DST_IP,PROTOCOL,?SRC_PORT,?DST_PORT,?TCP_FLAGS,PACKETS,BYTES</uniRecFormat>
26+
<splitBiflow>true</splitBiflow>
2627
<!-- TRAP interface configuration -->
2728
<trapIfcCommon>
2829
<timeout>HALF_WAIT</timeout>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!--
2+
Receive flow data over UDP, convert them into JSON and provide them as
3+
a server on local port
4+
-->
5+
<ipfixcol2>
6+
<!-- Input plugins -->
7+
<inputPlugins>
8+
<input>
9+
<name>UDP collector</name>
10+
<plugin>udp</plugin>
11+
<params>
12+
<!-- List on port 4739 -->
13+
<localPort>4739</localPort>
14+
<!-- Bind to all local adresses -->
15+
<localIPAddress></localIPAddress>
16+
</params>
17+
</input>
18+
</inputPlugins>
19+
20+
<!-- Output plugins -->
21+
<outputPlugins>
22+
<output>
23+
<name>JSON output</name>
24+
<plugin>json-kafka</plugin>
25+
<params>
26+
<!-- JSON format paramters -->
27+
<tcpFlags>formatted</tcpFlags>
28+
<timestamp>formatted</timestamp>
29+
<protocol>formatted</protocol>
30+
<ignoreUnknown>true</ignoreUnknown>
31+
<ignoreOptions>true</ignoreOptions>
32+
<nonPrintableChar>true</nonPrintableChar>
33+
<octetArrayAsUint>true</octetArrayAsUint>
34+
<numericNames>false</numericNames>
35+
<splitBiflow>false</splitBiflow>
36+
<detailedInfo>false</detailedInfo>
37+
<templateInfo>false</templateInfo>
38+
39+
<!-- Output methods -->
40+
<outputs>
41+
<kafka>
42+
<name>Send to Kafka</name>
43+
<brokers>127.0.0.1</brokers>
44+
<topic>ipfix</topic>
45+
<blocking>false</blocking>
46+
<partition>unassigned</partition>
47+
48+
<!-- Zero or more additional properties -->
49+
<property>
50+
<key>compression.codec</key>
51+
<value>lz4</value>
52+
</property>
53+
</kafka>
54+
</outputs>
55+
</params>
56+
</output>
57+
</outputPlugins>
58+
</ipfixcol2>

doc/sphinx/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ of IPFIXcol. Always keep in mind that you should modify a configuration to fit y
169169

170170
:`udp2json <../data/configs/udp2json.xml>`_:
171171
Receive flow data over UDP, convert them into JSON and provide them as a server on local port.
172+
:`udp2json-kafka <../data/configs/udp2json-kafka.xml>`_:
173+
Receive flow data over UDP, convert them into JSON and send them to Apache Kafka.
172174
:`tcp2anon2json <../data/configs/tcp2anon2json.xml>`_:
173175
Receive flow data over TCP, anonymize them and store in JSON format on a local drive.
174176
:`tcpUdp2lnf <../data/configs/tcpUdp2lnf.xml>`_:

0 commit comments

Comments
 (0)