aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock24
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs9
3 files changed, 33 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1f6d12e..75c2d6a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -516,6 +516,15 @@ dependencies = [
]
[[package]]
+name = "ntapi"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "ntp"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -688,6 +697,7 @@ dependencies = [
"nix",
"ntp",
"rsdsl_netlinklib",
+ "sysinfo",
"thiserror",
"tokio",
]
@@ -821,6 +831,20 @@ dependencies = [
]
[[package]]
+name = "sysinfo"
+version = "0.29.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5"
+dependencies = [
+ "cfg-if",
+ "core-foundation-sys",
+ "libc",
+ "ntapi",
+ "once_cell",
+ "winapi",
+]
+
+[[package]]
name = "thiserror"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index a4f332d..3d15cd2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,7 @@ hickory-resolver = { version = "0.24.0", default-features = false, features = ["
nix = { version = "0.26.2", features = ["time"] }
ntp = "0.5.0"
rsdsl_netlinklib = { git = "https://github.com/rsdsl/netlinklib.git", version = "0.4.5", default-features = false, features = ["status"] }
+sysinfo = { version = "0.29.10", default-features = false }
thiserror = "1.0"
tokio = { version = "1.0", features = ["macros", "time", "fs", "signal"] }
diff --git a/src/main.rs b/src/main.rs
index c954a04..72ba28a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,6 +11,7 @@ use hickory_resolver::AsyncResolver;
use nix::sys::time::TimeSpec;
use nix::time::ClockId;
use rsdsl_netlinklib::Connection;
+use sysinfo::{ProcessExt, Signal, System, SystemExt};
use thiserror::Error;
const EPOCH_OFFSET: i64 = 2208988800;
@@ -71,7 +72,13 @@ async fn main() -> Result<()> {
loop {
tokio::select! {
_ = resync.tick() => match sync_time(NTP_SERVER).await {
- Ok(_) => resync = tokio::time::interval(INTERVAL),
+ Ok(_) => {
+ resync = tokio::time::interval(INTERVAL);
+
+ for dhcp6 in System::new_all().processes_by_exact_name("rsdsl_dhcp6") {
+ dhcp6.kill_with(Signal::User2);
+ }
+ }
Err(e) => eprintln!("can't synchronize system time: {}", e),
},
_ = sigterm.recv() => {