fix(#6): connect/read timeouts on every HTTP agent

No ureq call had a timeout, so a silent registry hung pull forever. One
oci::agent() builder (30 s connect + per-read) now backs registry agents,
local ones included, and the kernel downloads.
This commit is contained in:
2026-10-22 19:54:09 +02:00
parent 2231e4efe1
commit 56762648e3
3 changed files with 12 additions and 4 deletions
+8 -2
View File
@@ -73,6 +73,12 @@ pub fn is_public(ip: IpAddr) -> bool {
}
}
/// Every HTTP agent: a silent server (connect or any single read, TLS handshake included) fails after 30 s instead of hanging.
pub fn agent() -> ureq::AgentBuilder {
let t = std::time::Duration::from_secs(30);
ureq::AgentBuilder::new().timeout_connect(t).timeout_read(t)
}
/// Registry the user named as local: `localhost` or a non-public IP literal. Decided by name only --
/// a DNS name pointing at loopback (e.g. *.127.0.0.1.nip.io) is controlled by whoever owns the zone.
fn explicit_local(registry: &str) -> bool {
@@ -85,9 +91,9 @@ fn explicit_local(registry: &str) -> bool {
/// (e.g. localhost:5000, 192.168.1.5:5000) was chosen by the user and keeps the default agent.
fn agent_for(registry: &str) -> ureq::Agent {
if explicit_local(registry) {
return ureq::agent();
return agent().build();
}
ureq::AgentBuilder::new()
agent()
.resolver(|addr: &str| -> std::io::Result<Vec<SocketAddr>> {
let ok: Vec<SocketAddr> = addr.to_socket_addrs()?.filter(|a| is_public(a.ip())).collect();
if ok.is_empty() {