Expand description
A lightweight library for SOCKS5 and HTTP proxy protocol encoding and parsing, designed to facilitate complex proxy applications.
This library serves as a foundation layer for higher-level proxy protocols. It provides a set of Tokio-based asynchronous functions specifically for parsing and processing SOCKS5 and HTTP proxy protocol requests and responses. The library employs I/O-agnostic design, meaning it doesn’t spawn internal threads, establish network connections, or perform DNS resolution. Instead, it delegates these controls entirely to the user code, enabling flexible integration with various proxy applications.
Socks-Http-Kit supports:
-
SOCKS5 client and server implementations
- Full support for
CONNECT
,BIND
, andUDP_ASSOCIATE
commands. - Username/password authentication mechanism.
- Full support for
-
HTTP proxy client and server implementations.
- HTTP BASIC authentication support.
§SOCKS5
- Use
socks5_connect
to send handshake to SOCKS5 servers, with optional authentication information. - Use
socks5_accept
to receive and parse handshake from SOCKS5 clients, returning the SOCKS5 command type and target address. - Use
socks5_finalize_accept
to send request processing results back to SOCKS5 clients, completing the handshake process. socks5_read_udp_header
parses SOCKS5 UDP protocol headers from UDP packet buffers.socks5_write_udp_header
writes SOCKS5 UDP protocol headers to specified buffers.
§HTTP
- Use
http_connect
to send handshake to HTTP proxy servers, with optional authentication information. - Use
http_accept
to receive and parse handshake from HTTP clients, extracting target address information. - Use
http_finalize_accept
to send processing results back to HTTP clients, completing the proxy handshake process.
§Address
decode_from_reader
andencode_to_writer
provide functionality to decode/encode SOCKS5-style addresses from asynchronous streams.decode_from_buf
andencode_to_buf
support decoding/encoding SOCKS5-style addresses in memory buffers, suitable for UDP transport and similar scenarios.
§Cargo Features
The library provides two optional features, both disabled by default:
socks5
: Enables SOCKS5 proxy protocol functionality, including client and server communication, authentication, and UDP parsing and encoding functions.http
: Enables HTTP proxy protocol functionality.
Enums§
- Addr
Error - Errors that can occur address decoding operations.
- Address
- Represents a network address in various supported formats.
- Auth
Method - Authentication methods supported by the proxy protocol.
- Http
Error http
- Errors that can occur during HTTP proxy protocol operations.
- Http
Reply http
- HTTP proxy response status codes as defined in RFC 7231.
- Socks5
Command socks5
- SOCKS5 commands as defined in RFC 1928 section 4.
- Socks5
Error socks5
- Errors that can occur during SOCKS5 protocol operations.
- Socks5
Reply socks5
- SOCKS5 server reply codes as defined in RFC 1928 section 6.
Functions§
- http_
accept http
- Accepts an HTTP proxy connection request from a client.
- http_
connect http
- Establishes an HTTP proxy connection to a target server.
- http_
finalize_ accept http
- Completes an HTTP proxy connection by sending a response to the client.
- socks5_
accept socks5
- Accepts a SOCKS5 proxy connection request from a client.
- socks5_
connect socks5
- Establishes a SOCKS5 proxy connection to a target server.
- socks5_
finalize_ accept socks5
- Completes a SOCKS5 proxy connection by sending a reply to the client.
- socks5_
read_ udp_ header socks5
- Reads and parses the SOCKS5 UDP header information and destination address from a UDP packet buffer.
- socks5_
write_ udp_ header socks5
- Writes the SOCKS5 UDP header and destination address into a buffer.