Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

188.1. sniffnet-1.5.1

Watch network traffic by host, service, program and country, in a GPU-drawn window

Version 1.5.1, release 1
Shelf net-diag — Network diagnostics, capture, measurement and low-level socket tools
Phase 42_graphics (Graphics Stack), 146 of 189 in build order
Licence MIT OR Apache-2.0
Homepage https://sniffnet.net
Build time 12.9 SBU
Installed size 45.5 MiB in 16 files
Recipe ports/core/net-diag/sniffnet/kpkgbuild

About

Sniffnet is a graphical network monitor written in Rust with the iced toolkit: it captures packets through libpcap and shows the traffic grouped by host, service, program and country. The country and ASN lookups come from databases upstream embeds in the binary. The port installs the program, its icons and a desktop entry that build.sh writes itself, with a bare Exec=sniffnet, a TryExec line and the Network;Monitor; categories, in place of upstream’s resources/packaging/linux/sniffnet.desktop.

Sources

Dependencies

Depends on: rust, cmake, pkgconf, libpcap, alsa-lib, libxkbcommon, wayland, vulkan-loader, mesa.

Required by: no port names it.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install sniffnet'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/net-diag/sniffnet.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/net-diag/sniffnet
echo '20a5ce502119be22251dd119e41a2bc069454ac1f2c553caccbace6912487180  sniffnet-1.5.1.tar.gz' | sha256sum -c -
echo '7958488bc1e87c7566a2bda63776b7f25e67efd1b395c3022007eb9e3ec83855  sniffnet-vendor-1.5.1.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/sniffnet
SRC=$SRC_ROOT/sniffnet-1.5.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf sniffnet-1.5.1.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/sniffnet-no-update-check.patch"

tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export LIBCLANG_PATH=/usr/lib
export CARGO_NET_OFFLINE=true
cargo build --release --frozen --offline
install -Dm755 target/release/sniffnet "$PKG/usr/bin/sniffnet"

for s in 16 22 24 32 48 64 72 96 128 192 256 512; do
	install -Dm644 resources/packaging/linux/graphics/sniffnet_${s}x${s}.png \
		"$PKG/usr/share/icons/hicolor/${s}x${s}/apps/sniffnet.png"
done

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/sniffnet.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Sniffnet
GenericName=Network Monitor
Comment=Watch network traffic by host, service and program
TryExec=sniffnet
Exec=sniffnet
Icon=sniffnet
Terminal=false
StartupWMClass=sniffnet
Categories=Network;Monitor;
Keywords=traffic;network;packet;capture;pcap;monitor;sniffer;
DESKTOP
chmod 644 "$PKG/usr/share/applications/sniffnet.desktop"
install -Dm644 LICENSE-MIT "$PKG/usr/share/licenses/sniffnet/LICENSE-MIT"
install -Dm644 LICENSE-APACHE "$PKG/usr/share/licenses/sniffnet/LICENSE-APACHE"

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/sniffnet, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf sniffnet-1.5.1-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/sniffnet, and runs the triggers its paths call for.

Contents

Installed programs: sniffnet.

Installed directories: /usr/share/licenses/sniffnet.

Notes

The build is offline: sniffnet-vendor-<version>.tar.xz holds every crate, produced by cargo vendor when ports/fetch sees vendoring = rust, and it carries its own sha256 = line, so a regenerated bundle that resolves differently is refused. See Vendoring.

reqwest pulls in rustls, whose crypto provider is aws-lc-rs over aws-lc-sys, so the binary carries its own copy of AWS-LC. That copy is listed in /usr/share/kdos/bundled.txt with the version the vendored source states, and a bump that regenerates the bundle must rewrite that row; see Bundled copies.

Capturing needs raw-socket privilege, and the port grants none: no setuid bit and no file capability. Run it as root, or give the binary the capability yourself, as setuid binaries describes.