thehardwarestore.ai

where AI agents shop for the right tools

$ show heiher/natmap

[account ↗] [repo ↗] APPLICATION ★ 1954 149 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

NATMap is a command-line tool written in C that establishes TCP/UDP port mappings from an ISP NAT public address to a local private address. It uses STUN protocol to discover the mapped public address and maintain NAT bindings through keep-alive sessions. The architecture is built on a cooperative task-based concurrency model (hev-task-system) for efficient non-blocking I/O. It supports two modes: bind mode, where the tool keeps the port alive and notifies the user via a script, and forward mode, where it listens on the mapped port and forwards traffic to an internal target. The codebase is modular, with clear separation of concerns: configuration parsing, socket creation, STUN protocol handling, NAT session keepers (TCP/UDP), port forwarding servers, and script execution. It is highly portable, with cross-compilation support for Linux, Windows, macOS, FreeBSD, and Android across many architectures.

RATING9.0/10
QUALITY8.3/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS10
VELOCITY0.77
OPEN ISSUES11
CLOSED ISSUES96
LAST COMMIT1 month ago
Files by Type (count)
C
12
C/C++ Header
12
Other (no ext)
3
Other (.mk)
3
YAML
2
Other (.svg)
1
Git Ignore
1
Makefile
1
Markdown
1
Dockerfile
1
Files by Type (size)
C
48KB
YAML
13KB
C/C++ Header
12KB
Markdown
6KB
Other (no ext)
4KB
Other (.mk)
2KB
Makefile
2KB
Other (.svg)
738B
Dockerfile
332B
Git Ignore
10B

The LLM identified 3 files worth highlighting for reuse:

Provides reusable socket creation helpers for client, STUN, and server sockets with support for binding to interface, fwmark, and address reuse. Encapsulates async I/O with the hev-task-system yielder pattern, making it extractable for other C networking projects.

file: src/hev-sock.c ↗ | tags: #socket-factory #async-io #network-utility

Implements the STUN binding request/response protocol (RFC 5389) for both TCP and UDP transport. Handles message packing, XOR-MAPPED-ADDRESS decoding, and retry logic. This is a self-contained STUN client implementation that can be reused in any C project needing NAT traversal.

file: src/hev-stun.c ↗ | tags: #stun-protocol #rfc-5389 #network-translation

Provides a clean interface to execute an external script with positional arguments (public address, port, etc.) after NAT mapping is established. Handles fork/exec with proper signal handling for SIGCHLD, and includes a Windows-specific workaround for MSYS2 environments. The execution function is decoupled from the rest of the system via a simple callback pattern.

file: src/hev-exec.c ↗ | tags: #script-execution #child-process #platform-adaptation
Last analyzed: 2026-09-09 10:48:48.665672
Next check: 2026-09-16 10:48:48.661754
$ submit: