Skip to content

Commit

Permalink
Merge branch 'refactor' of https://github.com/niclabs/dns-rust into r…
Browse files Browse the repository at this point in the history
…efactor
  • Loading branch information
Litr0 committed Nov 2, 2023
2 parents 50635c4 + 29c6639 commit 1330672
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/resolver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,45 @@ use crate::client::client_connection::ConnectionProtocol;

use std::{net::{IpAddr,SocketAddr,Ipv4Addr}, time::Duration, vec};
#[derive(Clone)]

/// Configuration for resolver
///
/// This struct contains all the necessary configurations to create a new
/// resolver. This includes a list of connections to Name Servers, the socket
/// address of the resolver, the quantity of retries before the resolver
/// panic in a Temporary Error, availability of cache and recursive queries,
/// the chosen transport protocol and the timeout for the connections.
pub struct ResolverConfig {
/// Servers
name_servers: Vec<(ClientUDPConnection,ClientTCPConnection)>,
/// Resolver address
/// Vector of tuples with the UDP and TCP connections to a Name Server.
name_servers: Vec<(ClientUDPConnection, ClientTCPConnection)>,
/// Socket address of the resolver.
bind_addr: SocketAddr,
/// Queries quantity for each query, before the resolver panic in a Temporary Error
/// Maximum quantity of queries for each sent query.
///
/// If this number is surpassed, the resolver is expected to panic in
/// a Temporary Error.
retry: u16,
/// Uses cache or not
/// Availability of cache in this resolver.
///
/// This is whether the resolver uses cache or not.
cache_available: bool,
/// Uses recursive
/// Availability of recursive queries in this resolver.
///
/// This is whether the resolver uses recursive queries or not.
recursive_available: bool,
/// Transport for query
/// Transport protocol for queries.
///
/// This is the transport protocol used by the resolver to send queries
/// and corresponds to `ConnectionProtocol` enum type.
protocol: ConnectionProtocol,
/// Timeout for connections
/// Timeout for connections.
///
/// This corresponds a `Duration` type.
timeout: Duration,
}

impl ResolverConfig {
/// Creates a ResolverConfig with the given address, protocol and timeout
pub fn new(resolver_addr: IpAddr, protocol: ConnectionProtocol, timeout: Duration) -> Self {
let resolver_config: ResolverConfig = ResolverConfig {
name_servers: Vec::new(),
Expand Down

0 comments on commit 1330672

Please sign in to comment.