Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for netblocks to CookiesMiddlewareProcessor. #340

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bd64329
Re-enable the cookies Stelline test.
ximon18 Jun 13, 2024
d6265ee
Fixes to the cookies middleware processor to make the Stelline cookie…
ximon18 Jun 13, 2024
35ca1c9
Increase log level to investigate MacOS failure.
ximon18 Jun 13, 2024
5f522f6
Increase log level to investigate MacOS failure.
ximon18 Jun 14, 2024
2d5dc32
Temporary workaround for new nightly rust error: this function depend…
ximon18 Jun 14, 2024
7d71767
Temporary workaround for new nightly rust error: this function depend…
ximon18 Jun 14, 2024
47abac5
Revert temporay workaround.
ximon18 Jun 15, 2024
0570d2f
Fix a new nightly warning involving never and unit types.
ximon18 Jun 15, 2024
dd226dc
Update ci.yml
ximon18 Jun 15, 2024
31223dc
Fixes and improvements to Stelline mock channel code. In particular, …
ximon18 Jun 18, 2024
ce29b37
Revert "Update ci.yml"
ximon18 Jun 18, 2024
4eda7ca
Revert "Increase log level to investigate MacOS failure."
ximon18 Jun 18, 2024
ffd715a
Revert "Increase log level to investigate MacOS failure."
ximon18 Jun 18, 2024
6207d23
Remove temporarily added logging.
ximon18 Jun 18, 2024
ca0f08a
Revert the addition of netblock support - add that in a separate PR.
ximon18 Jun 18, 2024
a72ded1
Revert "Revert the addition of netblock support - add that in a separ…
ximon18 Jun 18, 2024
a64744f
Review feedback: Use inetnum instead of ipnetwork.
ximon18 Jun 19, 2024
15b18d6
Don't use inetnum FromStr for Prefix as it doesn't support IP address…
ximon18 Jun 20, 2024
78d7de5
Fix misleading Rust docs and comments.
ximon18 Jun 20, 2024
929fb56
Replace test references to ip with netblock.
ximon18 Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ name = "domain"
path = "src/lib.rs"

[dependencies]
octseq = { version = "0.5.2-dev", git = "https://github.com/NLnetLabs/octseq.git", rev ="3f7797f4274af0a52e66105250ee1186ff2ab6ac", default-features = false }
time = { version = "0.3.1", default-features = false }

octseq = { version = "0.5.2-dev", git = "https://github.com/NLnetLabs/octseq.git", rev ="3f7797f4274af0a52e66105250ee1186ff2ab6ac", default-features = false }
time = { version = "0.3.1", default-features = false }
inetnum = { version = "0.1.0", optional = true }
rand = { version = "0.8", optional = true }
arc-swap = { version = "1.7.0", optional = true }
bytes = { version = "1.0", optional = true, default-features = false }
Expand All @@ -41,7 +41,7 @@ tracing = { version = "0.1.40", optional = true }
tracing-subscriber = { version = "0.3.18", optional = true, features = ["env-filter"] }

# For testing in integration tests:
mock_instant = { version = "0.4.0", optional = true }
mock_instant = { version = "0.5.1", optional = true }

[features]
default = ["std", "rand"]
Expand All @@ -59,20 +59,12 @@ validate = ["bytes", "std", "ring"]
zonefile = ["bytes", "serde", "std"]

# Unstable features
unstable-client-transport = [ "moka", "net", "tracing" ]
unstable-server-transport = ["arc-swap", "chrono/clock", "libc", "net", "tracing"]
unstable-stelline = ["tokio/test-util", "tracing", "tracing-subscriber", "unstable-server-transport", "zonefile"]
unstable-client-transport = ["moka", "net", "tracing"]
unstable-server-transport = ["arc-swap", "chrono/clock", "libc", "net", "siphasher", "tracing"]
unstable-stelline = ["tokio/test-util", "tracing", "tracing-subscriber", "unstable-server-transport", "zonefile", "mock_instant"]
unstable-validator = ["validate", "zonefile", "unstable-client-transport"]
unstable-zonetree = ["futures", "parking_lot", "serde", "tokio", "tracing"]

# Test features
# Commented out as using --all-features to build would cause mock time to also
# be used. We plan to move the test code under src/ and then use #[cfg(test)]
# and this will no longer be needed. The cookies test that depends on this is
# currently also disabled by being renamed to .rpl.not so it is okay to comment
# this out.
#mock-time = ["mock_instant"]

[dev-dependencies]
lazy_static = { version = "1.4.0" }
rstest = "0.19.0"
Expand Down
10 changes: 3 additions & 7 deletions examples/server-transports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use domain::net::server::dgram::DgramServer;
use domain::net::server::message::Request;
use domain::net::server::middleware::builder::MiddlewareBuilder;
use domain::net::server::middleware::processor::MiddlewareProcessor;
#[cfg(feature = "siphasher")]
use domain::net::server::middleware::processors::cookies::CookiesMiddlewareProcessor;
use domain::net::server::middleware::processors::mandatory::MandatoryMiddlewareProcessor;
use domain::net::server::service::{
Expand Down Expand Up @@ -688,12 +687,9 @@ async fn main() {
let mut fn_svc_middleware = MiddlewareBuilder::new();
fn_svc_middleware.push(MandatoryMiddlewareProcessor::new().into());

#[cfg(feature = "siphasher")]
{
let server_secret = "server12secret34".as_bytes().try_into().unwrap();
fn_svc_middleware
.push(CookiesMiddlewareProcessor::new(server_secret).into());
}
let server_secret = "server12secret34".as_bytes().try_into().unwrap();
fn_svc_middleware
.push(CookiesMiddlewareProcessor::new(server_secret).into());

let fn_svc_middleware = fn_svc_middleware.build();

Expand Down
2 changes: 1 addition & 1 deletion src/base/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use chrono::{DateTime, TimeZone};
use core::cmp::Ordering;
use core::{cmp, fmt, str};
#[cfg(all(feature = "std", test))]
use mock_instant::{SystemTime, UNIX_EPOCH};
use mock_instant::thread_local::{SystemTime, UNIX_EPOCH};
use octseq::parse::Parser;
#[cfg(all(feature = "std", not(test)))]
use std::time::{SystemTime, UNIX_EPOCH};
Expand Down
2 changes: 1 addition & 1 deletion src/net/client/validator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::stelline::connect::Connect;
use crate::stelline::parse_stelline::parse_file;
use crate::stelline::parse_stelline::Config;

use mock_instant::MockClock;
use mock_instant::thread_local::MockClock;
use rstest::rstest;
use tracing::instrument;

Expand Down
8 changes: 6 additions & 2 deletions src/net/server/dgram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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};

Expand Down Expand Up @@ -720,13 +721,16 @@ where

// Actually write the DNS response message bytes to the UDP
// socket.
let _ = Self::send_to(
if let Err(err) = Self::send_to(
&state.sock,
bytes,
&client_addr,
state.write_timeout,
)
.await;
.await
{
warn!(%client_addr, "Failed to send response: {err}");
}

metrics.dec_num_pending_writes();
metrics.inc_num_sent_responses();
Expand Down
Loading
Loading