Skip to content

Commit

Permalink
update dhcproto & unix-udp-sock
Browse files Browse the repository at this point in the history
  • Loading branch information
leshow committed Sep 29, 2023
1 parent 2c34dab commit 6ae489b
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 66 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

6 changes: 3 additions & 3 deletions bin/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
6 changes: 3 additions & 3 deletions dora-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions libs/config/src/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
Expand Down
101 changes: 54 additions & 47 deletions libs/config/src/wire/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion libs/discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ license = "MPL-2.0"
[dependencies]
anyhow = { workspace = true }
trust-dns-resolver = "0.20.0"

11 changes: 9 additions & 2 deletions libs/ip-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6ae489b

Please sign in to comment.