Commit Graph

79 Commits

Author SHA1 Message Date
Toni Uhlig
a733d536ad Added env check NDPID_STARTED_BY_SYSTEMD to prevent logging to stderr in such a case
* removed `nDPId` shutdown on poll/epoll error
 * fixed `chmod_chown()` rv check

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2024-11-07 11:32:42 +01:00
Toni Uhlig
ce5f448d3b Switched OpenWrt GitHub Actions SDK to main branch
* fixed some SonarCloud complaints
 * added more systemd CI tests
 * fixed debian package scripts to obey remove/purge
 * changed `chmod_chown()` error handling

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2024-11-02 18:36:54 +01:00
Toni
efed6f196e Read and parse configuration files. Fixes #41. (#42)
Read and parse configuration files. Fixes #41.

 * supports nDPId / nDPIsrvd via command line parameter `-f`
 * nDPId: read general/tuning and libnDPI settings
 * support for settings risk domains libnDPI option via config file or via `-R` (Fixes #45, thanks to @UnveilTech)
 * added some documentation in the config file
 * adjusted Systemd and Debian packaging to make use of config files

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2024-10-16 14:13:55 +02:00
Toni Uhlig
b6e4162116 Extend CI pipeline build and test.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2024-03-07 17:46:31 +01:00
Toni Uhlig
53d8a28582 Replaced ambiguous naming of "JSON string" to more accurate "JSON message".
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-12-04 13:01:27 +01:00
Toni Uhlig
830174c7b5 Fixed possible buffer underflow.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-11-20 17:52:30 +01:00
Toni Uhlig
bb9f02719d Added SonarCloud exclusions for third-party files and files lacking relevance.
* fixed two other "bugs"

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-11-20 14:51:59 +01:00
Toni Uhlig
5d56288a11 Fixed more SonarCloud complaints.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-11-07 00:02:36 +01:00
Toni
93498fff02 Apple/BSD port (#30)
* Add MacOS to Github CI builds.
* Fixed libnDPI-4.8 CI build.
* Fixed missing include for `struct sockaddr*`.
* Reworked IPv4 address and netmask retrieval.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-11-06 13:25:49 +01:00
Toni
1b67927169 Event I/O abstraction layer. (#28)
* Finalize Event I/O abstraction layer.
* Fix possible fd leakage, Gitlab-CI build and error logging.
* Fixed possible uninitialized signalfd variable.
* Fixed possible memory leak.
* Fixed some SonarCloud complaints.
* Fixed nDPId-test nDPIsrvd-arpa-mockup stuck indefinitely.
* Add nDPId / nDPIsrvd command line option to use poll() on Linux instead of the default epoll().

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-11-06 12:38:15 +01:00
Toni Uhlig
6ff8982ffb Fixed bug which may happen if additional write buffers are empty but main write buffer not.
* may cause nDPIsrvd to hang indefinitly if no more data received from a collector

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-10-19 13:40:44 +02:00
Toni Uhlig
a0e0611c56 nDPIsrvd: Log error if collector unix socket can not be removed.
* systemd: add post stop hook to forcefully remove the collector unix socket

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-09-11 16:58:13 +02:00
Toni Uhlig
4b3031245d keras-autoencoder.py: fixed invalid preprocessing of received base64 packet data
* split logic into seperate jobs; nDPIsrvd and Keras
 * nDPIsrvd: break event processing and re-run `epoll_wait()` after client disconnected

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-08-15 11:21:46 +02:00
Toni Uhlig
c57ace2fd3 Correctly handle EINTR while doing I/O..
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2023-07-18 13:51:00 +02:00
Toni Uhlig
d21a38cf02 Limit the size of base64 serialized raw packet data (8192 bytes per packet).
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-12-06 12:52:52 +01:00
Toni Uhlig
2c95b31210 nDPId-test: Reworked I/O handling to prevent some endless loop scenarios. Fixed a race condition in the memory wrapper as well.
* nDPId: Instead of sending too long JSON strings, log an error and some parts.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-12-02 22:11:57 +01:00
Toni Uhlig
64f6abfdbe Unified nDPId/nDPIsrvd command line argument storage.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-11-21 11:26:05 +01:00
Toni Uhlig
ea1698504c nDPIsrvd: Provide workaround for change user/group.
* nDPId/nDPIsrvd/c-examples: Parameter parsing needs to be improved
                              if `strdup()` in combination with static strings is used.
 * Other non-critical fixes.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-11-13 11:21:55 +01:00
Toni Uhlig
7515c8aeec Experimental systemd support.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-11-06 12:58:55 +01:00
Toni Uhlig
2d14509f04 nDPid-test: add buffer test
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-10-30 20:12:17 +01:00
Toni Uhlig
ac46f3841f Fixed heap overflow on shutdown caused by missing remotes size/used reset.
* introduced with 22a8d04c74

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-10-05 00:14:46 +02:00
Toni Uhlig
2103ee0811 Refactored client distributor C API.
* Still not perfect, but the code before was not even able to deal with JSON arrays.
   Use common "speaking" function names for all functions in nDPIsrvd.h
 * Provide a more or less generic and easy extendable JSON walk function.
 * Modified C examples to align with the changed C API.
 * c-collectd: Reduced lot's of code duplication by providing mapping tables.
 * nDPId: IAT array requires one slot less (first packet has always an IAT of 0).

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-09-25 00:54:39 +02:00
Toni Uhlig
9a28475bba Improved flown analyse event:
* store packet directions
 * merged direction based IATs
 * merged direction based PKTLENs

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-09-22 19:07:08 +02:00
Toni Uhlig
08f263e409 nDPId: Reduced flow-updates for TCP flows to 1/4 of the timeout value.
* nDPId: Fixed broken validation tests.
 * nDPId: Removed TICK_RESOLUTION, not required anymore.
 * c-collectd: Improved total layer4 payload calculation/update handling.
 * c-collectd: Updated RRD Graph script according to total layer4 payload changes.
 * py-flow-info.py: Fixed several bugs and syntax errors.
 * Python scripts: Added dirname(argv[0]) as search path for nDPIsrvd.py.
 * nDPIsrvd&nDPId-test: Fixed missing EPOLLERR check.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-09-19 19:39:49 +02:00
Toni Uhlig
d4633c1192 New flow event: 'analysis'.
* The goal was to provide a separate event for extracted feature that are not required
   and only useful for a few (e.g. someone who wants do ML).
 * Increased network buffer size to 32kB (8192 * 4).
 * Switched timestamp precision from ms to us for *ALL* timestamps.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-09-13 22:05:08 +02:00
Toni Uhlig
38c71af2f4 nDPIsrvd: Fixed NUL pointer deref during logging attempt.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-09-10 16:46:25 +02:00
lns
a46fc4153d nDPId: Merged nDPId_flow_(info|finished) into nDPId_flow
* nDPIsrvd: Fixed buffer allocation error due to missing memset() on disconnect
 * nDPIsrvd: Removed unused struct members

Signed-off-by: lns <matzeton@googlemail.com>
2022-04-24 23:49:57 +02:00
lns
22a8d04c74 Added proper DLT_RAW dissection for IPv4 and IPv6.
* nDPId: Improved TCP timeout handling if FIN/RST seen
	  which caused Midstream TCP flows when there shouldn't be any.
 * nDPIsrvd: Unified remote descriptor resource cleanup on disconnects/shutdown.
 * nDPIsrvd: Added additional error messages for remote descriptors.
 * py-flow-info: Better daemon status message printing.

Signed-off-by: lns <matzeton@googlemail.com>
2022-04-24 15:42:28 +02:00
lns
c283b89afd Refactored buffer subsystem.
Signed-off-by: lns <matzeton@googlemail.com>
2022-04-16 23:21:24 +02:00
Toni Uhlig
ed1647b944 Disconnect nDPIsrvd clients immediately instead waiting for a failed write().
* nDPIsrvd: Collector/Distributor logging improved
 * nDPIsrvd: Command line option for max remote descriptors
 * nDPId: Stop spamming nDPIsrvd Collector with the same events over and over again
 * nDPId: Refactored some variable names and events

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-03-13 02:28:10 +01:00
Toni Uhlig
41757ecf1c Added nDPIsrvd TCP/IP support for distributors.
* nDPIsrvd: Improved distributor client disconnect detection
 * nDPIsrvd: Fixed invalid usage of epoll_add instead of epoll_mod
 * nPDIsrvd: Improved logging for distributor clients

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-03-10 14:26:07 +01:00
Toni Uhlig
f9e4c58854 Added logging interface used by nDPId, nDPIsrvd and nDPId-test.
* fixed GitLab pipeline
 * nDPId: added static assert (just for a test)
 * nDPId: memory profiling for total bytes compressed
 * nDPId-test: enable zLib compression if configured with ENABLE_ZLIB

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-02-03 03:48:37 +01:00
Toni Uhlig
7022d0b1c5 nDPIsrvd: Fixed memory leak caused be not clearing buffer cache after a client disconnected.
* README.md: Fixed a typ0 and added a meh image from examples/py-flow-dashboard/flow-dash.py

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-01-26 15:38:43 +01:00
Toni Uhlig
9e07a57566 Major nDPId extension. Sorry for the huge commit.
- nDPId: fixed invalid IP4/IP6 tuple compare
 - nDPIsrvd: fixed caching issue (finally)
 - added tiny c example (can be used to check flow manager sanity)
 - c-captured: use flow_last_seen timestamp from `struct nDPIsrvd_flow`
 - README.md update: added example JSON sequence
 - nDPId: added new flow event `update` necessary for correct
   timeout handling (and other future use-cases)
 - nDPIsrvd.h and nDPIsrvd.py: switched to an instance
   (consists of an alias/source tuple) based flow manager
 - every flow related event **must** now serialize `alias`, `source`,
   `flow_id`, `flow_last_seen` and `flow_idle_time` to make the timeout
   handling and verification process work correctly
 - nDPIsrvd.h: ability to profile any dynamic memory (de-)allocation
 - nDPIsrvd.py: removed PcapPacket class (unused)
 - py-flow-dashboard and py-flow-multiprocess: fixed race condition
 - py-flow-info: print statusbar with probably useful information
 - nDPId/nDPIsrvd.h: switched from packet-flow only timestamps (`pkt_*sec`)
   to a generic flow event timestamp `ts_msec`
 - nDPId-test: added additional checks
 - nDPId: increased ICMP flow timeout
 - nDPId: using event based i/o if capturing packets from a device
 - nDPIsrvd: fixed memory leak on shutdown if remote descriptors
   were still connected

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2022-01-20 00:50:38 +01:00
Toni Uhlig
d389f04135 MemoryProfiling: Advanced flow usage logging.
* nDPId-test: disable #include <syslog.h> if NO_MAIN macro defined
 * nDPId-test: mock syslog flags and functions
 * gitlab-ci: force -Werror

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-11-13 17:30:21 +01:00
Toni Uhlig
9075706714 nDPId-test: Set max buffer size for remote descriptors useful to test caching/buffering.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-11-04 14:08:25 +01:00
Toni Uhlig
e54c2df63b nDPIsrvd: Fixed anther bug, introduced during refactoring -_-
nDPId-test: Collect information about JSON string length's.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-09-15 14:33:13 +02:00
Toni Uhlig
aa89800ff9 fixed Warnings / build error / cosmetics
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-09-14 18:38:37 +02:00
Toni Uhlig
6faded3cc7 Improved and Fixed another buffering issue caused by removing an outgoing fd too early from epoll queue (EPOLLOUT).
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-08-05 02:02:51 +02:00
Toni Uhlig
d48508b4af Improved nDPIsrvd buffer bloat handling using caching.
* still allow blocking mode (with send timeout)
 * improved daemon start/stop test script

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-08-04 17:19:15 +02:00
Toni Uhlig
a41ddafa88 Git tag/commit version printing for nDPId/nDPIsrvd. Reduces confusion.
* disabled subshell spawn for run_tests.sh, common pitfall while using counters

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-06-08 15:23:33 +02:00
Toni Uhlig
5954e46340 Build system cleanup / cosmetics.
* libnDPI submodule update

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-06-07 16:22:49 +02:00
Toni Uhlig
54e0601fec Unified IO buffer mgmt.
* c-collectd gives the user control over collectd-exec instance name
 * added missing collectd type `flow_l4_icmp_count`

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-06-07 15:04:46 +02:00
Toni Uhlig
a0fa598cee travis-ci build CMake project
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-04-15 11:21:37 +02:00
Toni Uhlig
0a7ad7a76a nDPId-test: added JSON distribution + JSON parsing (Multithreaded design re-using most of nDPId/nDPIsrvd core)
* improved Makefile.old install targets
 * splitted nDPIsrvd_parse into nDPIsrvd_parse_line and nDPIsrvd_parse_all for the sake of readability
 * minor Python script improvments (check for nDPIsrvd.py on multiple locations, may be superseeded by setuptools in the future)
 * some paths needs to be absolute (chdir() during daemonize) and therefor additional checks introduced
 * test run script checks and fails if certain files are are missing (PCAP file <=> result output file)
 * removed not very useful "internal format error" JSON serialization if a BUG for same exists
 * fixed invalid l4 type statistics counters for nDPIsrvd-collectd

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-04-09 00:18:35 +02:00
Toni Uhlig
e835d36f63 Added nDPId-test as all-in-one JSON dumper.
* fixed invalid flow event schema type
 * added run_tests.sh to generate/diff JSON dumps
 * renamed lot's of vars/fns in nDPId.c/nDPIsrvd.c, so nDPId-test.c can include "*.c"
 * improved CMake dependency checks

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-03-24 11:28:56 +01:00
Toni Uhlig
bdc8c5df2a Reduced code duplication. Preps for nDPId-test.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-03-23 14:25:56 +01:00
Toni Uhlig
1c3ef69faa nDPIsrvd collectd-exec overhaul.
* Install targets updated.
 * Removed nDPIsrvd.h token validation function (done automatically by token_get).

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-03-15 14:39:43 +01:00
Toni Uhlig
1073c9626b nDPIsrvd refactoring
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-03-05 12:24:24 +01:00
Toni Uhlig
e0310d7e1d Finalized examples/c-captured to dump packet bytes to PCAP for further analysis.
* Fixed memory holes in nDPId structs.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2021-02-24 18:43:26 +01:00