aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2022-11-03 17:33:42 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2022-11-03 17:33:42 +0100
commita8b909471790bc933171002e94a0712e8847b190 (patch)
tree98c9f6d58684df713d6b55346301a8f8c59fd1e3
parentee21269390169d75f5c5f46f4d5aaed4b052f3bc (diff)
accept optional retry interval in addition to refresh interval
closes #9
-rw-r--r--src/main.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index ff89762..c303585 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -118,6 +118,7 @@ struct ConfigIpv4 {
records: Vec<i32>,
link: String,
interval: u64,
+ retry: Option<u64>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -127,6 +128,7 @@ struct ConfigIpv6 {
records: Vec<i32>,
link: String,
interval: u64,
+ retry: Option<u64>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -137,6 +139,7 @@ struct ConfigNet6 {
len: u8,
link: String,
interval: u64,
+ retry: Option<u64>,
}
fn main() -> Result<()> {
@@ -167,7 +170,8 @@ fn main() -> Result<()> {
Err(e) => eprintln!("failed to push ipv4 address: {}", e),
}
- thread::sleep(Duration::from_secs(ipv4_1.interval));
+ let secs = ipv4_1.retry.unwrap_or(ipv4_1.interval);
+ thread::sleep(Duration::from_secs(secs));
}
});
@@ -178,7 +182,8 @@ fn main() -> Result<()> {
Err(e) => eprintln!("failed to monitor ipv4 address: {}", e),
}
- thread::sleep(Duration::from_secs(ipv4_2.interval));
+ let secs = ipv4_2.retry.unwrap_or(ipv4_2.interval);
+ thread::sleep(Duration::from_secs(secs));
}
});
}
@@ -196,7 +201,8 @@ fn main() -> Result<()> {
Err(e) => eprintln!("failed to push ipv6 address: {}", e),
}
- thread::sleep(Duration::from_secs(ipv6_1.interval));
+ let secs = ipv6_1.retry.unwrap_or(ipv6_1.interval);
+ thread::sleep(Duration::from_secs(secs));
}
});
@@ -207,7 +213,8 @@ fn main() -> Result<()> {
Err(e) => eprintln!("failed to monitor ipv6 address: {}", e),
}
- thread::sleep(Duration::from_secs(ipv6_2.interval));
+ let secs = ipv6_2.retry.unwrap_or(ipv6_2.interval);
+ thread::sleep(Duration::from_secs(secs));
}
});
}
@@ -225,7 +232,8 @@ fn main() -> Result<()> {
Err(e) => eprintln!("failed to push ipv6 prefix: {}", e),
}
- thread::sleep(Duration::from_secs(net6_1.interval));
+ let secs = net6_1.retry.unwrap_or(net6_1.interval);
+ thread::sleep(Duration::from_secs(secs));
}
});
@@ -236,7 +244,8 @@ fn main() -> Result<()> {
Err(e) => eprintln!("failed to monitor ipv6 prefix: {}", e),
}
- thread::sleep(Duration::from_secs(net6_2.interval));
+ let secs = net6_2.retry.unwrap_or(net6_2.interval);
+ thread::sleep(Duration::from_secs(secs));
}
});
}