-
Notifications
You must be signed in to change notification settings - Fork 506
Closed
Labels
Description
Problem description: netlink module fails with "Failed to read nameservers" error when parsing valid IPv6 address (in accordance to RFC6874)
Expected behavior: netlink would properly parse correct IPv6
Steps to reproduce:
- have an IPv6 address with Zone (aka Scope) Identifier in /etc/resolv.conf, like
nameserver fd78::1%wlp2s0(part delimited with'%'character) - spawn
i3status-rswithblock = "net"in config.toml - observe "Failed to read nameservers" error in
full_textplaceholder
This is a known issue in standard Rust library. One solution is to simply discard scope_id part, including '%' delimiter.
Possible quick fix:
diff --git a/src/netlink.rs b/src/netlink.rs
index b8557db..46bf6b6 100644
--- a/src/netlink.rs
+++ b/src/netlink.rs
@@ -438,12 +438,13 @@ async fn read_nameservers() -> Result<Vec<IpAddr>> {
.await
.error("Failed to read /etc/resolv.conf")?;
let mut nameservers = Vec::new();
+ let strip_scope_id = |s: &str| s.chars().take_while(|c| *c != '%').collect::<String>();
for line in file.lines() {
let mut line_parts = line.split_whitespace();
if line_parts.next() == Some("nameserver") {
if let Some(ip) = line_parts.next() {
- nameservers.push(ip.parse().error("Unable to parse ip")?);
+ nameservers.push(strip_scope_id(ip).parse().error("Unable to parse ip")?);
}
}
}Reactions are currently unavailable