Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enode URL parse failure due to enode prefix #8339

Merged

Conversation

sergerad
Copy link
Contributor

@sergerad sergerad commented May 22, 2024

Relates to PR #8188

Hack to fix parsing of enode strings with the URL crate.

The enode prefix causes the parser to go down this host parsing logic which does not handle ipv4:

    pub fn parse_opaque(input: &str) -> Result<Self, ParseError> {
// ...snip...
        if input.find(is_invalid_host_char).is_some() {
            Err(ParseError::InvalidDomainCharacter)
        } else {
            Ok(Host::Domain(
                utf8_percent_encode(input, CONTROLS).to_string(),
            ))
        }
    }

Comment on lines +81 to +85
// Parse the URL with enode prefix replaced with http.
// The enode prefix causes the parser to use parse_opaque() on
// the host str which only handles domains and ipv6, not ipv4.
let url = Url::parse(s.replace("enode://", "http://").as_str())
.map_err(|e| NodeRecordParseError::InvalidUrl(e.to_string()))?;
Copy link
Member

Choose a reason for hiding this comment

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

ah I see, this should work

@Rjected Rjected merged commit 3510f0f into paradigmxyz:dan/dns-resolution-on-enodes May 22, 2024
24 checks passed
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.

None yet

2 participants