Closed
Description
This example uses reqwest
for simplicity:
#[tokio::main]
async fn main() -> () {
let builder = reqwest::ClientBuilder::new();
let builder = builder.local_address(std::net::IpAddr::from([0, 0, 0, 0]));
let client = builder.build().unwrap();
match client.get("http://ipv6.google.com").send().await {
Ok(r) => {
println!("Response: {:?}", r);
}
Err(e) => {
println!("Error: {:?}", e);
}
}
}
Error message:
thread 'main' panicked at 'missing connect error', /home/alexwl/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/hyper-0.13.8/src/client/connect/http.rs:544:13
IPv6-only domains (only AAAA
DNS records, not A
) like ipv6.google.com
, are rare, but they do exist in the wild.
The problem is that split_by_preference
removes IPv6 addresses from IpAddrs
when the local_addr
is IPv4:
hyper/src/client/connect/dns.rs
Lines 203 to 225 in 523d66a
connect
panics when the self.addrs
is empty and the err
is None
:
hyper/src/client/connect/http.rs
Lines 524 to 545 in 523d66a
I think connect
should return an error instead of panicking when the err
is None
.
For example:
match err {
Some(e) => Err(e),
None => Err(std::io::Error::new(
std::io::ErrorKind::NotConnected,
"Network unreachable"
))
}