Skip to main content

eggress_protocol_socks/socks4/
error.rs

1/// Error types for SOCKS4/4a protocol operations.
2#[derive(Debug, thiserror::Error)]
3pub enum Socks4Error {
4    #[error("IO error: {0}")]
5    Io(#[from] std::io::Error),
6
7    #[error("invalid SOCKS version: expected 0x04, got 0x{0:02x}")]
8    InvalidVersion(u8),
9
10    #[error("unsupported command: 0x{0:02x} (only CONNECT is supported)")]
11    UnsupportedCommand(u8),
12
13    #[error("connection refused by SOCKS server")]
14    ConnectionRefused,
15
16    #[error("connection failed: failed to connect to target")]
17    ConnectionFailed,
18
19    #[error("connection failed: no identifying userid accepted")]
20    FailedNoIdent,
21
22    #[error("connection failed: different userid than expected")]
23    FailedDifferentUser,
24
25    #[error("unknown reply status: {0}")]
26    UnknownStatus(u8),
27
28    #[error("user ID exceeds maximum length of 255 bytes")]
29    UserIdTooLong,
30
31    #[error("malformed request: {0}")]
32    MalformedRequest(String),
33
34    #[error("domain name exceeds maximum length")]
35    DomainTooLong,
36
37    #[error("unsupported address type for SOCKS4")]
38    UnsupportedAddressType,
39}