Skip to content

Commit

Permalink
Patch for libtelio
Browse files Browse the repository at this point in the history
Reduce log levels from error and warn to debug.
These changes are copied from 0be935b commit.
  • Loading branch information
dfetti committed Oct 30, 2023
1 parent 408d0ba commit 887bba2
Show file tree
Hide file tree
Showing 36 changed files with 121 additions and 123 deletions.
18 changes: 9 additions & 9 deletions bin/src/hickory-dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use tokio::{
net::{TcpListener, UdpSocket},
runtime,
};
use tracing::{debug, error, info, warn, Event, Subscriber};
use tracing::{debug, info, Event, Subscriber};
use tracing_subscriber::{
fmt::{format, FmtContext, FormatEvent, FormatFields, FormattedFields},
layer::SubscriberExt,
Expand Down Expand Up @@ -155,15 +155,15 @@ async fn load_zone(
let is_dnssec_enabled = zone_config.is_dnssec_enabled();

if zone_config.is_update_allowed() {
warn!("allow_update is deprecated in [[zones]] section, it belongs in [[zones.stores]]");
debug!("allow_update is deprecated in [[zones]] section, it belongs in [[zones.stores]]");
}

// load the zone
let authority: Box<dyn AuthorityObject> = match zone_config.stores {
#[cfg(feature = "sqlite")]
Some(StoreConfig::Sqlite(ref config)) => {
if zone_path.is_some() {
warn!("ignoring [[zones.file]] instead using [[zones.stores.zone_file_path]]");
debug!("ignoring [[zones.file]] instead using [[zones.stores.zone_file_path]]");
}

let mut authority = SqliteAuthority::try_from_config(
Expand All @@ -182,7 +182,7 @@ async fn load_zone(
}
Some(StoreConfig::File(ref config)) => {
if zone_path.is_some() {
warn!("ignoring [[zones.file]] instead using [[zones.stores.zone_file_path]]");
debug!("ignoring [[zones.file]] instead using [[zones.stores.zone_file_path]]");
}

let mut authority = FileAuthority::try_from_config(
Expand Down Expand Up @@ -213,7 +213,7 @@ async fn load_zone(
}
#[cfg(feature = "sqlite")]
None if zone_config.is_update_allowed() => {
warn!(
debug!(
"using deprecated SQLite load configuration, please move to [[zones.stores]] form"
);
let zone_file_path = zone_path.ok_or("file is a necessary parameter of zone_config")?;
Expand Down Expand Up @@ -494,7 +494,7 @@ fn main() {
e
);

error!("{}", error_msg);
debug!("{}", error_msg);
panic!("{}", error_msg);
}
};
Expand All @@ -521,7 +521,7 @@ fn config_tls(
.collect();

if tls_sockaddrs.is_empty() {
warn!("a tls certificate was specified, but no TLS addresses configured to listen on");
debug!("a tls certificate was specified, but no TLS addresses configured to listen on");
}

for tls_listener in &tls_sockaddrs {
Expand Down Expand Up @@ -574,7 +574,7 @@ fn config_https(
.collect();

if https_sockaddrs.is_empty() {
warn!("a tls certificate was specified, but no HTTPS addresses configured to listen on");
debug!("a tls certificate was specified, but no HTTPS addresses configured to listen on");
}

for https_listener in &https_sockaddrs {
Expand Down Expand Up @@ -640,7 +640,7 @@ fn config_quic(
.collect();

if quic_sockaddrs.is_empty() {
warn!("a tls certificate was specified, but no QUIC addresses configured to listen on");
debug!("a tls certificate was specified, but no QUIC addresses configured to listen on");
}

for quic_listener in &quic_sockaddrs {
Expand Down
4 changes: 2 additions & 2 deletions bin/tests/server_harness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use hickory_proto::rr::dnssec::*;
use hickory_proto::rr::{rdata::A, *};
use regex::Regex;
use tokio::runtime::Runtime;
use tracing::{info, warn};
use tracing::{debug, info};

#[cfg(feature = "dnssec")]
use self::mut_message_client::MutMessageHandle;
Expand Down Expand Up @@ -83,7 +83,7 @@ where

let mut named = named_killer.lock().unwrap();
if let Err(e) = named.kill() {
warn!("warning: failed to kill named: {:?}", e);
debug!("warning: failed to kill named: {:?}", e);
}
};

Expand Down
6 changes: 3 additions & 3 deletions crates/proto/src/h2/h2_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use rustls::ClientConfig;
use tokio_rustls::{
client::TlsStream as TokioTlsClientStream, Connect as TokioTlsConnect, TlsConnector,
};
use tracing::{debug, warn};
use tracing::debug;

use crate::error::ProtoError;
use crate::http::Version;
Expand Down Expand Up @@ -490,7 +490,7 @@ where
debug!("h2 connection established to: {}", name_server);
tokio::spawn(
connection
.map_err(|e| warn!("h2 connection failed: {e}"))
.map_err(|e| debug!("h2 connection failed: {e}"))
.map(|_: Result<(), ()>| ()),
);

Expand Down Expand Up @@ -749,7 +749,7 @@ mod tests {
.add_parsable_certificates(&rustls_native_certs::load_native_certs().unwrap());

if ignored > 0 {
warn!(
debug!(
"failed to parse {} certificate(s) from the native root store",
ignored
);
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/op/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use std::{fmt, iter, mem, ops::Deref, sync::Arc};

use tracing::{debug, warn};
use tracing::debug;

use crate::{
error::*,
Expand Down Expand Up @@ -972,7 +972,7 @@ where
additional_count.0 += count.0;
additional_count.1 |= count.1;
} else if header.response_code().high() > 0 {
warn!(
debug!(
"response code: {} for request: {} requires EDNS but none available",
header.response_code(),
header.id()
Expand Down
2 changes: 1 addition & 1 deletion crates/proto/src/quic/quic_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ pub fn client_config_tls13() -> Result<TlsClientConfig, ProtoError> {
root_store.add_parsable_certificates(&rustls_native_certs::load_native_certs()?);

if ignored > 0 {
tracing::warn!(
tracing::debug!(
"failed to parse {} certificate(s) from the native root store",
ignored,
);
Expand Down
2 changes: 1 addition & 1 deletion crates/proto/src/rr/dnssec/rdata/dnskey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl DNSKEY {
.emit(&mut encoder)
.and_then(|_| self.emit(&mut encoder))
{
tracing::warn!("error serializing dnskey: {e}");
tracing::debug!("error serializing dnskey: {e}");
return Err(format!("error serializing dnskey: {e}").into());
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/proto/src/rr/dnssec/rdata/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ impl KEY {
// encoder.set_canonical_names(true);
// if let Err(e) = name.emit(&mut encoder)
// .and_then(|_| emit(&mut encoder, self)) {
// warn!("error serializing KEY: {}", e);
// debug!("error serializing KEY: {}", e);
// return Err(format!("error serializing KEY: {}", e).into());
// }
// }
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/rr/dnssec/supported_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::fmt::{self, Display, Formatter};
#[cfg(feature = "serde-config")]
use serde::{Deserialize, Serialize};

use tracing::warn;
use tracing::debug;

use crate::error::*;
use crate::rr::dnssec::Algorithm;
Expand Down Expand Up @@ -147,7 +147,7 @@ impl<'a> From<&'a [u8]> for SupportedAlgorithms {

for a in values.iter().map(|i| Algorithm::from_u8(*i)) {
match a {
Algorithm::Unknown(v) => warn!("unrecognized algorithm: {}", v),
Algorithm::Unknown(v) => debug!("unrecognized algorithm: {}", v),
a => supported.set(a),
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/rr/rdata/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{collections::HashMap, fmt};
#[cfg(feature = "serde-config")]
use serde::{Deserialize, Serialize};

use tracing::warn;
use tracing::debug;

use crate::{
error::{ProtoError, ProtoErrorKind, ProtoResult},
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<'r> RecordDataDecodable<'r> for OPT {
if state != OptReadState::ReadCode {
// there was some problem parsing the data for the options, ignoring them
// TODO: should we ignore all of the EDNS data in this case?
warn!("incomplete or poorly formatted EDNS options: {:?}", state);
debug!("incomplete or poorly formatted EDNS options: {:?}", state);
options.clear();
}

Expand Down
2 changes: 1 addition & 1 deletion crates/proto/src/rr/rdata/txt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl fmt::Display for TXT {
/// assert_eq!(
/// tested.as_bytes(),
/// b"Invalid utf8 <\xEF\xBF\xBD>. Valid utf8 <\xF0\x9F\xA4\xA3>",
/// "Utf8 lossy conversion error! Mismatch between input and expected"
/// "Utf8 lossy conversion debug! Mismatch between input and expected"
/// );
/// ```
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/rr/record_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{cmp::Ordering, fmt, net::IpAddr};
use serde::{Deserialize, Serialize};

use enum_as_inner::EnumAsInner;
use tracing::{trace, warn};
use tracing::{debug, trace};

use crate::{
error::{ProtoError, ProtoErrorKind, ProtoResult},
Expand Down Expand Up @@ -702,7 +702,7 @@ impl RData {
{
let mut encoder: BinEncoder<'_> = BinEncoder::new(&mut buf);
self.emit(&mut encoder).unwrap_or_else(|_| {
warn!("could not encode RDATA: {:?}", self);
debug!("could not encode RDATA: {:?}", self);
});
}
buf
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/rr/rr_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use std::{iter::Chain, slice::Iter, vec};

use tracing::{info, warn};
use tracing::{debug, info};

use crate::rr::{DNSClass, Name, RData, Record, RecordType};

Expand Down Expand Up @@ -311,7 +311,7 @@ impl RecordSet {
}
}
rdata => {
warn!("wrong rdata: {:?}, expected SOA", rdata);
debug!("wrong rdata: {:?}, expected SOA", rdata);
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/proto/src/serialize/txt/rdata_parsers/caa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! mail exchange, email, record
use tracing::warn;
use tracing::debug;

use crate::rr::rdata::caa;
use crate::rr::rdata::caa::{Property, Value};
Expand Down Expand Up @@ -59,7 +59,7 @@ pub(crate) fn parse<'i, I: Iterator<Item = &'i str>>(mut tokens: I) -> ParseResu
let issuer_critical = {
let flags = flags_str.parse::<u8>()?;
if flags & 0b0111_1111 != 0 {
warn!("unexpected flag values in caa (0 or 128): {}", flags);
debug!("unexpected flag values in caa (0 or 128): {}", flags);
}

flags & 0b1000_0000 != 0
Expand All @@ -70,7 +70,7 @@ pub(crate) fn parse<'i, I: Iterator<Item = &'i str>>(mut tokens: I) -> ParseResu
// unnecessary clone
let tag = Property::from(tag_str.to_string());
if tag.is_unknown() {
warn!("unknown tag found for caa: {:?}", tag);
debug!("unknown tag found for caa: {:?}", tag);
}
tag
};
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/tcp/tcp_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::time::Duration;
#[cfg(feature = "tokio-runtime")]
use async_trait::async_trait;
use futures_util::{future::Future, stream::Stream, StreamExt, TryFutureExt};
use tracing::warn;
use tracing::debug;

use crate::error::ProtoError;
#[cfg(feature = "tokio-runtime")]
Expand Down Expand Up @@ -144,7 +144,7 @@ impl<S: DnsTcpStream> Stream for TcpClientStream<S> {
let peer = self.tcp_stream.peer_addr();
if message.addr() != peer {
// TODO: this should be an error, right?
warn!("{} does not match name_server: {}", message.addr(), peer)
debug!("{} does not match name_server: {}", message.addr(), peer)
}

Poll::Ready(Some(Ok(message)))
Expand Down
8 changes: 4 additions & 4 deletions crates/proto/src/udp/udp_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::task::{Context, Poll};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use futures_util::{future::Future, stream::Stream};
use tracing::{debug, trace, warn};
use tracing::{debug, trace};

use crate::error::ProtoError;
use crate::op::message::NoopMessageFinalizer;
Expand Down Expand Up @@ -331,7 +331,7 @@ async fn send_serial_message_inner<S: DnsUdpSocket + Send>(
let request_target = msg.addr();

if src != request_target {
warn!(
debug!(
"ignoring response from {} because it does not match name_server: {}.",
src, request_target,
);
Expand All @@ -353,7 +353,7 @@ async fn send_serial_message_inner<S: DnsUdpSocket + Send>(
}
} else {
// on wrong id, attempted poison?
warn!(
debug!(
"expected message id: {} got: {}, dropped",
msg_id,
message.id()
Expand All @@ -364,7 +364,7 @@ async fn send_serial_message_inner<S: DnsUdpSocket + Send>(
}
Err(e) => {
// on errors deserializing, continue
warn!(
debug!(
"dropped malformed message waiting for id: {} err: {}",
msg_id, e
);
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/udp/udp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use futures_util::stream::Stream;
use futures_util::{future::Future, ready, TryFutureExt};
use rand;
use rand::distributions::{uniform::Uniform, Distribution};
use tracing::{debug, warn};
use tracing::debug;

use crate::udp::MAX_RECEIVE_BUFFER_SIZE;
use crate::xfer::{BufDnsStreamHandle, SerialMessage, StreamReceiver};
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<S: DnsUdpSocket + Send + 'static> Stream for UdpStream<S> {
// TODO: shouldn't this return the error to send to the sender?
if let Err(e) = ready!(socket.poll_send_to(cx, message.bytes(), addr)) {
// Drop the UDP packet and continue
warn!(
debug!(
"error sending message to {} on udp_socket, dropping response: {}",
addr, e
);
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/xfer/dns_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::task::{Context, Poll};
use futures_channel::mpsc;
use futures_util::future::{Future, FutureExt};
use futures_util::stream::{Peekable, Stream, StreamExt};
use tracing::{debug, warn};
use tracing::debug;

use crate::error::*;
use crate::xfer::dns_handle::DnsHandle;
Expand Down Expand Up @@ -212,7 +212,7 @@ where
match serial_response.send_response(io_stream.send_message(dns_request)) {
Ok(()) => (),
Err(_) => {
warn!("failed to associate send_message response to the sender");
debug!("failed to associate send_message response to the sender");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/xfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use futures_channel::oneshot;
use futures_util::future::Future;
use futures_util::ready;
use futures_util::stream::{Fuse, Peekable, Stream, StreamExt};
use tracing::{debug, warn};
use tracing::debug;

use crate::error::*;
use crate::Time;
Expand Down Expand Up @@ -51,7 +51,7 @@ fn ignore_send<M, T>(result: Result<M, mpsc::TrySendError<T>>) {
return;
}

warn!("error notifying wait, possible future leak: {:?}", error);
debug!("error notifying wait, possible future leak: {:?}", error);
}
}

Expand Down
Loading

0 comments on commit 887bba2

Please sign in to comment.