update recursor to use clap
This commit is contained in:
parent
5b929d71d7
commit
ab0094a4ff
@ -22,8 +22,8 @@
|
||||
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
||||
use clap::Parser;
|
||||
use console::style;
|
||||
use structopt::StructOpt;
|
||||
|
||||
use trust_dns_recursor::Recursor;
|
||||
use trust_dns_resolver::config::{
|
||||
@ -36,61 +36,61 @@ use trust_dns_resolver::TokioAsyncResolver;
|
||||
///
|
||||
/// This utility directly uses the trust-dns-recursor to perform a recursive lookup
|
||||
/// starting with a sent of hints or root dns servers.
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "recurse")]
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(name = "recurse")]
|
||||
struct Opts {
|
||||
/// Name to attempt to resolve, this is assumed to be fully-qualified
|
||||
domainname: String,
|
||||
|
||||
/// Type of query to issue, e.g. A, AAAA, NS, etc.
|
||||
#[structopt(short = "t", long = "type", default_value = "A")]
|
||||
#[clap(short = 't', long = "type", default_value = "A")]
|
||||
ty: RecordType,
|
||||
|
||||
/// Specify a nameserver to use, ip and port e.g. 8.8.8.8:53 or \[2001:4860:4860::8888\]:53 (port required)
|
||||
#[structopt(short = "n", long, require_delimiter = true)]
|
||||
#[clap(short = 'n', long, require_value_delimiter = true)]
|
||||
nameserver: Vec<SocketAddr>,
|
||||
|
||||
/// Specify the IP address to connect from.
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
bind: Option<IpAddr>,
|
||||
|
||||
/// Use ipv4 addresses only, default is both ipv4 and ipv6
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
ipv4: bool,
|
||||
|
||||
/// Use ipv6 addresses only, default is both ipv4 and ipv6
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
ipv6: bool,
|
||||
|
||||
/// Use only UDP, default to UDP and TCP
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
udp: bool,
|
||||
|
||||
/// Use only TCP, default to UDP and TCP
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
tcp: bool,
|
||||
|
||||
/// Enable debug and all logging
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
debug: bool,
|
||||
|
||||
/// Enable info + warning + error logging
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
info: bool,
|
||||
|
||||
/// Enable warning + error logging
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
warn: bool,
|
||||
|
||||
/// Enable error logging
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
error: bool,
|
||||
}
|
||||
|
||||
/// Run the resolve program
|
||||
/// Run the resolve programf
|
||||
#[tokio::main]
|
||||
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let opts: Opts = Opts::from_args();
|
||||
let opts: Opts = Opts::parse();
|
||||
|
||||
// enable logging early
|
||||
let log_level = if opts.debug {
|
||||
|
Loading…
Reference in New Issue
Block a user