Closes #16
This commit is contained in:
parent
6540041f4b
commit
5186bded04
1 changed files with 22 additions and 12 deletions
10
src/main.rs
10
src/main.rs
|
@ -272,8 +272,13 @@ impl Ips {
|
|||
|
||||
match get(ipv4uri) {
|
||||
Ok(data) => {
|
||||
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,6 +290,7 @@ impl Ips {
|
|||
|
||||
match get(ipv6uri) {
|
||||
Ok(data) => {
|
||||
if data.status() == 200 {
|
||||
let ipv6 = match data.text() {
|
||||
Ok(ip) => {ip},
|
||||
Err(_) => {panic!("Expected IP, found none")},
|
||||
|
@ -296,6 +302,10 @@ impl Ips {
|
|||
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");
|
||||
ret = false;
|
||||
|
|
Loading…
Reference in a new issue