Remove Copy
from ResolverOpts
This commit is contained in:
parent
272059870a
commit
cf26eb52db
@ -57,7 +57,7 @@ impl Recursor {
|
||||
|
||||
let opts = recursor_opts();
|
||||
let roots =
|
||||
GenericNameServerPool::from_config(roots, &opts, TokioConnectionProvider::default());
|
||||
GenericNameServerPool::from_config(roots, opts, TokioConnectionProvider::default());
|
||||
let roots = RecursorPool::from(Name::root(), roots);
|
||||
let name_server_cache = Mutex::new(NameServerCache::new(100)); // TODO: make this configurable
|
||||
let record_cache = DnsLru::new(100, TtlConfig::default());
|
||||
@ -439,7 +439,7 @@ impl Recursor {
|
||||
// now construct a namesever pool based off the NS and glue records
|
||||
let ns = GenericNameServerPool::from_config(
|
||||
config_group,
|
||||
&recursor_opts(),
|
||||
recursor_opts(),
|
||||
TokioConnectionProvider::default(),
|
||||
);
|
||||
let ns = RecursorPool::from(zone.clone(), ns);
|
||||
|
@ -192,7 +192,8 @@ impl<P: ConnectionProvider> AsyncResolver<P> {
|
||||
/// documentation for `AsyncResolver` for more information on how to use
|
||||
/// the background future.
|
||||
pub fn new_with_conn(config: ResolverConfig, options: ResolverOpts, conn_provider: P) -> Self {
|
||||
let pool = NameServerPool::from_config_with_provider(&config, &options, conn_provider);
|
||||
let pool =
|
||||
NameServerPool::from_config_with_provider(&config, options.clone(), conn_provider);
|
||||
let either;
|
||||
let client = RetryDnsHandle::new(pool, options.attempts);
|
||||
if options.validate {
|
||||
@ -222,8 +223,8 @@ impl<P: ConnectionProvider> AsyncResolver<P> {
|
||||
let lru = DnsLru::new(options.cache_size, dns_lru::TtlConfig::from_opts(&options));
|
||||
Self {
|
||||
config,
|
||||
options,
|
||||
client_cache: CachingClient::with_cache(lru, either, options.preserve_intermediates),
|
||||
options,
|
||||
hosts,
|
||||
}
|
||||
}
|
||||
|
@ -848,13 +848,13 @@ impl Default for ServerOrderingStrategy {
|
||||
}
|
||||
|
||||
/// Configuration for the Resolver
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(
|
||||
feature = "serde-config",
|
||||
derive(Serialize, Deserialize),
|
||||
serde(default)
|
||||
)]
|
||||
#[allow(dead_code)] // TODO: remove after all params are supported
|
||||
#[allow(dead_code, missing_copy_implementations)] // TODO: remove after all params are supported
|
||||
#[non_exhaustive]
|
||||
pub struct ResolverOpts {
|
||||
/// Sets the number of dots that must appear (unless it's a final dot representing the root)
|
||||
|
@ -54,7 +54,7 @@ pub type GenericNameServerPool<P> = NameServerPool<GenericConnector<P>>;
|
||||
impl GenericNameServerPool<TokioRuntimeProvider> {
|
||||
pub(crate) fn tokio_from_config(
|
||||
config: &ResolverConfig,
|
||||
options: &ResolverOpts,
|
||||
options: ResolverOpts,
|
||||
runtime: TokioRuntimeProvider,
|
||||
) -> Self {
|
||||
Self::from_config_with_provider(config, options, GenericConnector::new(runtime))
|
||||
@ -67,7 +67,7 @@ where
|
||||
{
|
||||
pub(crate) fn from_config_with_provider(
|
||||
config: &ResolverConfig,
|
||||
options: &ResolverOpts,
|
||||
options: ResolverOpts,
|
||||
conn_provider: P,
|
||||
) -> Self {
|
||||
let datagram_conns: Vec<NameServer<P>> = config
|
||||
@ -84,7 +84,7 @@ where
|
||||
#[cfg(not(feature = "dns-over-rustls"))]
|
||||
let ns_config = { ns_config.clone() };
|
||||
|
||||
NameServer::new(ns_config, *options, conn_provider.clone())
|
||||
NameServer::new(ns_config, options.clone(), conn_provider.clone())
|
||||
})
|
||||
.collect();
|
||||
|
||||
@ -102,7 +102,7 @@ where
|
||||
#[cfg(not(feature = "dns-over-rustls"))]
|
||||
let ns_config = { ns_config.clone() };
|
||||
|
||||
NameServer::new(ns_config, *options, conn_provider.clone())
|
||||
NameServer::new(ns_config, options.clone(), conn_provider.clone())
|
||||
})
|
||||
.collect();
|
||||
|
||||
@ -110,19 +110,19 @@ where
|
||||
datagram_conns: Arc::from(datagram_conns),
|
||||
stream_conns: Arc::from(stream_conns),
|
||||
#[cfg(feature = "mdns")]
|
||||
mdns_conns: name_server::mdns_nameserver(*options, conn_provider.clone(), false),
|
||||
options: *options,
|
||||
mdns_conns: name_server::mdns_nameserver(options, conn_provider.clone(), false),
|
||||
options,
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct a NameServerPool from a set of name server configs
|
||||
pub fn from_config(
|
||||
name_servers: NameServerConfigGroup,
|
||||
options: &ResolverOpts,
|
||||
options: ResolverOpts,
|
||||
conn_provider: P,
|
||||
) -> Self {
|
||||
let map_config_to_ns =
|
||||
|ns_config| NameServer::new(ns_config, *options, conn_provider.clone());
|
||||
|ns_config| NameServer::new(ns_config, options.clone(), conn_provider.clone());
|
||||
|
||||
let (datagram, stream): (Vec<_>, Vec<_>) = name_servers
|
||||
.into_inner()
|
||||
@ -137,28 +137,28 @@ where
|
||||
stream_conns: Arc::from(stream_conns),
|
||||
#[cfg(feature = "mdns")]
|
||||
mdns_conns: name_server::mdns_nameserver(*options, conn_provider.clone(), false),
|
||||
options: *options,
|
||||
options,
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(feature = "mdns"))]
|
||||
pub fn from_nameservers(
|
||||
options: &ResolverOpts,
|
||||
options: ResolverOpts,
|
||||
datagram_conns: Vec<NameServer<P>>,
|
||||
stream_conns: Vec<NameServer<P>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
datagram_conns: Arc::from(datagram_conns),
|
||||
stream_conns: Arc::from(stream_conns),
|
||||
options: *options,
|
||||
options,
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "mdns")]
|
||||
pub fn from_nameservers(
|
||||
options: &ResolverOpts,
|
||||
options: ResolverOpts,
|
||||
datagram_conns: Vec<NameServer<P>>,
|
||||
stream_conns: Vec<NameServer<P>>,
|
||||
mdns_conns: NameServer<P>,
|
||||
@ -167,7 +167,7 @@ where
|
||||
datagram_conns: Arc::from(datagram_conns),
|
||||
stream_conns: Arc::from(stream_conns),
|
||||
mdns_conns,
|
||||
options: *options,
|
||||
options,
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,14 +175,14 @@ where
|
||||
#[cfg(not(feature = "mdns"))]
|
||||
#[allow(dead_code)]
|
||||
fn from_nameservers_test(
|
||||
options: &ResolverOpts,
|
||||
options: ResolverOpts,
|
||||
datagram_conns: Arc<[NameServer<P>]>,
|
||||
stream_conns: Arc<[NameServer<P>]>,
|
||||
) -> Self {
|
||||
Self {
|
||||
datagram_conns,
|
||||
stream_conns,
|
||||
options: *options,
|
||||
options,
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ where
|
||||
type Error = ResolveError;
|
||||
|
||||
fn send<R: Into<DnsRequest>>(&self, request: R) -> Self::Response {
|
||||
let opts = self.options;
|
||||
let opts = self.options.clone();
|
||||
let request = request.into();
|
||||
let datagram_conns = Arc::clone(&self.datagram_conns);
|
||||
let stream_conns = Arc::clone(&self.stream_conns);
|
||||
@ -258,7 +258,7 @@ where
|
||||
debug!("sending request: {:?}", request.queries());
|
||||
|
||||
// First try the UDP connections
|
||||
let udp_res = match Self::try_send(opts, datagram_conns, request).await {
|
||||
let udp_res = match Self::try_send(opts.clone(), datagram_conns, request).await {
|
||||
Ok(response) if response.truncated() => {
|
||||
debug!("truncated response received, retrying over TCP");
|
||||
Ok(response)
|
||||
@ -518,7 +518,7 @@ mod tests {
|
||||
let io_loop = Runtime::new().unwrap();
|
||||
let pool = GenericNameServerPool::tokio_from_config(
|
||||
&resolver_config,
|
||||
&ResolverOpts::default(),
|
||||
ResolverOpts::default(),
|
||||
TokioRuntimeProvider::new(),
|
||||
);
|
||||
|
||||
@ -578,12 +578,12 @@ mod tests {
|
||||
..ResolverOpts::default()
|
||||
};
|
||||
let ns_config = { tcp };
|
||||
let name_server = GenericNameServer::new(ns_config, opts, conn_provider);
|
||||
let name_server = GenericNameServer::new(ns_config, opts.clone(), conn_provider);
|
||||
let name_servers: Arc<[_]> = Arc::from([name_server]);
|
||||
|
||||
#[cfg(not(feature = "mdns"))]
|
||||
let pool = GenericNameServerPool::from_nameservers_test(
|
||||
&opts,
|
||||
opts,
|
||||
Arc::from([]),
|
||||
Arc::clone(&name_servers),
|
||||
);
|
||||
|
@ -54,7 +54,7 @@ impl ForwardAuthority {
|
||||
info!("loading forwarder config: {}", origin);
|
||||
|
||||
let name_servers = config.name_servers.clone();
|
||||
let mut options = config.options.unwrap_or_default();
|
||||
let mut options = config.options.clone().unwrap_or_default();
|
||||
|
||||
// See RFC 1034, Section 4.3.2:
|
||||
// "If the data at the node is a CNAME, and QTYPE doesn't match
|
||||
|
@ -114,7 +114,7 @@ fn mock_nameserver_pool_on_send<O: OnSend + Unpin>(
|
||||
options: ResolverOpts,
|
||||
) -> MockedNameServerPool<O> {
|
||||
#[cfg(not(feature = "mdns"))]
|
||||
return NameServerPool::from_nameservers(&options, udp, tcp);
|
||||
return NameServerPool::from_nameservers(options, udp, tcp);
|
||||
|
||||
#[cfg(feature = "mdns")]
|
||||
return NameServerPool::from_nameservers(
|
||||
@ -699,10 +699,10 @@ fn test_concurrent_requests_2_conns() {
|
||||
|
||||
let udp1_nameserver = mock_nameserver_on_send(
|
||||
vec![Ok(DnsResponse::from_message(udp_message).unwrap())],
|
||||
options,
|
||||
options.clone(),
|
||||
on_send.clone(),
|
||||
);
|
||||
let udp2_nameserver = mock_nameserver_on_send(vec![], options, on_send);
|
||||
let udp2_nameserver = mock_nameserver_on_send(vec![], options.clone(), on_send);
|
||||
|
||||
let pool = mock_nameserver_pool_on_send(
|
||||
vec![udp2_nameserver, udp1_nameserver],
|
||||
@ -742,10 +742,10 @@ fn test_concurrent_requests_more_than_conns() {
|
||||
|
||||
let udp1_nameserver = mock_nameserver_on_send(
|
||||
vec![Ok(DnsResponse::from_message(udp_message).unwrap())],
|
||||
options,
|
||||
options.clone(),
|
||||
on_send.clone(),
|
||||
);
|
||||
let udp2_nameserver = mock_nameserver_on_send(vec![], options, on_send);
|
||||
let udp2_nameserver = mock_nameserver_on_send(vec![], options.clone(), on_send);
|
||||
|
||||
let pool = mock_nameserver_pool_on_send(
|
||||
vec![udp2_nameserver, udp1_nameserver],
|
||||
@ -785,7 +785,7 @@ fn test_concurrent_requests_1_conn() {
|
||||
|
||||
let udp1_nameserver = mock_nameserver_on_send(
|
||||
vec![Ok(DnsResponse::from_message(udp_message).unwrap())],
|
||||
options,
|
||||
options.clone(),
|
||||
on_send,
|
||||
);
|
||||
let udp2_nameserver = udp1_nameserver.clone();
|
||||
@ -828,7 +828,7 @@ fn test_concurrent_requests_0_conn() {
|
||||
|
||||
let udp1_nameserver = mock_nameserver_on_send(
|
||||
vec![Ok(DnsResponse::from_message(udp_message).unwrap())],
|
||||
options,
|
||||
options.clone(),
|
||||
on_send,
|
||||
);
|
||||
let udp2_nameserver = udp1_nameserver.clone();
|
||||
|
Loading…
Reference in New Issue
Block a user