mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
specify listener in error messages and logs
The "listening for incoming traffic on ..." log line is new, but something I've wanted even when we only supported one listener. I considered getting rid of `clippy::too_many_lines` by factoring out the construction of `app` to a separate function, but found that specifying it's type (or relevant traits) got quite hairy.
This commit is contained in:
parent
f7d7952f9b
commit
4f041f9153
3 changed files with 36 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::{
|
||||
borrow::Cow,
|
||||
fmt::{self, Display},
|
||||
net::{IpAddr, Ipv4Addr},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
|
@ -96,7 +97,7 @@ pub(crate) struct TlsConfig {
|
|||
pub(crate) key: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub(crate) enum ListenConfig {
|
||||
Tcp {
|
||||
|
|
@ -109,6 +110,23 @@ pub(crate) enum ListenConfig {
|
|||
},
|
||||
}
|
||||
|
||||
impl Display for ListenConfig {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ListenConfig::Tcp {
|
||||
address,
|
||||
port,
|
||||
tls: false,
|
||||
} => write!(f, "http://{address}:{port}"),
|
||||
ListenConfig::Tcp {
|
||||
address,
|
||||
port,
|
||||
tls: true,
|
||||
} => write!(f, "https://{address}:{port}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn false_fn() -> bool {
|
||||
false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue