Refactor
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -9,11 +9,7 @@ use config::CONFIG;
|
|||||||
use ip_getter::get_ip_string;
|
use ip_getter::get_ip_string;
|
||||||
|
|
||||||
|
|
||||||
async fn update() {
|
async fn update(current_ip: String) {
|
||||||
let current_ip = get_ip_string()
|
|
||||||
.await
|
|
||||||
.unwrap_or_else(|err| panic!("Can't get current ip! Err: {}", err));
|
|
||||||
|
|
||||||
let zones = get_zones()
|
let zones = get_zones()
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(
|
.unwrap_or_else(
|
||||||
@@ -82,9 +78,19 @@ async fn update() {
|
|||||||
async fn main() {
|
async fn main() {
|
||||||
let mut interval = time::interval(Duration::from_secs(CONFIG.check_interval_seconds));
|
let mut interval = time::interval(Duration::from_secs(CONFIG.check_interval_seconds));
|
||||||
|
|
||||||
|
let mut prev_ip: String = "".to_string();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
update().await;
|
let current_ip = get_ip_string()
|
||||||
println!("Updated!");
|
.await
|
||||||
|
.unwrap_or_else(|err| panic!("Can't get current ip! Err: {}", err));
|
||||||
|
|
||||||
|
if current_ip.eq(&prev_ip) {
|
||||||
|
prev_ip = current_ip.clone();
|
||||||
|
|
||||||
|
update(current_ip).await;
|
||||||
|
println!("Updated!");
|
||||||
|
}
|
||||||
|
|
||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user