Skip to content

Commit 3a8e861

Browse files
authored
feat: reorganize platform code into per-platform directories (#81)
* feat: reorganize platform code into per-platform directories - Move platform files into linux/, macos/, windows/, freebsd/ subdirectories - Unify create_process_lookup() API with _use_pktap parameter across all platforms - Update build.rs paths for eBPF program location - Reduce cfg attributes in main mod.rs from ~42 to 8 * fix: widen tolerance for test_sliding_window_no_skip_first_sample Increase acceptable range from 9000-11000 to 5000-15000 to account for timing variability on macOS ARM CI runners. * docs: update Linux build dependencies and remove EBPF_BUILD.md - Add missing build-essential, pkg-config, zlib1g-dev to documentation - Update rust.yml CI with complete dependencies - Remove EBPF_BUILD.md (info already in INSTALL.md) - Update references in README.md and ARCHITECTURE.md
1 parent fed1efa commit 3a8e861

32 files changed

Lines changed: 528 additions & 447 deletions

.github/workflows/aur-update.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- "v[0-9]+.[0-9]+.[0-9]+"
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
update-aur:
1114
name: update-aur

.github/workflows/ppa-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ on:
2020
tags:
2121
- 'v*'
2222

23+
permissions:
24+
contents: read
25+
2326
env:
2427
DEBEMAIL: cadetg@gmail.com
2528
DEBFULLNAME: Marco Cadetg

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- "v[0-9]+.[0-9]+.[0-9]+"
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
publish:
1114
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ on:
2525
- "v[0-9]+.[0-9]+.[0-9]+"
2626
workflow_dispatch:
2727

28+
permissions:
29+
contents: write
30+
2831
env:
2932
RUST_BACKTRACE: 1
3033
RUSTNET_ASSET_DIR: assets

.github/workflows/rust.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ on:
2121
- '.github/workflows/rust.yml'
2222
workflow_dispatch:
2323

24+
permissions:
25+
contents: read
26+
2427
env:
2528
CARGO_TERM_COLOR: always
2629

@@ -30,7 +33,7 @@ jobs:
3033
steps:
3134
- uses: actions/checkout@v6
3235
- name: Install dependencies
33-
run: sudo apt-get update && sudo apt-get install -y libpcap-dev libelf-dev clang llvm
36+
run: sudo apt-get update && sudo apt-get install -y libpcap-dev libelf-dev zlib1g-dev clang llvm pkg-config
3437
- name: Build
3538
run: cargo build --verbose
3639
- name: Run tests

.github/workflows/test-freebsd.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: Test Platform Builds
2+
3+
# Test builds on all supported platforms.
4+
# Runs automatically on PRs and can be triggered manually for specific platforms.
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
platform:
10+
description: 'Platform to build'
11+
required: true
12+
type: choice
13+
options:
14+
- all
15+
- linux
16+
- macos
17+
- windows
18+
- freebsd
19+
pull_request:
20+
paths:
21+
- 'Cargo.toml'
22+
- 'build.rs'
23+
- 'src/**'
24+
- '.github/workflows/test-platform-builds.yml'
25+
26+
permissions:
27+
contents: read
28+
29+
env:
30+
RUST_BACKTRACE: 1
31+
CARGO_TERM_COLOR: always
32+
33+
jobs:
34+
build-linux:
35+
name: Build Linux (x64)
36+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }}
37+
runs-on: ubuntu-22.04
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v6
41+
42+
- name: Install dependencies
43+
run: |
44+
sudo apt-get update -y
45+
sudo apt-get install -y libpcap-dev libelf-dev zlib1g-dev clang llvm pkg-config
46+
47+
- name: Install Rust
48+
uses: dtolnay/rust-toolchain@stable
49+
50+
- name: Build
51+
run: cargo build --verbose --release
52+
53+
- name: Run tests
54+
run: cargo test --verbose
55+
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v5
58+
with:
59+
name: rustnet-linux-x64
60+
path: target/release/rustnet
61+
if-no-files-found: error
62+
63+
build-macos-intel:
64+
name: Build macOS (Intel)
65+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
66+
runs-on: macos-14
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v6
70+
71+
- name: Install Rust
72+
uses: dtolnay/rust-toolchain@stable
73+
with:
74+
targets: x86_64-apple-darwin
75+
76+
- name: Build
77+
run: cargo build --verbose --release --target x86_64-apple-darwin --no-default-features
78+
79+
- name: Upload artifact
80+
uses: actions/upload-artifact@v5
81+
with:
82+
name: rustnet-macos-intel
83+
path: target/x86_64-apple-darwin/release/rustnet
84+
if-no-files-found: error
85+
86+
build-macos-arm:
87+
name: Build macOS (Apple Silicon)
88+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
89+
runs-on: macos-14
90+
steps:
91+
- name: Checkout repository
92+
uses: actions/checkout@v6
93+
94+
- name: Install Rust
95+
uses: dtolnay/rust-toolchain@stable
96+
with:
97+
targets: aarch64-apple-darwin
98+
99+
- name: Build
100+
run: cargo build --verbose --release --target aarch64-apple-darwin --no-default-features
101+
102+
- name: Run tests
103+
run: cargo test --verbose
104+
105+
- name: Upload artifact
106+
uses: actions/upload-artifact@v5
107+
with:
108+
name: rustnet-macos-arm
109+
path: target/aarch64-apple-darwin/release/rustnet
110+
if-no-files-found: error
111+
112+
build-windows-x64:
113+
name: Build Windows (64-bit)
114+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows' }}
115+
runs-on: windows-latest
116+
steps:
117+
- name: Checkout repository
118+
uses: actions/checkout@v6
119+
120+
- name: Install Rust
121+
uses: dtolnay/rust-toolchain@stable
122+
with:
123+
targets: x86_64-pc-windows-msvc
124+
125+
- name: Build
126+
run: cargo build --verbose --release --target x86_64-pc-windows-msvc --no-default-features
127+
128+
- name: Upload artifact
129+
uses: actions/upload-artifact@v5
130+
with:
131+
name: rustnet-windows-x64
132+
path: target/x86_64-pc-windows-msvc/release/rustnet.exe
133+
if-no-files-found: error
134+
135+
build-windows-x86:
136+
name: Build Windows (32-bit)
137+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows' }}
138+
runs-on: windows-latest
139+
steps:
140+
- name: Checkout repository
141+
uses: actions/checkout@v6
142+
143+
- name: Install Rust
144+
uses: dtolnay/rust-toolchain@stable
145+
with:
146+
targets: i686-pc-windows-msvc
147+
148+
- name: Build
149+
run: cargo build --verbose --release --target i686-pc-windows-msvc --no-default-features
150+
151+
- name: Upload artifact
152+
uses: actions/upload-artifact@v5
153+
with:
154+
name: rustnet-windows-x86
155+
path: target/i686-pc-windows-msvc/release/rustnet.exe
156+
if-no-files-found: error
157+
158+
build-freebsd:
159+
name: Build FreeBSD (x64)
160+
if: ${{ github.event_name == 'pull_request' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'freebsd' }}
161+
runs-on: ubuntu-latest
162+
steps:
163+
- name: Checkout repository
164+
uses: actions/checkout@v6
165+
166+
- name: Build on FreeBSD
167+
uses: vmactions/freebsd-vm@b9c3f24600acdef618ef1c9e2d3c6eeda4dce712 # v1.2.7
168+
with:
169+
usesh: true
170+
prepare: |
171+
pkg install -y curl libpcap rust
172+
run: |
173+
echo "Building for FreeBSD without default features (no eBPF)"
174+
cargo build --verbose --release --no-default-features
175+
176+
echo "Verifying binary was created"
177+
if [ -f "target/release/rustnet" ]; then
178+
echo "FreeBSD binary successfully built"
179+
ls -lh target/release/rustnet
180+
else
181+
echo "FreeBSD binary not found"
182+
exit 1
183+
fi
184+
185+
- name: Upload artifact
186+
uses: actions/upload-artifact@v5
187+
with:
188+
name: rustnet-freebsd-x64
189+
path: target/release/rustnet
190+
if-no-files-found: error

ARCHITECTURE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ RustNet uses platform-specific APIs to associate network connections with proces
180180
- If eBPF fails to load (permissions, kernel compatibility), automatically falls back to procfs mode
181181
- TUI Statistics panel shows active detection method
182182

183-
See [EBPF_BUILD.md](EBPF_BUILD.md) for detailed eBPF build and deployment information.
184-
185183
#### macOS
186184

187185
**PKTAP Mode (with sudo):**

0 commit comments

Comments
 (0)