Closes #16
This commit is contained in:
parent
6540041f4b
commit
5186bded04
1 changed files with 22 additions and 12 deletions
34
src/main.rs
34
src/main.rs
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue