Skip to content

Commit 9f4ca84

Browse files
authored
chore: update to hickory =0.25.0-alpha.4 (#3021)
## Description Update hickory to 0.25.0-alpha.4 and try to get the code to compile again. Hopefully the API won't change that much from this to the next non-alpha release 0.25 hickory-dns/hickory-dns#2206 (comment) . ## Breaking Changes None ## Notes & open questions Note: we still trigger cargo-deny because of the swarm-discovery crate: https://github.com/rkuhn/swarm-discovery/blob/master/Cargo.toml#L20 I guess even once we have merged this we still have to add an exemption to the deny.toml Is the usage of the new API correct, specifically regarding the new LookupControlFlow enum. It seems from the doc that I should just take the existing code and wrap it in LookupControlFlow::Continue? ```rust /// Result of a Lookup in the Catalog and Authority /// /// * **All authorities should default to using LookupControlFlow::Continue to wrap their responses.** /// These responses may be passed to other authorities for analysis or requery purposes. /// * Authorities may use LookupControlFlow::Break to indicate the response must be returned /// immediately to the client, without consulting any other authorities. For example, if the /// the user configures a blocklist authority, it would not be appropriate to pass the query to /// any additional authorities to try to resolve, as that might be used to leak information to a /// hostile party, and so a blocklist (or similar) authority should wrap responses for any /// blocklist hits in LookupControlFlow::Break. /// * Authorities may use LookupControlFlow::Skip to indicate the authority did not attempt to /// process a particular query. This might be used, for example, in a block list authority for /// any queries that **did not** match the blocklist, to allow the recursor or forwarder to /// resolve the query. Skip must not be used to represent an empty lookup; (use /// Continue(EmptyLookup) or Break(EmptyLookup) for that.) pub enum LookupControlFlow<T, E = LookupError> { /// A lookup response that may be passed to one or more additional authorities before /// being returned to the client. Continue(Result<T, E>), /// A lookup response that must be immediately returned to the client without consulting /// any other authorities. Break(Result<T, E>), /// The authority did not answer the query and the next authority in the chain should /// be consulted. Skip, } ``` ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented.
1 parent ad6c535 commit 9f4ca84

File tree

22 files changed

+207
-174
lines changed

22 files changed

+207
-174
lines changed

Cargo.lock

Lines changed: 72 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deny.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]
2626
ignore = [
2727
"RUSTSEC-2024-0370", # unmaintained, no upgrade available
2828
"RUSTSEC-2024-0384", # unmaintained, no upgrade available
29+
"RUSTSEC-2024-0421", # dependency from swarm-discovery, see https://github.com/rkuhn/swarm-discovery/issues/9
2930
]

iroh-dns-server/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ derive_more = { version = "1.0.0", features = [
2626
dirs-next = "2.0.0"
2727
futures-lite = "2.5"
2828
governor = "0.6.3" #needs new release of tower_governor for 0.7.0
29-
hickory-proto = "=0.25.0-alpha.2"
30-
hickory-server = { version = "=0.25.0-alpha.2", features = ["dns-over-rustls"] }
29+
hickory-server = { version = "=0.25.0-alpha.4", features = ["dns-over-rustls", "dns-over-https-rustls"] }
3130
http = "1.0.0"
3231
humantime-serde = "1.1.1"
3332
iroh-metrics = { version = "0.29.0" }
@@ -61,7 +60,7 @@ z32 = "1.1.1"
6160

6261
[dev-dependencies]
6362
criterion = "0.5.1"
64-
hickory-resolver = "=0.25.0-alpha.2"
63+
hickory-resolver = "=0.25.0-alpha.4"
6564
iroh = { version = "0.29.0", path = "../iroh" }
6665
iroh-test = { version = "0.29.0", path = "../iroh-test" }
6766
pkarr = { version = "2.2.0", features = ["rand"] }

iroh-dns-server/examples/resolve.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use std::net::SocketAddr;
22

33
use clap::{Parser, ValueEnum};
44
use hickory_resolver::{
5-
config::{NameServerConfig, Protocol, ResolverConfig},
6-
AsyncResolver,
5+
config::{NameServerConfig, ResolverConfig},
6+
proto::xfer::Protocol,
7+
Resolver,
78
};
89
use iroh::{
910
discovery::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING},
@@ -79,5 +80,5 @@ fn resolver_with_nameserver(nameserver: SocketAddr) -> DnsResolver {
7980
let mut config = ResolverConfig::new();
8081
let nameserver_config = NameServerConfig::new(nameserver, Protocol::Udp);
8182
config.add_name_server(nameserver_config);
82-
AsyncResolver::tokio(config, Default::default())
83+
Resolver::tokio(config, Default::default())
8384
}

iroh-dns-server/src/dns.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ use bytes::Bytes;
1414
use hickory_server::{
1515
authority::{Catalog, MessageResponse, ZoneType},
1616
proto::{
17+
self,
18+
op::ResponseCode,
1719
rr::{
1820
rdata::{self},
19-
RData, Record, RecordSet, RecordType, RrKey,
21+
LowerName, Name, RData, Record, RecordSet, RecordType, RrKey,
2022
},
2123
serialize::{binary::BinEncoder, txt::RDataParser},
22-
{self},
24+
xfer::Protocol,
2325
},
24-
resolver::Name,
2526
server::{Request, RequestHandler, ResponseHandler, ResponseInfo},
2627
store::in_memory::InMemoryAuthority,
2728
};
2829
use iroh_metrics::inc;
29-
use proto::{op::ResponseCode, rr::LowerName};
3030
use serde::{Deserialize, Serialize};
3131
use tokio::{
3232
net::{TcpListener, UdpSocket},
@@ -135,12 +135,16 @@ impl DnsHandler {
135135
.collect::<Result<Vec<_>, _>>()?;
136136

137137
let (static_authority, serial) = create_static_authority(&origins, config)?;
138-
let authority = NodeAuthority::new(zone_store, static_authority, origins, serial)?;
139-
let authority = Arc::new(authority);
138+
let authority = Arc::new(NodeAuthority::new(
139+
zone_store,
140+
static_authority,
141+
origins,
142+
serial,
143+
)?);
140144

141145
let mut catalog = Catalog::new();
142146
for origin in authority.origins() {
143-
catalog.upsert(LowerName::from(origin), Box::new(Arc::clone(&authority)));
147+
catalog.upsert(LowerName::from(origin), vec![authority.clone()]);
144148
}
145149

146150
Ok(Self {
@@ -166,8 +170,8 @@ impl RequestHandler for DnsHandler {
166170
) -> ResponseInfo {
167171
inc!(Metrics, dns_requests);
168172
match request.protocol() {
169-
hickory_server::server::Protocol::Udp => inc!(Metrics, dns_requests_udp),
170-
hickory_server::server::Protocol::Https => inc!(Metrics, dns_requests_https),
173+
Protocol::Udp => inc!(Metrics, dns_requests_udp),
174+
Protocol::Https => inc!(Metrics, dns_requests_https),
171175
_ => {}
172176
}
173177
debug!(protocol=%request.protocol(), query=%request.query(), "incoming DNS request");
@@ -266,7 +270,7 @@ fn create_static_authority(
266270

267271
fn push_record(records: &mut BTreeMap<RrKey, RecordSet>, serial: u32, record: Record) {
268272
let key = RrKey::new(record.name().clone().into(), record.record_type());
269-
let mut record_set = RecordSet::new(record.name(), record.record_type(), serial);
273+
let mut record_set = RecordSet::new(record.name().clone(), record.record_type(), serial);
270274
record_set.insert(record, serial);
271275
records.insert(key, record_set);
272276
}

0 commit comments

Comments
 (0)