diff options
-rw-r--r-- | Cargo.lock | 88 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rwxr-xr-x | check | 1 | ||||
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 18 |
5 files changed, 103 insertions, 7 deletions
@@ -1,6 +1,15 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] +name = "aho-corasick" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +dependencies = [ + "memchr", +] + +[[package]] name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -172,10 +181,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" [[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log 0.4.8", + "regex", + "termcolor", +] + +[[package]] name = "ewww" version = "0.1.0" dependencies = [ "anyhow", + "log 0.4.8", + "pretty_env_logger", "serde", "serde_yaml", "structopt", @@ -419,6 +443,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" [[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] name = "hyper" version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -746,6 +779,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" [[package]] +name = "pretty_env_logger" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +dependencies = [ + "env_logger", + "log 0.4.8", +] + +[[package]] name = "proc-macro-error" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -970,6 +1013,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] +name = "regex" +version = "1.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" + +[[package]] name = "remove_dir_all" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1192,6 +1253,15 @@ dependencies = [ ] [[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1221,6 +1291,15 @@ dependencies = [ ] [[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] name = "time" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1591,6 +1670,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -12,3 +12,5 @@ serde = { version = "1", features = ["derive"] } structopt = "0.3" anyhow = "1" thiserror = "1" +pretty_env_logger = "0.4" +log = "0.4" @@ -51,6 +51,7 @@ then cargo clippy $quiet fi $hideok cargo test $quiet +$hideok cargo fmt -- --check $hideok ./mktestcert test.key test.pem hunter2 @@ -0,0 +1 @@ + diff --git a/src/main.rs b/src/main.rs index 37e60d2..74175c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,9 @@ -use std::path::{Path, PathBuf}; use serde::Deserialize; +use std::path::{Path, PathBuf}; use structopt::StructOpt; use warp::Filter; +#[macro_use] +extern crate log; #[derive(Debug, Deserialize)] struct Config { @@ -30,18 +32,19 @@ enum EwwwError { TlsKeyNotFound(PathBuf), } - - #[tokio::main] async fn main() { + pretty_env_logger::init(); + info!("ewww starting up"); + let opt = Opt::from_args(); let config = read_config(&opt.config).unwrap(); let webroot = config.webroot.canonicalize().unwrap(); - eprintln!("webroot: {:?}", webroot); - let webroot = warp::any().and(warp::fs::dir(webroot)); + info!("webroot: {:?}", webroot); + let log = warp::log("ewww"); + let webroot = warp::any().and(warp::fs::dir(webroot)).with(log); - eprintln!("starting server: {:?}", config); warp::serve(webroot) .tls() .key_path(config.tls_key) @@ -51,9 +54,11 @@ async fn main() { } fn read_config(filename: &Path) -> anyhow::Result<Config> { + debug!("reading config from {:?}", filename); let config = std::fs::read_to_string(filename)?; let config: Config = serde_yaml::from_str(&config)?; check_config(&config)?; + info!("config: {:?}", config); Ok(config) } @@ -66,7 +71,6 @@ fn check_config(config: &Config) -> anyhow::Result<()> { } if !config.tls_key.exists() { return Err(EwwwError::TlsKeyNotFound(config.tls_key.clone()).into()); - } Ok(()) } |