wireguard_netstack/
error.rs1use std::net::SocketAddr;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 #[error("Failed to parse WireGuard config: {0}")]
12 ConfigParse(String),
13
14 #[error("Invalid base64 key: {0}")]
15 InvalidKey(String),
16
17 #[error("Invalid endpoint format: {0}")]
18 InvalidEndpoint(String),
19
20 #[error("Invalid address: {0}")]
21 InvalidAddress(String),
22
23 #[error("DNS resolution failed for '{hostname}': {message}")]
24 DnsResolution { hostname: String, message: String },
25
26 #[error("All DoH servers failed")]
27 DnsAllServersFailed,
28
29 #[error("No DNS records found for '{0}'")]
30 DnsNoRecords(String),
31
32 #[error("DNS error: RCODE={0}")]
33 DnsError(u16),
34
35 #[error("DNS response too short")]
36 DnsResponseTooShort,
37
38 #[error("DNS name extends beyond packet")]
39 DnsNameTooLong,
40
41 #[error("DNS label too long: {0}")]
42 DnsLabelTooLong(String),
43
44 #[error("Invalid HTTP response: {0}")]
45 InvalidHttpResponse(String),
46
47 #[error("DoH server returned error: {0}")]
48 DohServerError(String),
49
50 #[error("WireGuard handshake timeout after {0:?}")]
51 HandshakeTimeout(std::time::Duration),
52
53 #[error("Failed to create WireGuard tunnel: {0}")]
54 TunnelCreation(String),
55
56 #[error("TCP connection to {addr} failed: {message}")]
57 TcpConnect { addr: SocketAddr, message: String },
58
59 #[error("TCP connection failed: {0}")]
60 TcpConnectGeneric(String),
61
62 #[error("TCP connection timeout")]
63 TcpTimeout,
64
65 #[error("TCP send failed: {0}")]
66 TcpSend(String),
67
68 #[error("TCP receive failed: {0}")]
69 TcpRecv(String),
70
71 #[error("Read timeout")]
72 ReadTimeout,
73
74 #[error("Write timeout")]
75 WriteTimeout,
76
77 #[error("Short write: {written} of {expected} bytes")]
78 ShortWrite { written: usize, expected: usize },
79
80 #[error("Connection closed")]
81 ConnectionClosed,
82
83 #[error("IPv6 not supported")]
84 Ipv6NotSupported,
85
86 #[error("IO error: {0}")]
87 Io(#[from] std::io::Error),
88
89 #[error("Channel closed")]
90 ChannelClosed,
91
92 #[error("TLS handshake failed: {0}")]
93 TlsHandshake(String),
94}