This commit is contained in:
Neshura 2023-03-15 21:36:52 +01:00
parent 6540041f4b
commit 5186bded04
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -272,8 +272,13 @@ impl Ips {
match get(ipv4uri) { match get(ipv4uri) {
Ok(data) => { Ok(data) => {
self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned(); if data.status() == 200 {
ret = true; self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned();
ret = true;
}
else {
ret = false;
}
}, },
Err(_e) => { Err(_e) => {
println!("Could not fetch IPv4"); println!("Could not fetch IPv4");
@ -285,16 +290,21 @@ impl Ips {
match get(ipv6uri) { match get(ipv6uri) {
Ok(data) => { Ok(data) => {
let ipv6 = match data.text() { if data.status() == 200 {
Ok(ip) => {ip}, let ipv6 = match data.text() {
Err(_) => {panic!("Expected IP, found none")}, Ok(ip) => {ip},
}; Err(_) => {panic!("Expected IP, found none")},
let stripped = match ipv6.trim_end().strip_suffix(ipv6_interface) { };
Some(string) => string.to_string(), let stripped = match ipv6.trim_end().strip_suffix(ipv6_interface) {
None => ":".to_string(), Some(string) => string.to_string(),
}; None => ":".to_string(),
self.ipv6base = stripped; };
ret = true && ret; // Only set ret to true if previous ret is also true self.ipv6base = stripped;
ret = true && ret; // Only set ret to true if previous ret is also true
}
else {
ret = false;
}
} }
Err(_e) => { Err(_e) => {
println!("Could not fetch IPv6"); println!("Could not fetch IPv6");