How samyk/pwnat works
pwnat establishes direct client-to-server tunnels through NATs: the client uses a local TCP listener and UDP tunnel, while the server discovers clients with ICMP and bridges UDP traffic to an allowed or selected TCP destination. The graph preserves those documented stages and the sampled client, message, socket, packet, and state-management layers. Some server-loop details and other modules were not excerpted; edges for those are limited to README descriptions or visible references.
Main entry points: udpserver.c Server mode · udpclient.c Client mode · client.c Client state · socket.c Socket transport
Components 13
Program entry
- Mode dispatcher
src/pwnat.c - Option parsing
src/xgetopt.c
Tunnel endpoints
- Client mode
src/udpclient.c - Server mode
src/udpserver.c - Client state
src/client.c - Destination rules
src/destination.c
Protocol and discovery
- UDP messages
src/message.c - ICMP discovery
src/packet.c
Runtime support
- Socket transport
src/socket.c - Client registry
src/list.c - Shared definitions
src/common.h - Time support
src/gettimeofday.c
Other components
- Tunnel operator
Connections 22
- Tunnel operator → Mode dispatcher: selects mode
README.md - Mode dispatcher → Option parsing: parses options
src/pwnat.c - Mode dispatcher → Client mode: dispatches client
- Mode dispatcher → Server mode: dispatches server
- Client mode → Socket transport: opens TCP/UDP
src/udpclient.c - Client mode → Client state: creates clients
src/udpclient.c - Client mode → UDP messages: exchanges messages
- Server mode → ICMP discovery: sends discovery
README.md - Server mode → Destination rules: loads restrictions
src/udpserver.c - Server mode → Client registry: tracks clients
src/udpserver.c - Server mode → Client state: handles client state
src/udpserver.c - Server mode → Socket transport: opens UDP/TCP
- Server mode → UDP messages: handles tunnel messages
src/udpserver.c - Client state → UDP messages: sends protocol data
src/client.c - Client state → Socket transport: uses client sockets
src/client.c - Client registry → Client state: stores clients
- UDP messages → Socket transport: transfers packets
src/message.c - ICMP discovery → Socket transport: sends raw packets
src/packet.c - Client mode → Time support: checks timers
- Server mode → Time support: checks timers
- Client mode → Shared definitions: uses shared definitions
src/udpclient.c - Server mode → Shared definitions: uses shared definitions
src/udpserver.c