How gnbdev/opengnb works
Project type and purpose
• This is an open-source, multi-platform, P2P VPN/virtual network daemon written in C (OpenGNB).
• It provides intranet-penetration, point-to-point and relay forwarding of IP packets over virtual TUN interfaces, with NAT traversal and optional relay (“forward”) and index (“tracker”) nodes.
File structure
• Top-level:
• Makefiles for various OSes (Makefile.linux, Makefile.mingw_x86_64, etc.) → cross-platform build system
• libs/ → bundled third-party libraries: ed25519 (crypto), miniupnpc, libnatpmp, zlib, TAP-Windows, Wintun, protocol definitions, packet filter helpers
• src/ → application source code
– src/cli/ → CLI entry points: gnb, gnb_crypto, gnb_ctl, gnb_es
– src/crypto/ → symmetric/stream cipher modules (arc4, xor) and random
– src/ctl/, src/es/ → control-plane (configuration dumping, environment service, discovery)
– src/*Platform*/ → platform abstraction for TUN/TAP driver and native network I/O (linux, freebsd, darwin, openbsd, mingw, unix)
– src/packet_filter/ → packet-filtering, payload manipulation (zip, route, crypto)
– src/gnb_*.c/.h → core engine: configuration, node management, message frames, workers, ring buffers, forwarding, logging
• scripts/ → systemd service definitions
• examples/ → sample configuration files and up/down scripts per OS
Extract README insights
• Core components:
• gnb daemon – establishes virtual network interface (gnb_tun), manages peers, routes packets
• gnb_crypto – key management and signing (ED25519)
• gnb_ctl – control interface to query or dump internal state
• gnb_es – environment service for LAN discovery and broadcast
• External services:
• index node (tracker-like) – peer address indexing, no data forwarding
• forward node – optional relay for data when P2P fails
Final recommendations
• all major sub-systems: CLI, config loader, core engine, worker threads (discover, index, forward, packet-filter), network I/O, crypto, platform drivers.
• per-packet flow: from TUN → core → crypto → UDP → peer → TUN.
• initial handshake: core contacting index node, NAT traversal, peer candidate selection.