$ show ericpaulbishop/gargoyle
Gargoyle is a third-party router firmware distribution based on OpenWrt/LEDE. It provides a comprehensive web-based administration interface with features such as bandwidth monitoring, QoS, VPN (OpenVPN, WireGuard, Tor), dynamic DNS, ad blocking, web monitoring, and a plugin system for extensibility. The codebase is a large collection of C utilities (custom netfilter match modules, a package manager 'gpkg', bandwidth accounting libraries, and a CGI framework built on a patched version of haserl), shell scripts for UCI configuration and firewall management, and JavaScript/CSS for the web UI. Internationalization is extensive with over a dozen language packs. The architecture is monolithic in the sense that all components are built as part of a firmware image, but modular at the package level. Key data flows involve kernel-level packet matching (via custom nftables/iptables modules) feeding user-space libraries (libiptbwctl/libnftbwctl) and shell scripts that expose bandwidth and status data through the web interface.
The LLM identified 4 files worth highlighting for reuse:
A self-contained, portable regex engine (Henry Spencer's implementation, circa 1987) adapted for kernel-space use via #if __KERNEL__ guards. It includes a hardcoded step limit (1,000,000) to prevent catastrophic backtracking in softirq context. This file can be extracted and reused in any C project requiring a minimal regex matcher, with minimal modifications.
A collection of generic C data structures: dynamic list, priority queue, string map, and tree map (balanced binary tree). These are used across multiple packages (gpkg, haserl-i18n, firewall utilities) for config storage, translation lookups, and bandwidth tracking. The implementations are self-contained and can be reused in any C project as a lightweight container library.
The core translation engine for the haserl CGI framework. It parses key-value pair files (i18n string maps) and provides fast lookup for localized UI strings. The pattern of simple file parsing with in-memory hash tables is reusable for any CGI or server-side application needing lightweight internationalization without heavy frameworks.
A minimal, self-contained tar archive extractor (with gzip support via unzip.c) derived from BusyBox. It handles tar headers, file permissions, and path creation. This is ideal for embedded systems or any environment where a full libarchive is too heavy. The code is isolated and can be dropped into another project with minor porting.