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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use std::{io, net::SocketAddr, result, time::SystemTimeError};
use openssl::error::ErrorStack;
use serde::Serialize;
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, Serialize)]
pub enum Error {
#[error("no server certificate presented")]
NoServerCertificate,
#[error("no client certificate presented")]
NoClientCertificate,
#[error("remote node has wrong ID")]
WrongId,
#[error(
"need both or none of cert, secret_key in network config, and at least one known address"
)]
InvalidConfig,
#[error("own certificate invalid")]
OwnCertificateInvalid(#[source] ValidationError),
#[error("failed to create listener on {1}")]
ListenerCreation(
#[serde(skip_serializing)]
#[source]
io::Error,
SocketAddr,
),
#[error("failed to get listener addr")]
ListenerAddr(
#[serde(skip_serializing)]
#[source]
io::Error,
),
#[error("failed to convert listener to tokio")]
ListenerConversion(
#[serde(skip_serializing)]
#[source]
io::Error,
),
#[error("failed to resolve network address")]
ResolveAddr(
#[serde(skip_serializing)]
#[source]
io::Error,
),
#[error("failed to send message")]
MessageNotSent(
#[serde(skip_serializing)]
#[source]
io::Error,
),
#[error("failed to create acceptor")]
AcceptorCreation(
#[serde(skip_serializing)]
#[source]
ErrorStack,
),
#[error("failed to configure connector")]
ConnectorConfiguration(
#[serde(skip_serializing)]
#[source]
ErrorStack,
),
#[error("failed to generate cert")]
CertificateGeneration(
#[serde(skip_serializing)]
#[source]
ErrorStack,
),
#[error("handshake error: {0}")]
Handshake(
#[serde(skip_serializing)]
#[from]
HandshakeError<TcpStream>,
),
#[error("TLS validation error: {0}")]
TlsValidation(#[from] ValidationError),
#[error("system time error: {0}")]
SystemTime(
#[serde(skip_serializing)]
#[from]
SystemTimeError,
),
#[error("could not interact with systemd: {0}")]
SystemD(#[serde(skip_serializing)] io::Error),
#[error(transparent)]
Anyhow(
#[serde(skip_serializing)]
#[from]
anyhow::Error,
),
#[error("failed to create outgoing connection as server has stopped")]
ServerStopped,
}