Skip to content

feat(traffic): opt-in SOCKS5 UDP ASSOCIATE and raw UDP recording (P4.1c) - #433

Merged
BaaRai merged 5 commits into
mainfrom
feat/proxy-socks5-udp
Nov 20, 2026
Merged

BaaRai merged 5 commits into
mainfrom
feat/proxy-socks5-udp

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 20, 2026

Copy link
Copy Markdown
Owner

P4.1c: opt-in SOCKS5 UDP ASSOCIATE and raw UDP recording.

RFC 1928 UDP ASSOCIATE in the SOCKS5 listener, off by default (ARTEX_SOCKS5_UDP_ENABLED), only when the SOCKS5 listener itself is enabled and the traffic recorder is active. With the UDP flag off, CONNECT-only SOCKS5 still refuses ASSOCIATE with 0x07 and opens no UDP socket.

IPv4 and domain destinations (resolved to IPv4); IPv6 is rejected with 0x08. FRAG != 0 is dropped, no reassembly. The client UDP source is pinned to the request or to the first datagram. Each datagram is checked before forwarding against the same target gate (ResolveUDP4 / PinnedUDP4Resolver, domain, IP and CIDR rules before and after fresh DNS) and the same egress governor (egress.Do); a denied or unresolved destination drops that datagram and the association stays usable. Upstream replies are accepted only from destinations the association sent an allowed datagram to.

Bounds: 1000 datagrams, 4 MiB per association, 2m idle, shared MaxConcurrent, and close on the TCP control connection or server stop.

Each datagram is recorded in SQLite raw_udp_datagrams (association, protocol udp, host, port, direction, timestamp, size, preview, atomic blob spill with blob_refs). No HTTP exchange row is written and no PostgreSQL migration is needed. The docs warn that a non-loopback SOCKS5 bind is an unauthenticated proxy.

Tests: ./traffic -race (parsing and RFC 1928, FRAG drop, flags off and 0x07/0x08, IPv4 and domain relay, close on control close, no exchange row, per-datagram gate and governor, atomic spill and blob refs, datagram and byte caps, idle) and the server test on a throwaway Postgres (an exact_ip rule drops 127.0.0.2 while 127.0.0.1 passes and is recorded).

P4.1c widened addrTarget to udp, which let PinnedDialer accept a non-TCP network and broke TestPinnedDialScopeUnreadableFailsClosed/network. Split addrTarget (TCP) from addrTargetUDP (UDP relay) so the TCP gate stays fail-closed while the UDP resolver keeps its parser.
@BaaRai
BaaRai merged commit e2eeea9 into main Nov 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant