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
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::socket::SocketEndpoint;
use futures::channel::mpsc::SendError;
use futures::channel::oneshot::Canceled;
use std::net::{AddrParseError, IpAddr};
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
pub enum Error {
#[error("Invalid IP address: {0}")]
IpAddr(#[from] AddrParseError),
#[error("IP address not allowed: {0}")]
IpAddrNotAllowed(IpAddr),
#[error("IP address is malformed: {0}")]
IpAddrMalformed(String),
#[error("IP address is taken: {0}")]
IpAddrTaken(IpAddr),
#[error("Invalid network IP address: {0}")]
NetAddr(String),
#[error("Network IP address taken: {0}")]
NetAddrTaken(IpAddr),
#[error("Network not found for IP address: {0}")]
NetAddrMismatch(IpAddr),
#[error("Network is empty")]
NetEmpty,
#[error("Network not found")]
NetNotFound,
#[error("Invalid network CIDR: {0}/{1}")]
NetCidr(IpAddr, u8),
#[error("Network ID taken: {0}")]
NetIdTaken(String),
#[error("Invalid gateway address: {0}")]
GatewayMismatch(IpAddr),
#[error("Packet malformed: {0}")]
PacketMalformed(String),
#[error("Protocol not supported: {0}")]
ProtocolNotSupported(String),
#[error("Unknown protocol")]
ProtocolUnknown,
#[error("Endpoint taken: {0:?}")]
EndpointTaken(SocketEndpoint),
#[error("Invalid endpoint: {0:?}")]
EndpointInvalid(SocketEndpoint),
#[error("Socket closed")]
SocketClosed,
#[error("Connection error: {0}")]
ConnectionError(String),
#[error("Connection timed out")]
ConnectionTimeout,
#[error("Forbidden")]
Forbidden,
#[error("Cancelled")]
Cancelled,
#[error("{0}")]
Other(String),
}
impl From<Canceled> for Error {
fn from(_: Canceled) -> Self {
Self::Cancelled
}
}
impl From<SendError> for Error {
fn from(_: SendError) -> Self {
Self::Cancelled
}
}