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) {
Ok(data) => {
self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned();
ret = true;
if data.status() == 200 {
self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned();
ret = true;
}
else {
ret = false;
}
},
Err(_e) => {
println!("Could not fetch IPv4");
@ -285,16 +290,21 @@ impl Ips {
match get(ipv6uri) {
Ok(data) => {
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;
ret = true && ret; // Only set ret to true if previous ret is also true
if data.status() == 200 {
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;
ret = true && ret; // Only set ret to true if previous ret is also true
}
else {
ret = false;
}
}
Err(_e) => {
println!("Could not fetch IPv6");