From d59a3fc4a5c0b0112cdf91d234c6f056f6b7c683 Mon Sep 17 00:00:00 2001 From: Tim-Paik Date: Mon, 23 Aug 2021 17:47:56 +0800 Subject: [PATCH] 1.0.0-rc.2 xdg-open and tls bug fix --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc74710..02cfe07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2488,7 +2488,7 @@ checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29" [[package]] name = "web" -version = "0.8.3-beta" +version = "1.0.0-rc" dependencies = [ "actix-files", "actix-http", diff --git a/Cargo.toml b/Cargo.toml index aadd9d4..a3f7869 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Tim_Paik "] description = "simple http server written in rust" edition = "2018" name = "web" -version = "0.8.3-beta" +version = "1.0.0-rc" [dependencies] actix-files = "0.5" diff --git a/src/main.rs b/src/main.rs index 98645bb..e71a338 100644 --- a/src/main.rs +++ b/src/main.rs @@ -492,7 +492,13 @@ async fn main() -> std::io::Result<()> { std::process::Command::new("explorer").arg(url).spawn().ok(); } else if cfg!(target_os = "macos") { std::process::Command::new("open").arg(url).spawn().ok(); - } else if cfg!(target_os = "linux") { + } else if cfg!(target_os = "linux") + || cfg!(target_os = "android") + || cfg!(target_os = "freebsd") + || cfg!(target_os = "dragonfly") + || cfg!(target_os = "openbsd") + || cfg!(target_os = "netbsd") + { std::process::Command::new("xdg-open").arg(url).spawn().ok(); } }; @@ -572,7 +578,7 @@ async fn main() -> std::io::Result<()> { } } } - if data.starts_with("[ERROR]") { + if data.starts_with("[ERROR]") || data.starts_with("TLS alert") { writeln!(buf, "\r{}", red.value(data)) } else { writeln!(buf, "\r{}", green.value(data)) @@ -581,7 +587,6 @@ async fn main() -> std::io::Result<()> { .init(); let addr = if let Some(matches) = matches.subcommand_matches("doc") { - info!("[INFO] Generating document (may take a while)"); let mut cargo_toml = match std::fs::File::open("./Cargo.toml") { Ok(file) => file, Err(e) => { @@ -605,6 +610,7 @@ async fn main() -> std::io::Result<()> { } }; let crate_name = contents.package.name; + info!("[INFO] Generating document (may take a while)"); match std::process::Command::new("cargo").arg("doc").output() { Ok(output) => { let output = std::str::from_utf8(&output.stderr).unwrap_or(""); @@ -745,7 +751,7 @@ async fn main() -> std::io::Result<()> { ); let mut config = rustls::ServerConfig::new(rustls::NoClientAuth::new()); let cert_chain = rustls::internal::pemfile::certs(cert).unwrap(); - let mut keys = rustls::internal::pemfile::rsa_private_keys(key).unwrap(); + let mut keys = rustls::internal::pemfile::pkcs8_private_keys(key).unwrap(); config.set_single_cert(cert_chain, keys.remove(0)).unwrap(); server.bind_rustls(addr, config) } else {