diff --git a/Cargo.lock b/Cargo.lock index 46682d9..3338ee8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -790,9 +790,9 @@ dependencies = [ [[package]] name = "dhcproto" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcee045385d5f7819022821f41209b9945d17550760b0b2349aaef4ecfa14bc3" +checksum = "0f50f70ee36644509addb2a569d132eef63c579ba1395b735eeef56675fbcbc7" dependencies = [ "dhcproto-macros", "hex", @@ -3684,9 +3684,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "unix-udp-sock" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c047b54fcdda2aa4d4feffde101e8742570134e1840ef2a0d26b75cbfd2ba6" +checksum = "1bd7ba2f35a34643df43018437e1e96be3910407bf2944651e975aadd4ff557d" dependencies = [ "bytes", "futures-core", diff --git a/Cargo.toml b/Cargo.toml index 08bd3de..f97fb09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,21 +18,22 @@ anyhow = { version = "1.0", features = ["backtrace"] } async-trait = "0.1" bytes = "1.1" clap = { version = "4.1.8", features = ["derive", "env"] } -dhcproto = "0.9.0" +dhcproto = "0.10.0" futures = { version = "0.3", default-features = false, features = ["std"] } ipnet = { features = ["serde"], version = "2.4.0" } pnet = { features = ["serde", "std"], version = "0.33.0" } prometheus = "0.13.0" prometheus-static-metric = "0.5" -tokio = { version = "1.26.0", features = [ "full" ] } +tokio = { version = "1.26.0", features = ["full"] } tracing = "0.1.22" tracing-futures = "0.2" tracing-subscriber = { features = ["env-filter", "json"], version = "0.3" } trust-dns-proto = { version = "0.22.0", default-features = false } thiserror = "1.0" rand = "0.8" -socket2 = { version = "0.4.9", features = ["all"] } # TODO: update when tokio sockets impl AsFd, then update unix-udp-sock +socket2 = { version = "0.4.9", features = [ + "all", +] } # TODO: update when tokio sockets impl AsFd, then update unix-udp-sock serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.8" - diff --git a/bin/tests/basic.rs b/bin/tests/basic.rs index bfc0885..a494e6d 100644 --- a/bin/tests/basic.rs +++ b/bin/tests/basic.rs @@ -440,14 +440,14 @@ fn test_requested_opts() -> Result<()> { // create DISCOVER msg & send let msg_args = DiscoverBuilder::default() .giaddr([192, 168, 2, 1]) - .req_list([v4::OptionCode::NISDomain]) + .req_list([v4::OptionCode::NisDomain]) .build()?; let resp = client.run(MsgType::Discover(msg_args))?; assert_eq!(resp.opts().msg_type().unwrap(), v4::MessageType::Offer); assert_eq!( - resp.opts().get(v4::OptionCode::NISDomain).unwrap(), - &v4::DhcpOption::NISDomain("testdomain.com".to_string()) + resp.opts().get(v4::OptionCode::NisDomain).unwrap(), + &v4::DhcpOption::NisDomain("testdomain.com".to_string()) ); Ok(()) } diff --git a/dora-core/Cargo.toml b/dora-core/Cargo.toml index e326768..291610d 100644 --- a/dora-core/Cargo.toml +++ b/dora-core/Cargo.toml @@ -13,7 +13,7 @@ license = "MPL-2.0" env-parser = { path = "../libs/env-parser" } topo_sort = { path = "../libs/topo_sort" } # third party -async-trait = { workspace = true } +async-trait = { workspace = true } anyhow = { workspace = true } bytes = { workspace = true } chrono = "0.4" @@ -23,7 +23,7 @@ futures = { workspace = true } lazy_static = "1.4" tokio = { workspace = true } tokio-stream = "0.1" -tokio-util = { version = "0.7.0", features = [ "codec", "net" ] } +tokio-util = { version = "0.7.0", features = ["codec", "net"] } tracing = { workspace = true } tracing-futures = { workspace = true } tracing-subscriber = { workspace = true } @@ -35,7 +35,7 @@ rand = { workspace = true } clap = { workspace = true } socket2 = { workspace = true } libc = "0.2.126" -unix-udp-sock = "0.6.0" +unix-udp-sock = "0.7.0" pnet = { workspace = true } [dev-dependencies] diff --git a/libs/config/src/v4.rs b/libs/config/src/v4.rs index 77fa2b8..c15c116 100644 --- a/libs/config/src/v4.rs +++ b/libs/config/src/v4.rs @@ -873,9 +873,9 @@ mod tests { (DhcpOption::DomainNameServer(vec![[8, 8, 8, 8].into()]), res), ); reserved_opts.insert( - OptionCode::NISDomain, + OptionCode::NisDomain, ( - DhcpOption::NISDomain("testdomain.com.".to_string()), + DhcpOption::NisDomain("testdomain.com.".to_string()), another, ), ); diff --git a/libs/config/src/wire/v4.rs b/libs/config/src/wire/v4.rs index a1f9f6e..f8e1f04 100644 --- a/libs/config/src/wire/v4.rs +++ b/libs/config/src/wire/v4.rs @@ -412,59 +412,66 @@ impl Serialize for Opts { } fn to_opt(code: &OptionCode, opt: &DhcpOption) -> Option<(u8, Opt)> { - use dora_core::dhcproto::v4::DhcpOption::*; + use dora_core::dhcproto::v4::DhcpOption as O; match opt { - Pad | End => None, - SubnetMask(addr) - | SwapServer(addr) - | BroadcastAddr(addr) - | RouterSolicitationAddr(addr) - | RequestedIpAddress(addr) - | ServerIdentifier(addr) - | SubnetSelection(addr) => Some(((*code).into(), Opt::Ip(MaybeList::Val(*addr)))), - TimeServer(ips) - | NameServer(ips) - | Router(ips) - | DomainNameServer(ips) - | LogServer(ips) - | QuoteServer(ips) - | LprServer(ips) - | ImpressServer(ips) - | ResourceLocationServer(ips) - | XFontServer(ips) - | XDisplayManager(ips) - | NIS(ips) - | NTPServers(ips) - | NetBiosNameServers(ips) - | NetBiosDatagramDistributionServer(ips) => { + O::Pad | O::End => None, + O::SubnetMask(addr) + | O::SwapServer(addr) + | O::BroadcastAddr(addr) + | O::RouterSolicitationAddr(addr) + | O::RequestedIpAddress(addr) + | O::ServerIdentifier(addr) + | O::SubnetSelection(addr) => Some(((*code).into(), Opt::Ip(MaybeList::Val(*addr)))), + O::TimeServer(ips) + | O::NameServer(ips) + | O::Router(ips) + | O::DomainNameServer(ips) + | O::LogServer(ips) + | O::QuoteServer(ips) + | O::LprServer(ips) + | O::ImpressServer(ips) + | O::ResourceLocationServer(ips) + | O::XFontServer(ips) + | O::XDisplayManager(ips) + | O::NisServers(ips) + | O::NtpServers(ips) + | O::NetBiosNameServers(ips) + | O::NetBiosDatagramDistributionServer(ips) => { Some(((*code).into(), Opt::Ip(MaybeList::List(ips.clone())))) } - TimeOffset(num) => Some(((*code).into(), Opt::I32(MaybeList::Val(*num)))), - DefaultTcpTtl(num) | DefaultIpTtl(num) | OptionOverload(num) => { + O::TimeOffset(num) => Some(((*code).into(), Opt::I32(MaybeList::Val(*num)))), + O::DefaultTcpTtl(num) | O::DefaultIpTtl(num) | O::OptionOverload(num) => { Some(((*code).into(), Opt::U8(MaybeList::Val(*num)))) } - NetBiosNodeType(ntype) => Some(((*code).into(), Opt::U8(MaybeList::Val((*ntype).into())))), - IpForwarding(b) - | NonLocalSrcRouting(b) - | AllSubnetsLocal(b) - | PerformMaskDiscovery(b) - | MaskSupplier(b) - | PerformRouterDiscovery(b) - | EthernetEncapsulation(b) - | TcpKeepaliveGarbage(b) => Some(((*code).into(), Opt::Bool(MaybeList::Val(*b)))), - ArpCacheTimeout(num) - | TcpKeepaliveInterval(num) - | AddressLeaseTime(num) - | Renewal(num) - | Rebinding(num) => Some(((*code).into(), Opt::U32(MaybeList::Val(*num)))), - Hostname(s) | MeritDumpFile(s) | DomainName(s) | ExtensionsPath(s) | NISDomain(s) - | RootPath(s) | NetBiosScope(s) | Message(s) => { - Some(((*code).into(), Opt::Str(MaybeList::Val(s.clone())))) + O::NetBiosNodeType(ntype) => { + Some(((*code).into(), Opt::U8(MaybeList::Val((*ntype).into())))) } - BootFileSize(num) | MaxDatagramSize(num) | InterfaceMtu(num) | MaxMessageSize(num) => { - Some(((*code).into(), Opt::U16(MaybeList::Val(*num)))) - } - Unknown(opt) => Some(((*code).into(), Opt::Hex(hex::encode(opt.data())))), + O::IpForwarding(b) + | O::NonLocalSrcRouting(b) + | O::AllSubnetsLocal(b) + | O::PerformMaskDiscovery(b) + | O::MaskSupplier(b) + | O::PerformRouterDiscovery(b) + | O::EthernetEncapsulation(b) + | O::TcpKeepaliveGarbage(b) => Some(((*code).into(), Opt::Bool(MaybeList::Val(*b)))), + O::ArpCacheTimeout(num) + | O::TcpKeepaliveInterval(num) + | O::AddressLeaseTime(num) + | O::Renewal(num) + | O::Rebinding(num) => Some(((*code).into(), Opt::U32(MaybeList::Val(*num)))), + O::Hostname(s) + | O::MeritDumpFile(s) + | O::DomainName(s) + | O::ExtensionsPath(s) + | O::NisDomain(s) + | O::RootPath(s) + | O::NetBiosScope(s) + | O::Message(s) => Some(((*code).into(), Opt::Str(MaybeList::Val(s.clone())))), + O::BootFileSize(num) + | O::MaxDatagramSize(num) + | O::InterfaceMtu(num) + | O::MaxMessageSize(num) => Some(((*code).into(), Opt::U16(MaybeList::Val(*num)))), + O::Unknown(opt) => Some(((*code).into(), Opt::Hex(hex::encode(opt.data())))), _ => { // the data includes the code & len, let's slice that off match opt.to_vec() { diff --git a/libs/discovery/Cargo.toml b/libs/discovery/Cargo.toml index d140b60..a259ca9 100644 --- a/libs/discovery/Cargo.toml +++ b/libs/discovery/Cargo.toml @@ -9,4 +9,3 @@ license = "MPL-2.0" [dependencies] anyhow = { workspace = true } trust-dns-resolver = "0.20.0" - diff --git a/libs/ip-manager/Cargo.toml b/libs/ip-manager/Cargo.toml index 43728b5..32d1e7e 100644 --- a/libs/ip-manager/Cargo.toml +++ b/libs/ip-manager/Cargo.toml @@ -14,11 +14,18 @@ client-protection = { path = "../client-protection" } async-trait = { workspace = true } ipnet = { workspace = true } thiserror = { workspace = true } -tracing = { workspace = true, features = ["log"] } # TODO: do we need the log feature? +tracing = { workspace = true, features = [ + "log", +] } # TODO: do we need the log feature? chrono = "0.4.19" moka = { version = "0.10.0", features = ["future"] } # TODO: hopefully the rustls feature can go away, the lib requires it -sqlx = { version = "0.5.13", features = ["sqlite", "runtime-tokio-rustls", "chrono", "offline"] } +sqlx = { version = "0.5.13", features = [ + "sqlite", + "runtime-tokio-rustls", + "chrono", + "offline", +] } [dev-dependencies] tokio-test = "0.4.1"