Skip to content

Commit

Permalink
Add a --udp option to idns query.
Browse files Browse the repository at this point in the history
  • Loading branch information
partim committed May 2, 2024
1 parent 36e3829 commit fe22b38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/idns/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Client {
&self, request: RequestMessage<Vec<u8>>, server: &Server,
) -> Result<Answer, Error> {
match server.transport {
Transport::Udp => self.request_udp(request, server).await,
Transport::UdpTcp => self.request_udptcp(request, server).await,
Transport::Tcp => self.request_tcp(request, server).await,
}
Expand Down Expand Up @@ -158,6 +159,7 @@ pub struct Server {

#[derive(Clone, Copy, Debug)]
pub enum Transport {
Udp,
UdpTcp,
Tcp,
}
Expand Down
9 changes: 8 additions & 1 deletion src/idns/commands/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ pub struct Query {
#[arg(short, long)]
tcp: bool,

/// Use only UDP.
#[arg(short, long)]
udp: bool,

/// Set the timeout for a query.
#[arg(long, value_name="SECONDS")]
timeout: Option<f32>,
Expand Down Expand Up @@ -217,7 +221,10 @@ impl Query {
}

fn transport(&self) -> Transport {
if self.tcp {
if self.udp {
Transport::Udp
}
else if self.tcp {
Transport::Tcp
}
else {
Expand Down

0 comments on commit fe22b38

Please sign in to comment.