Updated IPv6 Parser
This commit is contained in:
parent
2e20a00615
commit
3bae2f68de
1 changed files with 7 additions and 4 deletions
11
src/main.rs
11
src/main.rs
|
@ -86,7 +86,7 @@ impl Ips {
|
||||||
match response {
|
match response {
|
||||||
Ok(data) => self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned(),
|
Ok(data) => self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Could not fetch IP4, quitting");
|
println!("Could not fetch IPv4, quitting");
|
||||||
exit(75);
|
exit(75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,15 +95,18 @@ impl Ips {
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
let ipv6 = data.text().expect(":");
|
let ipv6 = match data.text() {
|
||||||
let stripped = match ipv6.strip_suffix(ipv6_interface) {
|
Ok(ip) => {ip},
|
||||||
|
Err(_) => {panic!("Expected IP, found none")},
|
||||||
|
};
|
||||||
|
let stripped = match ipv6.trim_end().strip_suffix(ipv6_interface) {
|
||||||
Some(string) => string.to_string(),
|
Some(string) => string.to_string(),
|
||||||
None => ":".to_string(),
|
None => ":".to_string(),
|
||||||
};
|
};
|
||||||
self.ipv6base = stripped;
|
self.ipv6base = stripped;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Could not fetch IP6, quitting");
|
println!("Could not fetch IPv6, quitting");
|
||||||
exit(75);
|
exit(75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue