Skip to content

Commit

Permalink
refactor: deps
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed May 12, 2024
1 parent 166242b commit d94b46b
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 50 deletions.
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ viz-smol = { version = "0.1.5", path = "viz-smol" }

anyhow = "1.0"
async-trait = "0.1"
bytes = "1.5"
bytes = "1.6"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
Expand All @@ -70,7 +70,7 @@ sync_wrapper = "1.0"
thiserror = "1.0"

# router
path-tree = "0.7.6"
path-tree = "0.7.7"

# session
sessions = "0.6"
Expand All @@ -82,7 +82,7 @@ headers = "0.4"
http = "1.1"
http-body = "1"
http-body-util = "0.1"
hyper = { version = "1.2", features = ["server"] }
hyper = { version = "1.3", features = ["server"] }
hyper-util = { version = "0.1.3", features = ["server-auto", "tokio"] }
mime = "0.3"
mime_guess = "2.0"
Expand All @@ -92,10 +92,10 @@ hex = "0.4"
rust-embed = "8"

futures-util = "0.3"
rustls-pemfile = "1.0"
tokio = { version = "1.36", features = ["net"] }
rustls-pemfile = "2.0"
tokio = { version = "1.37", features = ["net"] }
tokio-native-tls = "0.3"
tokio-rustls = "0.24"
tokio-rustls = "0.26"
tokio-stream = "0.1"
tokio-tungstenite = "0.21"
tokio-util = "0.7"
Expand All @@ -117,15 +117,15 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tower = "0.4"
tower-http = "0.5"

# soml
# Soml
async-channel = "2.2"
async-executor = "1.8"
async-io = "2.2"
async-executor = "1.11"
async-io = "2.3"
async-net = "2.0"
smol-hyper = "0.1.1"
smol-macros = "0.1"
macro_rules_attribute = "0.2"
futures-lite = { version = "2.1.0", default-features = false, features = ["std"] }
futures-lite = { version = "2.3", default-features = false, features = ["std"] }

[workspace.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion examples/htmlx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ serde_json.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

handlebars = { version = "5", features = ["dir_source"] }
once_cell = "1.19"
once_cell = "1"
2 changes: 1 addition & 1 deletion examples/limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ publish = false
[dependencies]
viz = { workspace = true, features = ["limits", "json", "form", "multipart"] }

serde = { version = "1.0", features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
2 changes: 1 addition & 1 deletion examples/routing/openapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ serde_json.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

utoipa = "4"
utoipa-swagger-ui = "6"
utoipa-swagger-ui = "7"
2 changes: 1 addition & 1 deletion examples/static-files/include-dir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
viz.workspace = true
http-body-util.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

include_dir = "0.7"
http-body-util = "0.1"
2 changes: 1 addition & 1 deletion examples/static-routes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ viz.workspace = true

hyper.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
once_cell = "1.19"
once_cell = "1"
1 change: 1 addition & 0 deletions examples/templates/askama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ publish = false
viz.workspace = true

tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

askama = "0.12"
1 change: 1 addition & 0 deletions examples/templates/maud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ publish = false
viz.workspace = true

tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

maud = "0.26"
2 changes: 1 addition & 1 deletion examples/templates/minijinja/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ viz.workspace = true

serde.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
minijinja = { version = "1", features = ["loader"] }
minijinja = { version = "2", features = ["loader"] }
once_cell = "1.19"
5 changes: 3 additions & 2 deletions examples/templates/tera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ viz.workspace = true

serde.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
tera = "1.18"
once_cell = "1.19"

tera = "1.19"
once_cell = "1"
2 changes: 1 addition & 1 deletion viz-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mime.workspace = true

rfc7239 = "0.1" # realip
cookie = { version = "0.18", features = ["percent-encode"], optional = true }
form-data = { version = "0.5.3", optional = true }
form-data = { version = "0.5.5", optional = true }
serde = { workspace = true, features = ["derive"], optional = true }
serde_json = { workspace = true, optional = true }
serde_urlencoded = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion viz-handlers/src/serve/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub(crate) struct Files(Vec<(String, String, bool, Option<String>, String)>);

impl Display for Files {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
#[allow(clippy::manual_unwrap_or_default)]
#[allow(clippy::unwrap_or_default)]
for (relative, title, kind, ext, base) in &self.0 {
writeln!(
f,
Expand Down
4 changes: 2 additions & 2 deletions viz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ cors = ["viz-core/cors"]

compression = ["viz-core/compression"]

http1 = ["hyper/http1"]
http2 = ["hyper/http2"]
http1 = ["hyper/http1", "hyper-util/http1"]
http2 = ["hyper/http2", "hyper-util/http2"]

unix-socket = []

Expand Down
56 changes: 28 additions & 28 deletions viz/src/server/tls/rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ use std::{

use tokio::net::{TcpListener, TcpStream};
use tokio_rustls::{
rustls::{
server::{
AllowAnyAnonymousOrAuthenticatedClient, AllowAnyAuthenticatedClient, NoClientAuth,
},
Certificate, PrivateKey, RootCertStore, ServerConfig,
},
rustls::{pki_types::PrivateKeyDer, server::WebPkiClientVerifier, RootCertStore, ServerConfig},
server::TlsStream,
};

Expand Down Expand Up @@ -95,55 +90,60 @@ impl Config {
///
/// # Errors
pub fn build(self) -> Result<ServerConfig> {
fn read_trust_anchor(trust_anchor: &Certificate) -> Result<RootCertStore> {
fn read_trust_anchor(mut trust_anchor: &[u8]) -> Result<RootCertStore> {
let certs = rustls_pemfile::certs(&mut trust_anchor)
.collect::<IoResult<Vec<_>>>()
.map_err(Error::boxed)?;
let mut store = RootCertStore::empty();
store.add(trust_anchor).map_err(Error::boxed)?;
for cert in certs {
store.add(cert).map_err(Error::boxed)?;
}
Ok(store)
}

let certs = rustls_pemfile::certs(&mut self.cert.as_slice())
.map(|mut certs| certs.drain(..).map(Certificate).collect())
.collect::<Result<Vec<_>, _>>()
.map_err(Error::boxed)?;

let keys = {
let mut pkcs8: Vec<PrivateKey> =
rustls_pemfile::pkcs8_private_keys(&mut self.key.as_slice())
.map(|mut keys| keys.drain(..).map(PrivateKey).collect())
.map_err(Error::boxed)?;
let mut pkcs8 = rustls_pemfile::pkcs8_private_keys(&mut self.key.as_slice())
.collect::<Result<Vec<_>, _>>()
.map_err(Error::boxed)?;
if pkcs8.is_empty() {
let mut rsa: Vec<PrivateKey> =
rustls_pemfile::rsa_private_keys(&mut self.key.as_slice())
.map(|mut keys| keys.drain(..).map(PrivateKey).collect())
.map_err(Error::boxed)?;
let mut rsa = rustls_pemfile::rsa_private_keys(&mut self.key.as_slice())
.collect::<Result<Vec<_>, _>>()
.map_err(Error::boxed)?;

if rsa.is_empty() {
return Err(Error::boxed(IoError::new(
ErrorKind::InvalidData,
"failed to parse tls private keys",
)));
}
rsa.remove(0)
PrivateKeyDer::Pkcs1(rsa.remove(0))
} else {
pkcs8.remove(0)
PrivateKeyDer::Pkcs8(pkcs8.remove(0))
}
};

let client_auth = match self.client_auth {
ClientAuth::Off => NoClientAuth::boxed(),
ClientAuth::Optional(trust_anchor) => AllowAnyAnonymousOrAuthenticatedClient::new(
read_trust_anchor(&Certificate(trust_anchor))?,
)
.boxed(),
ClientAuth::Off => WebPkiClientVerifier::no_client_auth(),
ClientAuth::Optional(trust_anchor) => {
WebPkiClientVerifier::builder(read_trust_anchor(&trust_anchor)?.into())
.allow_unauthenticated()
.build()
.map_err(Error::boxed)?
}
ClientAuth::Required(trust_anchor) => {
AllowAnyAuthenticatedClient::new(read_trust_anchor(&Certificate(trust_anchor))?)
.boxed()
WebPkiClientVerifier::builder(read_trust_anchor(&trust_anchor)?.into())
.build()
.map_err(Error::boxed)?
}
};

ServerConfig::builder()
.with_safe_defaults()
.with_client_cert_verifier(client_auth)
.with_single_cert_with_ocsp_and_sct(certs, keys, self.ocsp_resp, Vec::new())
.with_single_cert_with_ocsp(certs, keys, self.ocsp_resp)
.map_err(Error::boxed)
}
}
Expand Down

0 comments on commit d94b46b

Please sign in to comment.