$ show Netis/cloud-probe
Netis Cloud Probe is a production-grade network packet capture and forwarding system designed to monitor traffic without requiring dedicated TAP or SPAN hardware. It consists of a high-performance C capture engine (cpworker), a Go daemon (cpdaemon) that manages worker processes and communicates with a central policy manager (CPM), and a Go CLI (cpctl) for manual control. The system supports multiple capture sources (libpcap, DPDK, pcap files) and output sinks (GRE, VXLAN, ZMQ, rotating files) with a configurable execution model (real-time or pipelined using a lock-free SPSC ring buffer). Configuration reload is handled via a state-machine protocol, enabling hot-swapping of tasks without packet loss. The codebase is multi-language (C, Go) with CMake and Mage build systems, comprehensive unit and integration tests, and bilingual documentation (English, Chinese). It is actively maintained with a recent commit and continuous integration.
The LLM identified 7 files worth highlighting for reuse:
A lock-free single-producer single-consumer ring buffer with a built-in simple memory allocator. It provides allocate, commit, read, and release operations using atomic store/load with release/acquire semantics. This is a self-contained, high-performance inter-thread communication primitive that can be extracted into any C project requiring lock-free data transfer.
A token-bucket rate limiter implemented as a set of functions (ratelimit_init, ratelimit_consume, ratelimit_return, ratelimit_sync). It uses a time-based accumulation model with a configurable rate and burst capacity. The implementation is standalone (no internal dependencies) and can serve as a drop-in rate limiter for packet processing, network throttling, or any resource-limiting scenario in C.
A deterministic fingerprint generator for Go structs using FNV-1a hash. The core function StructFingerprintLabels uses reflection to traverse struct fields, sort them lexicographically, and produce a compact, order-independent fingerprint string. This is an isolated utility for detecting configuration changes or building cache keys from arbitrary structs, reusable across any Go project that needs content-based identity.
A cross-platform cgroup management package that detects cgroup v1 vs v2 at runtime and provides a consistent interface for setting CPU limits and cleaning up cgroups. It handles statfs-based filesystem detection and falls back gracefully. The core logic is self-contained (only stdlib and zap logger dependency) and can be extracted into any Linux daemon that needs to enforce per-process CPU quotas.
A logging utility that implements a custom slog.Handler which fans out log records to multiple sinks (e.g., stderr and file) while preserving structured attributes. It provides level-based routing, error attribute extraction, and a convenient constructor for common setups. This is a self-contained Go package that replaces the missing built-in multi-writer in log/slog, usable in any Go application needing structured logging to multiple outputs.
A set of HTTP middleware and response helpers for building JSON APIs in Go. It includes panic recovery with structured logging, request logging, JSON response writers with error handling, and common HTTP status code constants. The code is not coupled to any application-specific logic and can be extracted as a lightweight HTTP foundation for Go microservices.
A data-driven test runner for cpworker integration tests. It reads test case directories containing config.json and verify.json, starts cpworker as a subprocess, applies the configuration, captures output, and runs verifiers. The pattern of config-driven test cases with separate verification scripts is reusable for any project that tests network services or command-line tools.