Skip to content

feat(traffic): opt-in SOCKS5 CONNECT listener and raw TCP recording (P4.1a) - #431

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

BaaRai merged 5 commits into
mainfrom
feat/proxy-socks5-raw-tcp

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 20, 2026

Copy link
Copy Markdown
Owner

P4.1a: opt-in SOCKS5 CONNECT listener and raw TCP recording.

RFC 1928 SOCKS5 inbound listener in the traffic recorder, off by default (ARTEX_SOCKS5_ENABLED, ARTEX_SOCKS5_ADDR, loopback 127.0.0.1:1080). CONNECT only; BIND and UDP ASSOCIATE are refused with 0x07 (UDP is P4.1c). IPv4, domain and IPv6 addressing; no-auth for loopback peers; RFC 1929 username/password accepted so the pace marker can ride in the username.

Before dialing, each connection goes through the same egress governor (egress.Do) and the same target gate (interceptor.DialSOCKS5, reusing dialTarget, blockRule and targetCheck). Bytes are relayed half-close aware with bounded capture (MaxConcurrent 64, 4 MiB per direction, 8 KiB preview, 2m idle, 10s handshake, 30s dial, 30s pace).

Each completed stream is recorded in the SQLite traffic index as one raw_tcp_streams row (protocol tcp, host, port, timestamps, c2s/s2c bytes, truncated flag, preview and atomic blob spill with blob_refs). No HTTP exchanges row is written and no PostgreSQL migration is needed.

Flag off: no listener, the HTTP MITM proxy is byte-identical, and agents keep HTTP_PROXY, HTTPS_PROXY and ALL_PROXY. The listener only starts when the traffic recorder is enabled. A non-loopback bind accepts any username/password, so it is an unauthenticated proxy; the docs say so and the default is loopback.

Tests: go test -race ./traffic (handshake, auth and half-close, no exchange row, target gate and governor refusal before dial, caps, truncation and blob spill, IPv4/IPv6/DNS, concurrency and idle) and the server test on a throwaway Postgres.

@BaaRai
BaaRai merged commit 5c298aa into main Nov 20, 2026
6 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