Skip to content

Commit

Permalink
Fix enode URL parse failure due to enode prefix (#8339)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad authored and Rjected committed May 23, 2024
1 parent f17b065 commit cdfdaff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/net/discv5/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl ConfigBuilder {
self
}

/// Adds boot nodes in the form a list of [`NodeRecord`]s, parsed enodes.
/// Adds boot nodes in the form a list of [`DNSNodeRecord`]s, parsed enodes.
pub fn add_unsigned_boot_nodes<T: Into<DNSNodeRecord>>(
mut self,
enodes: impl Iterator<Item = T>,
Expand Down
6 changes: 5 additions & 1 deletion crates/net/types/src/dns_node_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ impl FromStr for DNSNodeRecord {
fn from_str(s: &str) -> Result<Self, Self::Err> {
use url::Url;

let url = Url::parse(s).map_err(|e| NodeRecordParseError::InvalidUrl(e.to_string()))?;
// 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()))?;

let host = url
.host()
Expand Down

0 comments on commit cdfdaff

Please sign in to comment.