comment why tls is slow

This commit is contained in:
Edward Shen 2021-04-23 23:28:47 -04:00
parent 654178dd5c
commit 70015a7c38
Signed by: edward
GPG key ID: 19182661E818369F
6 changed files with 12 additions and 11 deletions

4
Cargo.lock generated
View file

@ -2,9 +2,9 @@
# It is not intended for manual editing.
[[package]]
name = "actix-codec"
version = "0.4.0-beta.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90673465c6187bd0829116b02be465dc0195a74d7719f76ffff0effef934a92e"
checksum = "1d5dbeb2d9e51344cb83ca7cc170f1217f9fe25bfc50160e6e200b5c31c1019a"
dependencies = [
"bitflags",
"bytes",

View file

@ -8,6 +8,11 @@ include = ["src/**/*", "db_queries", "LICENSE", "README.md"]
description = "A MangaDex@Home implementation in Rust."
repository = "https://github.com/edward-shen/mangadex-home-rs"
[profile.release]
lto = true
codegen-units = 1
debug = 1
[dependencies]
actix-web = { version = "4.0.0-beta.4", features = [ "rustls" ] }
async-trait = "0.1"
@ -35,8 +40,3 @@ tokio = { version = "1", features = [ "full", "parking_lot" ] }
tokio-stream = { version = "0.1", features = [ "sync" ] }
tokio-util = { version = "0.6", features = [ "codec" ] }
url = { version = "2", features = [ "serde" ] }
[profile.release]
lto = true
codegen-units = 1
debug = 1

View file

@ -175,7 +175,6 @@ impl Cache for DiskCache {
&self,
key: &CacheKey,
) -> Option<Result<(CacheStream, ImageMetadata), CacheError>> {
coz::scope!("disk cache get");
let channel = self.db_update_channel_sender.clone();
let path = Arc::new(self.disk_path.clone().join(PathBuf::from(key)));

View file

@ -145,6 +145,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
})
.shutdown_timeout(60)
.bind_rustls(format!("0.0.0.0:{}", port), tls_config)?
// .bind(format!("0.0.0.0:{}", port))?
.run()
.await?;

View file

@ -64,7 +64,6 @@ async fn token_data(
return ServerResponse::TokenValidationError(e);
}
}
coz::progress!();
fetch_image(state, cache, chapter_hash, file_name, false).await
}

View file

@ -6,7 +6,7 @@ use crate::ping::{Request, Response, Tls, CONTROL_CENTER_PING_URL};
use log::{error, info, warn};
use parking_lot::RwLock;
use rustls::sign::CertifiedKey;
use rustls::ResolvesServerCert;
use rustls::{ClientHello, ResolvesServerCert};
use sodiumoxide::crypto::box_::PrecomputedKey;
use thiserror::Error;
use url::Url;
@ -126,7 +126,9 @@ impl ServerState {
pub struct RwLockServerState(pub RwLock<ServerState>);
impl ResolvesServerCert for RwLockServerState {
fn resolve(&self, _: rustls::ClientHello) -> Option<CertifiedKey> {
fn resolve(&self, _: ClientHello) -> Option<CertifiedKey> {
// TODO: wait for actix-web to use a new version of rustls so we can
// remove cloning the certs all the time
let read_guard = self.0.read();
Some(CertifiedKey {
cert: read_guard.tls_config.certs.clone(),