Skip to main content

Module socks5

Module socks5 

Source
Expand description

SOCKS5 (RFC 1928) shared primitives + the UDP-ASSOCIATE client.

The greeting and the ATYP address codec are the single source of truth for the SOCKS5 address wire format, shared by the CONNECT tunnel client (connect_via_socks5), the UDP-ASSOCIATE client (Socks5UdpAssociation), and (cross-crate) the downstream aroxy Shadowsocks / Trojan target encoders — all of which use the same ATYP | ADDR | PORT layout. The latter lets arcbox (and aroxy) route guest UDP through an upstream SOCKS5 proxy.

Structs§

Socks5UdpAssociation
A SOCKS5 UDP association (RFC 1928 §7).

Functions§

connect_via_socks5
Establishes a TCP tunnel via a SOCKS5 proxy (RFC 1928 CONNECT, no-auth subset).
decode_addr
Decodes a SOCKS5 address from the front of buf, returning (host, port, bytes_consumed), or None if truncated / bad ATYP / non-UTF8 domain.
encode_addr
Appends a SOCKS5 address (ATYP | ADDR | PORT) to out. IP-literal hosts use ATYP v4/v6; everything else is sent as a domain name (ATYP 0x03) so the proxy resolves it — avoiding fake-IP leaks.
read_addr
Reads a SOCKS5 address (ATYP | ADDR | PORT) from any async stream. Domains are decoded strictly (non-UTF8 is an error, matching decode_addr).