Skip to content

Commit 0f46124

Browse files
Merge pull request #3 from stefanDeveloper/cpp
Cpp Improvement
2 parents 1f8f9bb + 0659a38 commit 0f46124

File tree

524 files changed

+783
-5482
lines changed

Some content is hidden

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

524 files changed

+783
-5482
lines changed

.dockerignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
docker-compose.yml
1+
docker-compose.yml
2+
.git
3+
.github
4+
build
5+
cmake-build-*
6+
**/__pycache__
7+
**/*.o
8+
**/*.a
9+
**/*.log
10+
tests/
11+
nDPId/
12+
heidpi-logger-py/
13+
heidpi-rust/
14+
*.swp
15+
.DS_Store

.github/workflows/python-app.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/python-publish.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

Dockerfile.consumer

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
1-
FROM pypy:3.9-slim-bookworm
1+
# ---------- Build stage ----------
2+
FROM debian:bookworm AS build
3+
ARG CMAKE_BUILD_TYPE=Release
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
build-essential cmake pkg-config git ca-certificates \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /src
10+
COPY heidpi-logger/ ./heidpi-logger/
11+
12+
RUN cmake -S heidpi-logger -B /build \
13+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
14+
-DBUILD_TESTING=OFF \
15+
-DMAXMINDDB_BUILD_BINARIES=OFF \
16+
-DMAXMINDDB_TOOLS=OFF \
17+
-DMAXMINDDB_INSTALL=OFF \
18+
&& cmake --build /build --target heidpi_cpp -- -j"$(nproc)" \
19+
&& strip /build/heidpi_cpp || true
20+
21+
# ---------- Runtime stage ----------
22+
FROM debian:bookworm-slim AS runtime
23+
24+
RUN apt-get update && apt-get install -y --no-install-recommends \
25+
libstdc++6 ca-certificates \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
# non-root
29+
RUN useradd -r -u 10001 appuser
30+
WORKDIR /app
31+
32+
# Configs (aus Repo-Root)
33+
COPY config.yml /app/config.yml
34+
35+
COPY --from=build /build/heidpi_cpp /usr/local/bin/app
236

337
ENV WRITE="/var/log" \
438
SHOW_FLOW_EVENTS=1 \
5-
SHOW_PACKET_EVENTS=0 \
39+
SHOW_PACKET_EVENTS=1 \
640
SHOW_ERROR_EVENTS=0 \
741
SHOW_DAEMON_EVENTS=0 \
842
UNIX="" \
943
PORT=7000 \
1044
HOST=""
1145

12-
WORKDIR /usr/src/app
13-
14-
COPY heidpi ./ \
15-
config.yml ./ \
16-
LICENSE ./ \
17-
README.md ./ \
18-
requirements.txt ./ \
19-
pyproject.toml ./
20-
21-
RUN pip install . \
22-
pip install -r requirements.txt
46+
USER appuser
2347

24-
CMD [ "heiDPI"]
48+
ENTRYPOINT ["/usr/local/bin/app"]
49+
CMD ["--config","/app/config.yml"]

README.consumer.md

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,6 @@
66
[nDPId](https://github.com/utoni/nDPId) Docker Image for deep packet inspection. As described in [nDPId](https://github.com/utoni/nDPId/blob/main/README.md), we split the image into producer and consumer image for a more generic purpose. For the producer, the image starts the UNIX and UDP socket and nDPId respectively. Via environment variables, users can adapt the nDPId daemon and nDPIsrvd. As by now, we support all current nDPId parameters.
77

88
<table>
9-
<tr>
10-
<td><b>Live Notebook</b></td>
11-
<td>
12-
<a href="https://mybinder.org/v2/gh/heidpi/heiDPI-tutorials/main?filepath=demo_notebook.ipynb">
13-
<img src="https://img.shields.io/badge/notebook-launch-blue?logo=jupyter&style=for-the-badge" alt="live notebook" />
14-
</a>
15-
</td>
16-
</tr>
17-
<tr>
18-
<td><b>Latest Release</b></td>
19-
<td>
20-
<a href="https://pypi.python.org/pypi/heidpi">
21-
<img src="https://img.shields.io/pypi/v/heidpi.svg?logo=pypi&style=for-the-badge" alt="latest release" />
22-
</a>
23-
</td>
24-
</tr>
25-
<tr>
26-
<td><b>Supported Versions</b></td>
27-
<td>
28-
<a href="https://pypi.org/project/heidpi/">
29-
<img src="https://img.shields.io/pypi/pyversions/heidpi?logo=python&style=for-the-badge" alt="python3" />
30-
</a>
31-
<a href="https://pypi.org/project/heidpi/">
32-
<img src="https://img.shields.io/badge/pypy-3.7%20%7C%203.8%20%7C%203.9-blue?logo=pypy&style=for-the-badge" alt="pypy3" />
33-
</a>
34-
</td>
35-
</tr>
369
<tr>
3710
<td><b>Project License</b></td>
3811
<td>
@@ -59,32 +32,19 @@
5932
Install using PyPi:
6033

6134
```sh
62-
pip install heiDPI
35+
cd ./heidpi-logger && cmake . && make
6336
```
6437

6538
Use the CLI for quick usage:
6639

6740
```
68-
> heiDPI -h
69-
usage: heiDPI [-h] [--host HOST | --unix UNIX] [--port PORT] [--write WRITE] [--config CONFIG] [--show-daemon-events SHOW_DAEMON_EVENTS] [--show-packet-events SHOW_PACKET_EVENTS] [--show-error-events SHOW_ERROR_EVENTS] [--show-flow-events SHOW_FLOW_EVENTS]
70-
71-
heiDPI Python Interface
72-
73-
options:
74-
-h, --help show this help message and exit
75-
--host HOST nDPIsrvd host IP (default: None)
76-
--unix UNIX nDPIsrvd unix socket path (default: None)
77-
--port PORT nDPIsrvd TCP port (default: 7000)
78-
--write WRITE heiDPI write path for logs (default: /var/log)
79-
--config CONFIG heiDPI write path for logs (default: /home/smachmeier/projects/emcl/heiDPI/config.yml)
80-
--show-daemon-events SHOW_DAEMON_EVENTS
81-
heiDPI shows daemon events (default: 0)
82-
--show-packet-events SHOW_PACKET_EVENTS
83-
heiDPI shows packet events (default: 0)
84-
--show-error-events SHOW_ERROR_EVENTS
85-
heiDPI shows error events (default: 0)
86-
--show-flow-events SHOW_FLOW_EVENTS
87-
heiDPI shows flow events (default: 0)
41+
> ./heidpi_cpp -h
42+
usage: heidpi_cpp [-h] [--host HOST | --unix UNIX] [--port PORT] [--write WRITE]
43+
[--config CONFIG] [--filter FILTER]
44+
[--show-daemon-events]
45+
[--show-packet-events]
46+
[--show-error-events]
47+
[--show-flow-events]
8848
```
8949

9050
### Prerequisities

README.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,6 @@
1616
</a>
1717
</td>
1818
</tr>
19-
<tr>
20-
<td><b>Latest Release</b></td>
21-
<td>
22-
<a href="https://pypi.python.org/pypi/heidpi">
23-
<img src="https://img.shields.io/pypi/v/heidpi.svg?logo=pypi&style=for-the-badge" alt="latest release" />
24-
</a>
25-
</td>
26-
</tr>
27-
<tr>
28-
<td><b>Supported Versions</b></td>
29-
<td>
30-
<a href="https://pypi.org/project/heidpi/">
31-
<img src="https://img.shields.io/pypi/pyversions/heidpi?logo=python&style=for-the-badge" alt="python3" />
32-
</a>
33-
<a href="https://pypi.org/project/heidpi/">
34-
<img src="https://img.shields.io/badge/pypy-3.7%20%7C%203.8%20%7C%203.9-blue?logo=pypy&style=for-the-badge" alt="pypy3" />
35-
</a>
36-
</td>
37-
</tr>
3819
<tr>
3920
<td><b>Project License</b></td>
4021
<td>

config.toml

Lines changed: 0 additions & 31 deletions
This file was deleted.

config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
appName: heiDPI
22

33
logging:
4-
level: INFO
4+
level: ERROR
55
encoding: utf-8
66
format: "%(asctime)s %(levelname)s:%(message)s"
77
datefmt: "%Y-%m-%dT%I:%M:%S"
@@ -28,26 +28,26 @@ flow_event:
2828
# - city
2929
# - traits
3030
# - postal
31-
threads: 4
31+
# threads: 4
3232

3333
daemon_event:
3434
ignore_fields: []
3535
daemon_event_name:
3636
- init
3737
- status
3838
filename: daemon_event
39-
threads: 4
39+
# threads: 4
4040

4141
packet_event:
4242
ignore_fields: []
4343
packet_event_name:
4444
- packet-flow
4545
filename: packet_event
46-
threads: 4
46+
# threads: 4
4747

4848
error_event:
4949
ignore_fields: []
5050
error_event_name:
5151
- error-flow
5252
filename: error_event
53-
threads: 4
53+
# threads: 4

0 commit comments

Comments
 (0)