Skip to content

Commit

Permalink
refact: LookupStrategy changed to Resolution
Browse files Browse the repository at this point in the history
Name was changed to follow RFC 9499 best current practices
  • Loading branch information
justRkive committed Aug 1, 2024
1 parent be0552f commit f689fd2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/async_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod slist;

use self::lookup_response::LookupResponse;
use crate::async_resolver::resolver_error::ResolverError;
use crate::async_resolver::{config::ResolverConfig, lookup::LookupStrategy};
use crate::async_resolver::{config::ResolverConfig, lookup::Resolution};
use crate::client::client_connection::ConnectionProtocol;
use crate::client::client_error::ClientError;
use crate::domain_name::DomainName;
Expand Down Expand Up @@ -188,7 +188,7 @@ impl AsyncResolver {
/// response of the query which can translate the response to different formats.
///
/// This lookup is done asynchronously using the `tokio` runtime. It calls the
/// asynchronous method `run()` of the `LookupStrategy` struct. This method
/// asynchronous method `run()` of the `Resolution` struct. This method
/// is used to perform the DNS lookup and return the response of the query.
///
/// If the response has an error, the method returns the corresponding `ResolverError`
Expand Down Expand Up @@ -236,7 +236,7 @@ impl AsyncResolver {
}
}

let mut lookup_strategy = LookupStrategy::new(query, self.config.clone());
let mut lookup_strategy = Resolution::new(query, self.config.clone());

// TODO: add general timeout
let lookup_response = lookup_strategy.run().await;
Expand Down
16 changes: 8 additions & 8 deletions src/async_resolver/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ use crate::async_resolver::config::ResolverConfig;
///
/// The lookup is done asynchronously after calling the asynchronoyus
/// `run` method.
pub struct LookupStrategy {
pub struct Resolution {
query: DnsMessage,
/// Resolver configuration.
config: ResolverConfig,
/// Reference to the response of the query.
response_msg: Arc<std::sync::Mutex<Result<DnsMessage, ResolverError>>>,
}

impl LookupStrategy {
impl Resolution {

/// Creates a new `LookupStrategy` with the given configuration.
/// Creates a new `Resolution` with the given configuration.
pub fn new(
query: DnsMessage,
config: ResolverConfig,
Expand Down Expand Up @@ -347,7 +347,7 @@ mod async_resolver_test {

let query = message::create_recursive_query(domain_name, record_type, record_class);

let lookup_future = LookupStrategy::new(
let lookup_future = Resolution::new(
query,
config,
);
Expand All @@ -373,7 +373,7 @@ mod async_resolver_test {
let name_servers = vec![server_info];
// let response_arc: Arc<Mutex<Result<DnsMessage, ResolverError>>> = Arc::new(Mutex::new(Err(ResolverError::EmptyQuery)));

let lookup_strategy = LookupStrategy::new(
let lookup_strategy = Resolution::new(
message::create_recursive_query(domain_name, record_type, record_class),
config,
);
Expand Down Expand Up @@ -428,7 +428,7 @@ mod async_resolver_test {
let name_servers = vec![server_info];
// let response_arc: Arc<Mutex<Result<DnsMessage, ResolverError>>> = Arc::new(Mutex::new(Err(ResolverError::EmptyQuery)));

let lookup_strategy = LookupStrategy::new(
let lookup_strategy = Resolution::new(
message::create_recursive_query(domain_name, record_type, record_class),
config,
);
Expand Down Expand Up @@ -474,7 +474,7 @@ mod async_resolver_test {
let name_servers = vec![server_info];
// let response_arc: Arc<Mutex<Result<DnsMessage, ResolverError>>> = Arc::new(Mutex::new(Err(ResolverError::EmptyQuery)));

let lookup_strategy = LookupStrategy::new(
let lookup_strategy = Resolution::new(
message::create_recursive_query(domain_name, record_type, record_class),
config,
);
Expand Down Expand Up @@ -531,7 +531,7 @@ mod async_resolver_test {
// query_sate,
// tokio::time::Duration::from_secs(3)).await;

let mut lookup_strategy = LookupStrategy::new(
let mut lookup_strategy = Resolution::new(
message::create_recursive_query(domain_name, record_type, record_class),
config,
);
Expand Down
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ pub fn create_recursive_query(

/// Constructs a `DnsMessage` that represents a server failure response.
///
/// This function is primarily used by the `LookupStrategy` to generate a server failure response message
/// This function is primarily used by the `Resolution` to generate a server failure response message
/// based on a given query message. This can be useful in scenarios where a default response is needed before
/// an actual response is received from the DNS server.
///
Expand Down

0 comments on commit f689fd2

Please sign in to comment.