Skip to content

Commit

Permalink
Merge branch 'main' into workspace_dependency_table
Browse files Browse the repository at this point in the history
  • Loading branch information
mokeyish authored Mar 20, 2023
2 parents 5319d48 + 72f2a07 commit 5fc3cab
Show file tree
Hide file tree
Showing 34 changed files with 310 additions and 94 deletions.
3 changes: 2 additions & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name = "trust-dns"
version = "0.22.0"
authors = ["Benjamin Fry <benjaminfry@me.com>"]
edition = "2018"
edition = "2021"
rust-version = "1.64.0"


# A short blurb about the package. This is not rendered in any format when
# uploaded to crates.io (aka this is not markdown)
description = """
Expand Down
38 changes: 26 additions & 12 deletions bin/src/trust-dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,18 @@ fn config_https(
}

for https_listener in &https_sockaddrs {
info!(
"loading cert for DNS over TLS named {} from {:?}",
tls_cert_config.get_endpoint_name(),
tls_cert_config.get_path()
);
if let Some(endpoint_name) = tls_cert_config.get_endpoint_name() {
info!(
"loading cert for DNS over TLS named {} from {:?}",
endpoint_name,
tls_cert_config.get_path()
);
} else {
info!(
"loading cert for DNS over TLS from {:?}",
tls_cert_config.get_path()
);
}
// TODO: see about modifying native_tls to impl Clone for Pkcs12
let tls_cert = dnssec::load_cert(zone_dir, tls_cert_config)
.expect("error loading tls certificate file");
Expand All @@ -605,7 +612,7 @@ fn config_https(
https_listener,
config.get_tcp_request_timeout(),
tls_cert,
tls_cert_config.get_endpoint_name().to_string(),
tls_cert_config.get_endpoint_name().map(|s| s.to_string()),
)
.expect("could not register HTTPS listener");
}
Expand Down Expand Up @@ -636,11 +643,18 @@ fn config_quic(
}

for quic_listener in &quic_sockaddrs {
info!(
"loading cert for DNS over TLS named {} from {:?}",
tls_cert_config.get_endpoint_name(),
tls_cert_config.get_path()
);
if let Some(endpoint_name) = tls_cert_config.get_endpoint_name() {
info!(
"loading cert for DNS over QUIC named {} from {:?}",
endpoint_name,
tls_cert_config.get_path()
);
} else {
info!(
"loading cert for DNS over QUIC from {:?}",
tls_cert_config.get_path()
);
}
// TODO: see about modifying native_tls to impl Clone for Pkcs12
let tls_cert = dnssec::load_cert(zone_dir, tls_cert_config)
.expect("error loading tls certificate file");
Expand All @@ -664,7 +678,7 @@ fn config_quic(
quic_listener,
config.get_tcp_request_timeout(),
tls_cert,
tls_cert_config.get_endpoint_name().to_string(),
tls_cert_config.get_endpoint_name().map(|s| s.to_string()),
)
.expect("could not register QUIC listener");
}
Expand Down
2 changes: 1 addition & 1 deletion crates/async-std-resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "async-std-resolver"
version = "0.22.0"
authors = ["Benjamin Fry <benjaminfry@me.com>"]
edition = "2018"
edition = "2021"
rust-version = "1.64.0"

# A short blurb about the package. This is not rendered in any format when
Expand Down
2 changes: 1 addition & 1 deletion crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "trust-dns-client"
version = "0.22.0"
authors = ["Benjamin Fry <benjaminfry@me.com>"]
edition = "2018"
edition = "2021"
rust-version = "1.64.0"

# A short blurb about the package. This is not rendered in any format when
Expand Down
2 changes: 1 addition & 1 deletion crates/proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "trust-dns-proto"
version = "0.22.0"
edition = "2018"
edition = "2021"
rust-version = "1.64.0"
authors = ["Benjamin Fry <benjaminfry@me.com>"]

Expand Down
1 change: 0 additions & 1 deletion crates/proto/src/https/https_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use std::convert::TryInto;
use std::fmt::{self, Display};
use std::future::Future;
use std::io;
Expand Down
7 changes: 3 additions & 4 deletions crates/proto/src/https/https_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

//! HTTPS related server items
use std::borrow::Borrow;
use std::fmt::Debug;
use std::str::FromStr;
use std::sync::Arc;
Expand All @@ -26,15 +25,15 @@ use crate::https::HttpsError;
/// To allow downstream clients to do something interesting with the lifetime of the bytes, this doesn't
/// perform a conversion to a Message, only collects all the bytes.
pub async fn message_from<R>(
this_server_name: Arc<str>,
this_server_name: Option<Arc<str>>,
request: Request<R>,
) -> Result<BytesMut, HttpsError>
where
R: Stream<Item = Result<Bytes, h2::Error>> + 'static + Send + Debug + Unpin,
{
debug!("Received request: {:#?}", request);

let this_server_name = this_server_name.borrow();
let this_server_name = this_server_name.as_deref();
match crate::https::request::verify(this_server_name, &request) {
Ok(_) => (),
Err(err) => return Err(err),
Expand Down Expand Up @@ -127,7 +126,7 @@ mod tests {
let request = request::new("ns.example.com", len).unwrap();
let request = request.map(|()| stream);

let from_post = message_from(Arc::from("ns.example.com"), request);
let from_post = message_from(Some(Arc::from("ns.example.com")), request);
let bytes = match block_on(from_post) {
Ok(bytes) => bytes,
e => panic!("{:#?}", e),
Expand Down
16 changes: 9 additions & 7 deletions crates/proto/src/https/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub fn new(name_server_name: &str, message_len: usize) -> HttpsResult<Request<()
}

/// Verifies the request is something we know what to deal with
pub fn verify<T>(name_server: &str, request: &Request<T>) -> HttpsResult<()> {
pub fn verify<T>(name_server: Option<&str>, request: &Request<T>) -> HttpsResult<()> {
// Verify all HTTP parameters
let uri = request.uri();

Expand All @@ -86,12 +86,14 @@ pub fn verify<T>(name_server: &str, request: &Request<T>) -> HttpsResult<()> {
}

// the authority must match our nameserver name
if let Some(authority) = uri.authority() {
if authority.host() != name_server {
return Err("incorrect authority".into());
if let Some(name_server) = name_server {
if let Some(authority) = uri.authority() {
if authority.host() != name_server {
return Err("incorrect authority".into());
}
} else {
return Err("no authority in HTTPS request".into());
}
} else {
return Err("no authority in HTTPS request".into());
}

// TODO: switch to mime::APPLICATION_DNS when that stabilizes
Expand Down Expand Up @@ -150,6 +152,6 @@ mod tests {
#[test]
fn test_new_verify() {
let request = new("ns.example.com", 512).expect("error converting to http");
assert!(verify("ns.example.com", &request).is_ok());
assert!(verify(Some("ns.example.com"), &request).is_ok());
}
}
2 changes: 0 additions & 2 deletions crates/proto/src/op/op_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl fmt::Display for OpCode {
/// Convert from `OpCode` to `u8`
///
/// ```
/// use std::convert::From;
/// use trust_dns_proto::op::op_code::OpCode;
///
/// let var: u8 = From::from(OpCode::Query);
Expand All @@ -86,7 +85,6 @@ impl From<OpCode> for u8 {
/// Convert from `u8` to `OpCode`
///
/// ```
/// use std::convert::From;
/// use trust_dns_proto::op::op_code::OpCode;
///
/// let var: OpCode = OpCode::from_u8(0).unwrap();
Expand Down
2 changes: 0 additions & 2 deletions crates/proto/src/op/response_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ impl Display for ResponseCode {
/// Convert from `ResponseCode` to `u16`
///
/// ```
/// use std::convert::From;
/// use trust_dns_proto::op::response_code::ResponseCode;
///
/// let var: ResponseCode = From::from(0);
Expand Down Expand Up @@ -242,7 +241,6 @@ impl From<ResponseCode> for u16 {
/// Convert from `u16` to `ResponseCode`
///
/// ```
/// use std::convert::From;
/// use trust_dns_proto::op::response_code::ResponseCode;
///
/// let var: u16 = From::from(ResponseCode::NoError);
Expand Down
2 changes: 0 additions & 2 deletions crates/proto/src/quic/quic_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use std::convert::{TryFrom, TryInto};

use bytes::{Bytes, BytesMut};
use quinn::{RecvStream, SendStream, VarInt};
use tracing::debug;
Expand Down
4 changes: 1 addition & 3 deletions crates/proto/src/rr/dns_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#![allow(clippy::use_self)]

use std::cmp::Ordering;
use std::convert::From;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::fmt::{self, Display, Formatter};
use std::str::FromStr;

#[cfg(feature = "serde-config")]
Expand Down
1 change: 0 additions & 1 deletion crates/proto/src/rr/dnssec/rdata/tsig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//! TSIG for secret key authentication of transaction
#![allow(clippy::use_self)]

use std::convert::TryInto;
use std::fmt;

#[cfg(feature = "serde-config")]
Expand Down
4 changes: 1 addition & 3 deletions crates/proto/src/rr/dnssec/supported_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

//! bitmap for expressing the set of supported algorithms in edns.
use std::convert::From;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::fmt::{self, Display, Formatter};

#[cfg(feature = "serde-config")]
use serde::{Deserialize, Serialize};
Expand Down
Loading

0 comments on commit 5fc3cab

Please sign in to comment.