Skip to content

Conversation

rcgoodfellow
Copy link
Contributor

Greetings,

When trying to send a request to an IPv6 link local address such as

http://[fe80::1234%2]:8080/foo

the changes that came from #1937 go a long ways toward making things work. However, when the address is passed to the resolver it still contains the square brackets. These square brackets are specific to URL-encoded [1] addresses and do not constitute a valid IPv6 address representation on their own AFAICT. So when [fe80::1234%2] gets passed to the getaddrinfo resolver on some platforms it's not recognized as an IPV6 address with a scope and an attempt at DNS resolution results.

This patch moves the stripping of the square brackets a bit earlier in the call chain so that both try_parse and resolve see an IPv6 address with URL-specific encoding removed.

Minimum Reproducible Example

Running the following on illumos results in a failed DNS lookup, substituting in appropriate values for the address and interface index. After applying this patch, the communication works as expected.

use tokio;
use hyper;
use std::str::FromStr;

type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

#[tokio::main]
async fn main() -> Result<()> {

    let client = hyper::Client::new();
    let uri = hyper::Uri::from_str("http://[fe80::1234%2]:914/foo").unwrap();
    let resp = client.get(uri).await?;
    println!("response: {:#?}", resp);

    Ok(())
}

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks!

@seanmonstar seanmonstar enabled auto-merge (rebase) October 13, 2021 22:50
@seanmonstar seanmonstar merged commit 910e026 into hyperium:master Oct 13, 2021
rcgoodfellow added a commit to oxidecomputer/maghemite that referenced this pull request Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants