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
68
69
70
71
72
use std::{io, net::SocketAddr, result, time::SystemTimeError};
use openssl::error::ErrorStack;
use thiserror::Error;
use tokio::net::TcpStream;
use tokio_openssl::HandshakeError;
use crate::tls::ValidationError;
pub(super) type Result<T> = result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("no server certificate presented")]
NoServerCertificate,
#[error("no client certificate presented")]
NoClientCertificate,
#[error("remote node has wrong ID")]
WrongId,
#[error("need either both or none of cert, secret_key in network config")]
InvalidConfig,
#[error("own certificate invalid")]
OwnCertificateInvalid(#[source] ValidationError),
#[error("failed to create listener on {1}")]
ListenerCreation(#[source] io::Error, SocketAddr),
#[error("failed to get listener addr")]
ListenerAddr(#[source] io::Error),
#[error("failed to convert listener to tokio")]
ListenerConversion(#[source] io::Error),
#[error("failed to resolve network address")]
ResolveAddr(#[source] io::Error),
#[error("failed to send message")]
MessageNotSent(#[source] io::Error),
#[error("failed to create acceptor")]
AcceptorCreation(#[source] ErrorStack),
#[error("failed to configure connector")]
ConnectorConfiguration(#[source] ErrorStack),
#[error("failed to generate cert")]
CertificateGeneration(#[source] ErrorStack),
#[error("handshake error: {0}")]
Handshake(#[from] HandshakeError<TcpStream>),
#[error("TLS validation error: {0}")]
TlsValidation(#[from] ValidationError),
#[error("system time error: {0}")]
SystemTime(#[from] SystemTimeError),
#[error("could not interact with systemd: {0}")]
SystemD(io::Error),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
#[error("failed to create outgoing connection as server has stopped")]
ServerStopped,
}