mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
allow listening on multiple ports in config
This is a config compatibility break. The ability to listen on multiple ports, including both TLS and non-TLS, is necessary for running complement against grapevine.
This commit is contained in:
parent
b7ad00ef6e
commit
f7d7952f9b
4 changed files with 99 additions and 45 deletions
|
|
@ -25,10 +25,8 @@ pub(crate) static DEFAULT_PATH: Lazy<PathBuf> =
|
|||
pub(crate) struct Config {
|
||||
#[serde(default = "false_fn")]
|
||||
pub(crate) conduit_compat: bool,
|
||||
#[serde(default = "default_address")]
|
||||
pub(crate) address: IpAddr,
|
||||
#[serde(default = "default_port")]
|
||||
pub(crate) port: u16,
|
||||
#[serde(default = "default_listen")]
|
||||
pub(crate) listen: Vec<ListenConfig>,
|
||||
pub(crate) tls: Option<TlsConfig>,
|
||||
|
||||
pub(crate) server_name: OwnedServerName,
|
||||
|
|
@ -98,6 +96,19 @@ pub(crate) struct TlsConfig {
|
|||
pub(crate) key: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub(crate) enum ListenConfig {
|
||||
Tcp {
|
||||
#[serde(default = "default_address")]
|
||||
address: IpAddr,
|
||||
#[serde(default = "default_port")]
|
||||
port: u16,
|
||||
#[serde(default = "false_fn")]
|
||||
tls: bool,
|
||||
},
|
||||
}
|
||||
|
||||
fn false_fn() -> bool {
|
||||
false
|
||||
}
|
||||
|
|
@ -106,6 +117,14 @@ fn true_fn() -> bool {
|
|||
true
|
||||
}
|
||||
|
||||
fn default_listen() -> Vec<ListenConfig> {
|
||||
vec![ListenConfig::Tcp {
|
||||
address: default_address(),
|
||||
port: default_port(),
|
||||
tls: false,
|
||||
}]
|
||||
}
|
||||
|
||||
fn default_address() -> IpAddr {
|
||||
Ipv4Addr::LOCALHOST.into()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue