mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
Add support for HAProxy proxy protocol for listeners
This commit is contained in:
parent
99f3e2aecd
commit
3247c64cd8
7 changed files with 234 additions and 14 deletions
|
|
@ -137,22 +137,35 @@ pub(crate) enum ListenTransport {
|
|||
port: u16,
|
||||
#[serde(default = "false_fn")]
|
||||
tls: bool,
|
||||
#[serde(default = "false_fn")]
|
||||
proxy_protocol: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl Display for ListenTransport {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
match *self {
|
||||
ListenTransport::Tcp {
|
||||
address,
|
||||
port,
|
||||
tls: false,
|
||||
} => write!(f, "http://{address}:{port}"),
|
||||
ListenTransport::Tcp {
|
||||
address,
|
||||
port,
|
||||
tls: true,
|
||||
} => write!(f, "https://{address}:{port}"),
|
||||
tls,
|
||||
proxy_protocol,
|
||||
} => {
|
||||
let scheme = format!(
|
||||
"{}{}",
|
||||
if proxy_protocol {
|
||||
"proxy+"
|
||||
} else {
|
||||
""
|
||||
},
|
||||
if tls {
|
||||
"https"
|
||||
} else {
|
||||
"http"
|
||||
}
|
||||
);
|
||||
write!(f, "{scheme}://{address}:{port}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -379,6 +392,7 @@ fn default_listen() -> Vec<ListenConfig> {
|
|||
address: default_address(),
|
||||
port: default_port(),
|
||||
tls: false,
|
||||
proxy_protocol: false,
|
||||
},
|
||||
}]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue