1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! SagerNet UDP-over-TCP (UoT) protocol implementation
//!
//! This module implements the sing-box UoT protocol for tunneling UDP over TCP.
//! It supports both V1 (legacy) and V2 formats.
//!
//! ## Protocol Versions
//!
//! ### UoT V1 (Legacy)
//! - Magic address: `sp.udp-over-tcp.arpa`
//! - Mode: Multi-destination (each packet includes its target address)
//! - Packet format: `[AddrParser address][length:u16be][data]`
//!
//! ### UoT V2
//! - Magic address: `sp.v2.udp-over-tcp.arpa`
//! - Request header: `[isConnect:u8][SOCKS5 address]`
//! - Two modes based on `isConnect` byte:
//!
//! #### V2 Connect Mode (isConnect=1)
//! - Single destination specified in request header
//! - Subsequent packets: `[length:u16be][data]` (no address per packet)
//! - Uses VlessMessageStream format
//!
//! #### V2 Non-Connect Mode (isConnect=0)
//! - Multi-destination mode (same as V1)
//! - Subsequent packets: `[AddrParser address][length:u16be][data]`
//!
//! ## Address Formats (IMPORTANT!)
//!
//! Two different address formats are used:
//!
//! ### SOCKS5 Format (used in V2 request header)
//! - 0x01: IPv4 (4 bytes)
//! - 0x03: Domain (1 byte length + domain)
//! - 0x04: IPv6 (16 bytes)
//!
//! ### AddrParser Format (used in V1/V2 packet payloads)
//! - 0x00: IPv4 (4 bytes)
//! - 0x01: IPv6 (16 bytes)
//! - 0x02: Domain (1 byte length + domain)
pub use ;
/// UoT V2 connect mode stream - identical format to VlessMessageStream (length-prefixed u16be + data)
pub type UotV2Stream<S> = crateVlessMessageStream;
/// Magic address used to signal UoT V1 mode (multi-destination)
pub const UOT_V1_MAGIC_ADDRESS: &str = "sp.udp-over-tcp.arpa";
/// Magic address used to signal UoT V2 mode (optional connect mode)
pub const UOT_V2_MAGIC_ADDRESS: &str = "sp.v2.udp-over-tcp.arpa";