Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,17 @@ pub async fn run(mut opts: Opts) -> anyhow::Result<()> {
let proxy_headers = opts.proxy_headers.into_iter().collect::<HeaderMap<_>>();

let ip_strategy = match (opts.ipv4, opts.ipv6) {
(false, false) => Default::default(),
(false, false) => {
if cfg!(target_os = "macos") && (url.host_str() == Some("localhost")) {
// #784
// On macOS, localhost resolves to ::1 first, So web servers that bind to localhost tend to listen ipv6 only.
// So prefer ipv6 on macos for localhost.

hickory_resolver::config::LookupIpStrategy::Ipv6thenIpv4
} else {
Default::default()
}
}
(true, false) => hickory_resolver::config::LookupIpStrategy::Ipv4Only,
(false, true) => hickory_resolver::config::LookupIpStrategy::Ipv6Only,
(true, true) => hickory_resolver::config::LookupIpStrategy::Ipv4AndIpv6,
Expand Down