Rust library for parsing OpenBSD dhcpd configuration files.
The library currently supports only OpenBSD implementation of the
dhcpd.leases
file format. See
man pages
```rust use dhcpdparser::parser; use dhcpdparser::parser::LeasesMethods;
let leases = parser::parse(" lease 192.168.0.2 { starts 2 2019/01/01 22:00:00 ends 2 2019/01/01 22:00:00 hardware type 11:11:11:11:11:11 uid Client1 client-hostname CLIENTHOSTNAME hostname TESTHOSTNAME abandoned }
lease 192.168.0.3 {
starts 1 1985/01/01 00:00:00
hardware type 22:22:22:22:22:22
uid Client2
hostname TESTHOSTNAME
}
".to_string()).expect("This should be a correct lease file");
asserteq!(leases[0].hostname.asref().unwrap(), "TESTHOSTNAME"); asserteq!(leases[1].dates.starts.unwrap().tostring(), "Monday 1985/01/01 00:00:00"); assert!(leases[1].dates.ends.is_none());
assert!(leases[0].abandoned); assert!(!leases[1].abandoned); asserteq!(leases.byleased("192.168.0.2".to_string()).unwrap(), leases[0]); ```