Skip to content

Commit 70498d2

Browse files
committed
refactor: Separate network communication from packet capture logic & introduce PF_RING captures
Move overarching service orchestration to main.cpp and create dedicated NetworkClient and CaptureService components for better separation of concerns. New Architecture: - main.cpp: Service orchestrator handling both capture and network clients - NetworkClient: Manages TCP connection to WhatPulse with auto-reconnect - CaptureService: Handles packet capture and interface monitoring only - IPacketHandler: Interface for cleaner packet handling abstraction
1 parent 830d293 commit 70498d2

16 files changed

+1366
-610
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
whatpulse-pcap-service
1+
whatpulse-pcap-service*

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CC=g++
22
CFLAGS=-std=c++17 -Wall -Wextra -O2 -pthread
33
LDFLAGS=-lpcap -pthread
44
TARGET=whatpulse-pcap-service
5-
SOURCES=main.cpp pcapservice.cpp tcpclient.cpp pcapcapturethread.cpp logger.cpp
5+
SOURCES=main.cpp captureservice.cpp networkclient.cpp tcpclient.cpp pcapcapturethread.cpp pfringcapturethread.cpp logger.cpp
66
VERSION=1.0.2
77

88
# Default target
@@ -12,7 +12,9 @@ $(TARGET): $(SOURCES)
1212
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCES) $(LDFLAGS)
1313

1414
# Debug build
15-
debug: CFLAGS += -g -DDEBUG
15+
debug: CFLAGS = -std=c++17 -Wall -Wextra -g -O0 -DDEBUG -pthread -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined
16+
debug: LDFLAGS = -lpcap -pthread -fsanitize=address -fsanitize=undefined
17+
debug: TARGET := $(TARGET)-debug
1618
debug: $(TARGET)
1719

1820
# Static build (most portable - for universal distribution)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A companion service that enables network monitoring for WhatPulse when running i
66

77
When WhatPulse runs as an AppImage or in other restricted environments, it may not have direct access to capture network packets. This service runs alongside WhatPulse to provide network monitoring capabilities by:
88

9-
- Capturing network traffic using system-level access
9+
- Capturing network traffic using high-performance PF_RING or traditional PCap
1010
- Filtering and processing packet data safely
1111
- Forwarding relevant statistics to WhatPulse via local connection
1212

@@ -119,7 +119,7 @@ The service will automatically connect to WhatPulse when both are running. No ad
119119
sudo systemctl status whatpulse-pcap-service
120120

121121
# View recent logs
122-
sudo journalctl -u whatpulse-pcap-service -f
122+
sudo tail /var/log/whatpulse-pcap.log
123123
```
124124

125125
### Common Issues

0 commit comments

Comments
 (0)