From 3bae2f68de7932e4762a1c383e5ff921c9c54a6e Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 27 Feb 2023 03:20:45 +0100 Subject: [PATCH] Updated IPv6 Parser --- src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 25a6627..3a5d0d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,7 +86,7 @@ impl Ips { match response { Ok(data) => self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned(), Err(e) => { - println!("Could not fetch IP4, quitting"); + println!("Could not fetch IPv4, quitting"); exit(75); } } @@ -95,15 +95,18 @@ impl Ips { match response { Ok(data) => { - let ipv6 = data.text().expect(":"); - let stripped = match ipv6.strip_suffix(ipv6_interface) { + let ipv6 = match data.text() { + Ok(ip) => {ip}, + Err(_) => {panic!("Expected IP, found none")}, + }; + let stripped = match ipv6.trim_end().strip_suffix(ipv6_interface) { Some(string) => string.to_string(), None => ":".to_string(), }; self.ipv6base = stripped; } Err(e) => { - println!("Could not fetch IP6, quitting"); + println!("Could not fetch IPv6, quitting"); exit(75); } }