* [PATCH proxmox] fix #6768: openid: add connect and global timeout to http client
@ 2026-12-02 11:32 Martin Markert
0 siblings, 0 replies; only message in thread
From: Martin Markert @ 2026-12-02 11:32 UTC (permalink / raw)
To: pbs-devel
Without any timeout, a single unreachable address of the OpenID
provider, e.g. an IPv6 route that silently drops packets, makes the
discovery request block forever. In PBS this hangs the auth-url call
and with it the whole proxmox-backup-api daemon, so even PAM logins
fail until the daemon is killed.
Set a connect timeout, which ureq splits over all resolved addresses,
so a working IPv4 address still gets used after the IPv6 one timed
out, and a global timeout as upper bound for the whole request.
Tested with a provider name resolving to a dropped IPv6 and a
reachable IPv4 address: without this patch the request hung for more
than 90 s, with it the request succeeds via IPv4 after 6.7 s, and
fails with a timeout after 10 s if no address is reachable.
Signed-off-by: Martin Markert <keinemelodien@icloud.com>
---
proxmox-openid/src/http_client.rs | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/proxmox-openid/src/http_client.rs b/proxmox-openid/src/http_client.rs
index a21e1d5..a9bbb4f 100755
--- a/proxmox-openid/src/http_client.rs
+++ b/proxmox-openid/src/http_client.rs
@@ -1,5 +1,6 @@
use std::env;
use std::io::Read;
+use std::time::Duration;
use http::method::Method;
@@ -35,13 +36,22 @@ pub enum Error {
Other(String),
}
+// Without timeouts a single unreachable address of the provider (e.g. a broken IPv6 route that
+// silently drops packets) blocks the request forever. With a connect timeout, ureq splits it over
+// all resolved addresses and falls back to the next one, so a working IPv4 address still gets used.
+const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
+const GLOBAL_TIMEOUT: Duration = Duration::from_secs(20);
+
fn ureq_agent() -> Result<ureq::Agent, Error> {
- let mut config = ureq::Agent::config_builder().tls_config(
- ureq::tls::TlsConfig::builder()
- .provider(ureq::tls::TlsProvider::NativeTls)
- .root_certs(ureq::tls::RootCerts::PlatformVerifier)
- .build(),
- );
+ let mut config = ureq::Agent::config_builder()
+ .timeout_connect(Some(CONNECT_TIMEOUT))
+ .timeout_global(Some(GLOBAL_TIMEOUT))
+ .tls_config(
+ ureq::tls::TlsConfig::builder()
+ .provider(ureq::tls::TlsProvider::NativeTls)
+ .root_certs(ureq::tls::RootCerts::PlatformVerifier)
+ .build(),
+ );
if let Ok(val) = env::var("all_proxy").or_else(|_| env::var("ALL_PROXY")) {
let proxy = ureq::Proxy::new(&val).map_err(Box::new)?;
config = config.proxy(Some(proxy));
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 13:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 11:32 [PATCH proxmox] fix #6768: openid: add connect and global timeout to http client Martin Markert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox