Skip to content

Commit

Permalink
Merge branch 'byo-signing-sorter-impl' into sortedrecords-zonemd-remo…
Browse files Browse the repository at this point in the history
…ve-replace
  • Loading branch information
ximon18 committed Dec 18, 2024
2 parents 7deffd0 + 6586302 commit 3319ec6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ futures-util = { version = "0.3", optional = true }
hashbrown = { version = "0.14.2", optional = true, default-features = false, features = ["allocator-api2", "inline-more"] } # 0.14.2 introduces explicit hashing
heapless = { version = "0.8", optional = true }
libc = { version = "0.2.153", default-features = false, optional = true } # 0.2.79 is the first version that has IP_PMTUDISC_OMIT
log = { version = "0.4.22", optional = true }
parking_lot = { version = "0.12", optional = true }
moka = { version = "0.12.3", optional = true, features = ["future"] }
openssl = { version = "0.10.57", optional = true } # 0.10.57 upgrades to 'bitflags' 2.x
Expand All @@ -45,7 +46,7 @@ smallvec = { version = "1.3", optional = true }
tokio = { version = "1.33", optional = true, features = ["io-util", "macros", "net", "time", "sync", "rt-multi-thread" ] }
tokio-rustls = { version = "0.26", optional = true, default-features = false }
tokio-stream = { version = "0.1.1", optional = true }
tracing = { version = "0.1.40", optional = true }
tracing = { version = "0.1.40", optional = true, features = ["log"] }
tracing-subscriber = { version = "0.3.18", optional = true, features = ["env-filter"] }

[features]
Expand All @@ -57,6 +58,7 @@ heapless = ["dep:heapless", "octseq/heapless"]
serde = ["dep:serde", "octseq/serde"]
smallvec = ["dep:smallvec", "octseq/smallvec"]
std = ["dep:hashbrown", "bytes?/std", "octseq/std", "time/std"]
tracing = ["dep:log", "dep:tracing"]

# Cryptographic backends
ring = ["dep:ring"]
Expand Down
8 changes: 4 additions & 4 deletions src/net/server/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::Arc;

use arc_swap::ArcSwap;
use futures_util::StreamExt;
use log::{log_enabled, Level};
use octseq::Octets;
use tokio::io::{
AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadHalf, WriteHalf,
Expand All @@ -17,8 +18,7 @@ use tokio::sync::mpsc::error::TrySendError;
use tokio::sync::{mpsc, watch};
use tokio::time::Instant;
use tokio::time::{sleep_until, timeout};
use tracing::Level;
use tracing::{debug, enabled, error, trace, warn};
use tracing::{debug, error, trace, warn};

use crate::base::message_builder::AdditionalBuilder;
use crate::base::wire::Composer;
Expand Down Expand Up @@ -582,7 +582,7 @@ where
&mut self,
msg: StreamTarget<Svc::Target>,
) -> Result<(), ConnectionEvent> {
if enabled!(Level::TRACE) {
if log_enabled!(Level::Trace) {
let bytes = msg.as_dgram_slice();
let pcap_text = to_pcap_text(bytes, bytes.len());
trace!(addr = %self.addr, pcap_text, "Sending response");
Expand Down Expand Up @@ -647,7 +647,7 @@ where
Ok(buf) => {
let received_at = Instant::now();

if enabled!(Level::TRACE) {
if log_enabled!(Level::Trace) {
let pcap_text = to_pcap_text(&buf, buf.as_ref().len());
trace!(addr = %self.addr, pcap_text, "Received message");
}
Expand Down
9 changes: 4 additions & 5 deletions src/net/server/dgram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::sync::{Arc, Mutex};

use arc_swap::ArcSwap;
use futures_util::stream::StreamExt;
use log::{log_enabled, Level};
use octseq::Octets;
use tokio::io::ReadBuf;
use tokio::net::UdpSocket;
Expand All @@ -30,9 +31,7 @@ use tokio::time::interval;
use tokio::time::timeout;
use tokio::time::Instant;
use tokio::time::MissedTickBehavior;
use tracing::warn;
use tracing::Level;
use tracing::{enabled, error, trace};
use tracing::{error, trace, warn};

use crate::base::wire::Composer;
use crate::base::Message;
Expand Down Expand Up @@ -496,7 +495,7 @@ where
let received_at = Instant::now();
self.metrics.inc_num_received_requests();

if enabled!(Level::TRACE) {
if log_enabled!(Level::Trace) {
let pcap_text = to_pcap_text(&buf, bytes_read);
trace!(%addr, pcap_text, "Received message");
}
Expand Down Expand Up @@ -553,7 +552,7 @@ where
let bytes = target.as_dgram_slice();

// Logging
if enabled!(Level::TRACE) {
if log_enabled!(Level::Trace) {
let pcap_text = to_pcap_text(bytes, bytes.len());
trace!(%addr, pcap_text, "Sending response");
}
Expand Down
9 changes: 5 additions & 4 deletions src/net/server/middleware/edns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use core::marker::PhantomData;
use core::ops::ControlFlow;

use futures_util::stream::{once, Once, Stream};
use log::{log_enabled, Level};
use octseq::Octets;
use tracing::{debug, enabled, error, trace, warn, Level};
use tracing::{debug, error, trace, warn};

use crate::base::iana::OptRcode;
use crate::base::message_builder::AdditionalBuilder;
Expand Down Expand Up @@ -141,7 +142,7 @@ where
// "A DNS server that receives a query using UDP
// transport that includes the edns-tcp-keepalive
// option MUST ignore the option."
if enabled!(Level::DEBUG)
if log_enabled!(Level::Debug)
&& opt_rec.opt().tcp_keepalive().is_some()
{
debug!("RFC 7828 3.2.1 violation: ignoring edns-tcp-keepalive option received via UDP");
Expand All @@ -161,7 +162,7 @@ where
let requestors_udp_payload_size =
opt_rec.udp_payload_size();

if enabled!(Level::DEBUG)
if log_enabled!(Level::Debug)
&& requestors_udp_payload_size
< MINIMUM_RESPONSE_BYTE_LEN
{
Expand Down Expand Up @@ -200,7 +201,7 @@ where
None => clamped_requestors_udp_payload_size,
};

if enabled!(Level::TRACE) {
if log_enabled!(Level::Trace) {
trace!("EDNS(0) response size negotation concluded: client requested={}, server requested={:?}, chosen value={}",
opt_rec.udp_payload_size(), server_max_response_size_hint, negotiated_hint);
}
Expand Down
18 changes: 13 additions & 5 deletions src/zonefile/inplace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,20 @@ impl Scanner for EntryScanner<'_> {
// Skip over symbols that don’t need converting at the beginning.
while self.zonefile.buf.next_ascii_symbol()?.is_some() {}

if self.zonefile.buf.cat == ItemCat::None {
// The item has ended. Remove the double quote.
let write = if is_quoted {
self.zonefile.buf.start - 1
} else {
self.zonefile.buf.start
};
self.zonefile.buf.next_item()?;
return Ok(self.zonefile.buf.split_to(write).freeze());
}

// If we aren’t done yet, we have escaped characters to replace.
let mut write = self.zonefile.buf.start;

if is_quoted {
// Discard the closing quote, it shouldn't be part of the value.
write -= 1;
}

while let Some(sym) = self.zonefile.buf.next_symbol()? {
self.zonefile.buf.buf[write] = sym.into_octet()?;
write += 1;
Expand Down Expand Up @@ -1561,6 +1567,8 @@ mod test {
test(" \"quoted\"\n", b"quoted");
test(" \"quoted\" ", b"quoted");
test("\"quoted\" ", b"quoted");
test("\"qu\\oted\"", b"quoted");
test(" \"qu\\\\ot\\\\ed\" ", b"qu\\ot\\ed");
}

#[test]
Expand Down

0 comments on commit 3319ec6

Please sign in to comment.