Expand description
Trojan protocol parsing and serialization.
This module provides zero-copy parsers for trojan request headers and UDP packets. It is intentionally minimal and DRY: address parsing is shared by request and UDP paths.
Structs§
Enums§
- HostRef
- Parse
Error - Parse
Result - Parse result for incremental parsing.
- Write
Error - Errors that can occur when writing protocol data.
Constants§
- ATYP_
DOMAIN - ATYP_
IPV4 - ATYP_
IPV6 - CMD_
CONNECT - CMD_MUX
- Mux command for trojan-go multiplexing extension.
- CMD_
UDP_ ASSOCIATE - CRLF
- HASH_
LEN - MAX_
DOMAIN_ LEN - Maximum domain name length.
- MAX_
UDP_ PAYLOAD - Maximum UDP payload size (8 KiB, consistent with trojan-go).
Functions§
- is_
valid_ hash - Validates that the hash is a valid hex string (a-f, A-F, 0-9).
- parse_
request - parse_
udp_ packet - write_
request_ header - Writes a Trojan request header to the buffer.
- write_
udp_ packet - Writes a UDP packet to the buffer.