Updated IPv6 Parser

This commit is contained in:
Neshura 2023-02-27 03:20:45 +01:00
parent 2e20a00615
commit 3bae2f68de
No known key found for this signature in database
GPG key ID: ACDF5B6EBECF6B0A

View file

@ -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);
} }
} }