Skip to main content

Crate trojan_proto

Crate trojan_proto 

Source
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§

AddressRef
TrojanRequest
UdpPacket

Enums§

HostRef
ParseError
ParseResult
Parse result for incremental parsing.
WriteError
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.