diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-03-19 19:49:52 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-03-19 19:49:52 +0100 |
commit | 56e897f1fc3a7c4b607314397225dd32cc878aa5 (patch) | |
tree | 5d927b5ae07853d3a9b5a5399cfebed150fc7462 /src | |
parent | c8567f9927fb52473438fbc2ce35bcc403891059 (diff) |
Revert "wait for rsdsl_pppoe 'lease' file"
This reverts commit 00d06a7035f81670ac0bdf71ff803bee5dd8668d.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index e114fcc..79f627b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,6 @@ use rsdsl_netlinkd::{addr, link, route}; use std::fs::File; use std::net::{IpAddr, Ipv4Addr}; use std::path::Path; -use std::thread; -use std::time::Duration; use notify::event::{CreateKind, ModifyKind}; use notify::{Event, EventKind, RecursiveMode, Watcher}; @@ -15,26 +13,18 @@ fn main() -> Result<()> { link::up("eth0".into())?; link::up("eth1".into())?; - let mut watcher = loop { - match notify::recommended_watcher(|res: notify::Result<Event>| match res { - Ok(event) => match event.kind { - EventKind::Create(kind) if kind == CreateKind::File => { - configure_wan(); - } - EventKind::Modify(kind) if matches!(kind, ModifyKind::Data(_)) => { - configure_wan(); - } - _ => {} - }, - Err(e) => println!("[netlinkd] watch error: {}", e), - }) { - Ok(v) => break v, - Err(_) => { - println!("[netlinkd] waiting for rsdsl_pppoe"); - thread::sleep(Duration::from_secs(8)); + let mut watcher = notify::recommended_watcher(|res: notify::Result<Event>| match res { + Ok(event) => match event.kind { + EventKind::Create(kind) if kind == CreateKind::File => { + configure_wan(); } - } - }; + EventKind::Modify(kind) if matches!(kind, ModifyKind::Data(_)) => { + configure_wan(); + } + _ => {} + }, + Err(e) => println!("[netlinkd] watch error: {}", e), + })?; watcher.watch( Path::new("/data/pppoe.ip_config"), |