paqet uses a client-server architecture where the client acts as a local proxy and the server acts as a remote gateway, with raw packet transport in between.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hanselime/paqet/llms.txt
Use this file to discover all available pages before exploring further.
Client-Server Model
Client
The client component runs on your local machine and provides two modes of operation: SOCKS5 Proxy ModeBoth modes can be used simultaneously in the same client configuration.
Server
The server component runs on a remote machine with a public IP address. It:- Listens for raw TCP packets on the configured port
- Accepts KCP connections from clients
- Forwards decrypted traffic to target destinations
- Returns responses back through the encrypted tunnel
Component Breakdown
paqet is built on several key open-source libraries, each providing specific functionality:pcap (libpcap)
Purpose: Low-level packet capture and injection- Captures raw packets directly from the network interface
- Injects crafted packets onto the network
- Bypasses the OS TCP/IP stack entirely
Linux binaries are statically linked. macOS requires Xcode Command Line Tools. Windows requires Npcap.
gopacket
Purpose: Packet crafting and decoding library for Go- Constructs Ethernet, IP, and TCP headers
- Parses incoming packet headers
- Calculates checksums
- Provides packet serialization/deserialization
kcp-go
Purpose: Reliable, encrypted transport protocol- Implements KCP (fast ARQ protocol) in Go
- Provides symmetric encryption (AES, ChaCha20, etc.)
- Handles packet retransmission and ordering
- Optimized for high-loss networks with aggressive retransmission
internal/client/client.go:28-37:
internal/server/server.go:49-54:
smux
Purpose: Stream multiplexing library- Multiplexes multiple streams over a single KCP connection
- Reduces connection establishment overhead
- Allows concurrent requests without creating new raw packet flows
Network Stack Bypass
Understanding how paqet bypasses the network stack is crucial to its operation.Normal Application Flow
- Network driver receives the packet
- TCP/IP stack processes headers, manages connection state
netfilter(backend forufw/firewalld) applies firewall rules- Application receives filtered data
paqet’s Bypassed Flow
- pcap provides a copy of packets before the TCP/IP stack processes them
- paqet processes the copy independently of the OS
- Firewall rules don’t apply because paqet’s copy bypasses netfilter
- OS doesn’t know about the connection (no state tracking)
Connection Multiplexing
Multiplexing allows paqet to handle multiple application streams efficiently:Without Multiplexing
- Separate KCP handshake
- Separate packet crafting overhead
- More resources on both client and server
With Multiplexing (smux)
- One KCP connection (established once)
- One set of raw packet flows
- Lower latency for subsequent requests
Multiple connections can provide better throughput by allowing parallel transmission, but each connection adds overhead. Start with 1-2 connections and increase if needed.