Add: verbose flag to show logs in detail
This commit is contained in:
@@ -16,6 +16,7 @@ tokio-rustls = "0.24"
|
||||
tokio-socks = "0.5"
|
||||
url = "2"
|
||||
pnet = { version = "0.34", optional = true }
|
||||
tracing = "0.1"
|
||||
|
||||
[features]
|
||||
pcap = ["dep:pnet"]
|
||||
|
||||
@@ -19,6 +19,7 @@ use thiserror::Error;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio_rustls::TlsConnector;
|
||||
use tokio_socks::tcp::Socks5Stream;
|
||||
use tracing::debug;
|
||||
use url::Url;
|
||||
|
||||
#[cfg(feature = "pcap")]
|
||||
@@ -169,6 +170,15 @@ pub async fn query(
|
||||
timeout_ms: u64,
|
||||
) -> Result<DnsQueryReport, DnsError> {
|
||||
let record_type = parse_record_type(record_type)?;
|
||||
debug!(
|
||||
domain,
|
||||
record_type = %record_type,
|
||||
transport = %transport,
|
||||
server = ?server.as_ref().map(|value| value.addr),
|
||||
proxy = ?proxy.as_deref(),
|
||||
timeout_ms,
|
||||
"dns query start"
|
||||
);
|
||||
if let Some(proxy) = proxy {
|
||||
let server = server.ok_or_else(|| DnsError::MissingServer(transport.to_string()))?;
|
||||
return match transport {
|
||||
@@ -245,6 +255,15 @@ pub async fn detect(
|
||||
repeat: u32,
|
||||
timeout_ms: u64,
|
||||
) -> Result<DnsDetectResult, DnsError> {
|
||||
debug!(
|
||||
domain,
|
||||
transport = %transport,
|
||||
servers = servers.len(),
|
||||
proxy = ?proxy.as_deref(),
|
||||
repeat,
|
||||
timeout_ms,
|
||||
"dns detect start"
|
||||
);
|
||||
let mut results = Vec::new();
|
||||
for server in servers {
|
||||
for _ in 0..repeat.max(1) {
|
||||
@@ -311,6 +330,12 @@ pub async fn watch(_options: DnsWatchOptions) -> Result<DnsWatchReport, DnsError
|
||||
|
||||
#[cfg(feature = "pcap")]
|
||||
pub async fn watch(options: DnsWatchOptions) -> Result<DnsWatchReport, DnsError> {
|
||||
debug!(
|
||||
iface = ?options.iface,
|
||||
duration_ms = options.duration_ms,
|
||||
filter = ?options.filter,
|
||||
"dns watch start"
|
||||
);
|
||||
let iface = match select_interface(options.iface.as_deref()) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
@@ -341,6 +366,15 @@ pub async fn watch(options: DnsWatchOptions) -> Result<DnsWatchReport, DnsError>
|
||||
match rx.next() {
|
||||
Ok(frame) => {
|
||||
if let Some(event) = parse_dns_frame(frame, start, &filter) {
|
||||
debug!(
|
||||
src = %event.src,
|
||||
dst = %event.dst,
|
||||
query_name = %event.query_name,
|
||||
query_type = %event.query_type,
|
||||
rcode = %event.rcode,
|
||||
is_response = event.is_response,
|
||||
"dns watch event"
|
||||
);
|
||||
events.push(event);
|
||||
}
|
||||
}
|
||||
@@ -435,6 +469,13 @@ async fn doh_query_via_proxy(
|
||||
timeout_ms: u64,
|
||||
proxy: String,
|
||||
) -> Result<DnsQueryReport, DnsError> {
|
||||
debug!(
|
||||
domain,
|
||||
record_type = %record_type,
|
||||
server = %server.addr,
|
||||
proxy = %proxy,
|
||||
"dns doh via proxy"
|
||||
);
|
||||
let tls_name = server
|
||||
.name
|
||||
.clone()
|
||||
@@ -530,6 +571,13 @@ async fn dot_query_via_proxy(
|
||||
timeout_ms: u64,
|
||||
proxy: String,
|
||||
) -> Result<DnsQueryReport, DnsError> {
|
||||
debug!(
|
||||
domain,
|
||||
record_type = %record_type,
|
||||
server = %server.addr,
|
||||
proxy = %proxy,
|
||||
"dns dot via proxy"
|
||||
);
|
||||
let tls_name = server
|
||||
.name
|
||||
.clone()
|
||||
|
||||
Reference in New Issue
Block a user