From 0f736978f30ae0c276543f1b90c47689c9bae614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Mon, 15 Aug 2022 01:26:45 +0100 Subject: [PATCH 01/14] Reimplement basic static (+handlebars) file hosting with actix-web --- Cargo.lock | 2741 ++++++++------------------------------- Cargo.toml | 13 +- src/context.rs | 38 - src/mail.rs | 50 - src/main.rs | 74 +- src/static_templates.rs | 78 -- 6 files changed, 601 insertions(+), 2393 deletions(-) delete mode 100644 src/context.rs delete mode 100644 src/mail.rs delete mode 100644 src/static_templates.rs diff --git a/Cargo.lock b/Cargo.lock index e769e0b..47f59d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,57 +3,222 @@ version = 3 [[package]] -name = "aead" -version = "0.3.2" +name = "actix-codec" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" dependencies = [ - "generic-array 0.14.5", + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "log", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util", ] [[package]] -name = "aes" -version = "0.6.0" +name = "actix-files" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" +checksum = "d832782fac6ca7369a70c9ee9a20554623c5e51c76e190ad151780ebea1cf689" dependencies = [ - "aes-soft", - "aesni", - "cipher", + "actix-http", + "actix-service", + "actix-utils", + "actix-web", + "askama_escape", + "bitflags", + "bytes", + "derive_more", + "futures-core", + "http-range", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", ] [[package]] -name = "aes-gcm" -version = "0.8.0" +name = "actix-http" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" +checksum = "6f9ffb6db08c1c3a1f4aef540f1a63193adc73c4fbd40b75a95fc8c5258f6e51" dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "ahash", + "base64", + "bitflags", + "brotli", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "flate2", + "futures-core", + "h2", + "http", + "httparse", + "httpdate", + "itoa", + "language-tags", + "local-channel", + "mime", + "percent-encoding", + "pin-project-lite", + "rand", + "sha1", + "smallvec", + "tracing", + "zstd", ] [[package]] -name = "aes-soft" -version = "0.6.4" +name = "actix-macros" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ - "cipher", - "opaque-debug 0.3.0", + "quote", + "syn", ] [[package]] -name = "aesni" -version = "0.10.0" +name = "actix-router" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80" dependencies = [ - "cipher", - "opaque-debug 0.3.0", + "bytestring", + "firestorm", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ea16c295198e958ef31930a6ef37d0fb64e9ca3b6116e6b93a8bdae96ee1000" +dependencies = [ + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da34f8e659ea1b077bb4637948b815cd3768ad5a188fdcd74ff4d84240cd824" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "futures-util", + "mio", + "num_cpus", + "socket2", + "tokio", + "tracing", +] + +[[package]] +name = "actix-service" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" +dependencies = [ + "futures-core", + "paste", + "pin-project-lite", +] + +[[package]] +name = "actix-utils" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27e8fe9ba4ae613c21f677c2cfaf0696c3744030c6f485b34634e502d6bb379" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "ahash", + "bytes", + "bytestring", + "cfg-if", + "cookie", + "derive_more", + "encoding_rs", + "futures-core", + "futures-util", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "pin-project-lite", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f270541caec49c15673b0af0e9a00143421ad4f118d2df7edcb68b627632f56" +dependencies = [ + "actix-router", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", ] [[package]] @@ -66,219 +231,25 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.57" +name = "alloc-no-stdlib" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3" [[package]] -name = "arrayvec" -version = "0.5.2" +name = "alloc-stdlib" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "ascii_utils" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" - -[[package]] -name = "async-channel" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", + "alloc-no-stdlib", ] [[package]] -name = "async-executor" -version = "1.4.1" +name = "askama_escape" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "once_cell", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd8b508d585e01084059b60f06ade4cb7415cd2e4084b71dd1cb44e7d3fb9880" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-lock", - "blocking", - "futures-lite", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5e18f61464ae81cde0a23e713ae8fd299580c54d697a35820cfd0625b8b0e07" -dependencies = [ - "concurrent-queue", - "futures-lite", - "libc", - "log 0.4.17", - "once_cell", - "parking", - "polling", - "slab", - "socket2 0.4.4", - "waker-fn", - "winapi 0.3.9", -] - -[[package]] -name = "async-lock" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-native-tls" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9e7a929bd34c68a82d58a4de7f86fffdaf97fb2af850162a7bb19dd7269b33" -dependencies = [ - "async-std", - "native-tls", - "thiserror", - "url 2.2.2", -] - -[[package]] -name = "async-process" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2c06e30a24e8c78a3987d07f0930edf76ef35e027e7bdb063fccafdad1f60c" -dependencies = [ - "async-io", - "blocking", - "cfg-if 1.0.0", - "event-listener", - "futures-lite", - "libc", - "once_cell", - "signal-hook", - "winapi 0.3.9", -] - -[[package]] -name = "async-recursion" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cda8f4bcc10624c4e85bc66b3f452cca98cfa5ca002dc83a16aad2367641bea" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "async-smtp" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "472a081e9e3a92f9201237f07b51c0bab657336ca6600fd2f243c9cc3c9c81ff" -dependencies = [ - "async-native-tls", - "async-std", - "async-trait", - "base64 0.13.0", - "bufstream", - "fast-socks5", - "fast_chemail", - "hostname 0.1.5", - "log 0.4.17", - "nom 5.1.2", - "pin-project", - "pin-utils", - "serde", - "serde_derive", - "serde_json", - "thiserror", -] - -[[package]] -name = "async-std" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52580991739c5cdb36cde8b2a516371c0a3b70dda36d916cc08b82372916808c" -dependencies = [ - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "async-process", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log 0.4.17", - "memchr", - "num_cpus", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-std-resolver" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf3e776afdf3a2477ef4854b85ba0dff3bd85792f685fb3c68948b4d304e4f0" -dependencies = [ - "async-std", - "async-trait", - "futures-io", - "futures-util", - "pin-utils", - "trust-dns-resolver", -] - -[[package]] -name = "async-task" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" - -[[package]] -name = "async-trait" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" [[package]] name = "atty" @@ -288,16 +259,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.9", -] - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", + "winapi", ] [[package]] @@ -306,25 +268,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - [[package]] name = "base64" version = "0.13.0" @@ -339,95 +282,57 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", + "generic-array", ] [[package]] -name = "block-buffer" -version = "0.9.0" +name = "brotli" +version = "3.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" dependencies = [ - "generic-array 0.14.5", + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", ] [[package]] -name = "block-padding" -version = "0.1.5" +name = "brotli-decompressor" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" dependencies = [ - "byte-tools", + "alloc-no-stdlib", + "alloc-stdlib", ] -[[package]] -name = "blocking" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" -dependencies = [ - "async-channel", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "once_cell", -] - -[[package]] -name = "bufstream" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" - -[[package]] -name = "bumpalo" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - [[package]] name = "bytes" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" [[package]] -name = "cache-padded" -version = "1.2.0" +name = "bytestring" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a" +dependencies = [ + "bytes", +] [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -436,100 +341,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "check-if-email-exists" -version = "0.8.30" +name = "clap" +version = "3.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4d005f064f8d17b8464867d44ba22461b27ffab4e7aedcc8f30aff9c73ed90" -dependencies = [ - "async-native-tls", - "async-recursion", - "async-smtp", - "async-std", - "async-std-resolver", - "fast-socks5", - "futures", - "log 0.4.17", - "mailchecker", - "rand 0.8.5", - "regex", - "reqwest", - "serde", - "serde_json", - "trust-dns-proto", -] - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi 0.3.9", -] - -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.5", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +checksum = "29e724a68d9319343bb3328c9cc2dfde263f4b3142ee1059a9980580171c954b" dependencies = [ + "atty", "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", + "strsim", + "termcolor", + "textwrap", ] [[package]] -name = "concurrent-queue" -version = "1.2.2" +name = "clap_derive" +version = "3.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +checksum = "13547f7012c01ab4a0e8f8967730ada8f9fdf419e8b6c792788f39cf4e46eefa" dependencies = [ - "cache-padded", + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "cookie" -version = "0.11.4" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f6044740a4a516b8aac14c140cdf35c1a640b1bd6b98b6224e49143b2f1566" +checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ - "aes-gcm", - "base64 0.13.0", - "hkdf", - "hmac", - "percent-encoding 2.1.0", - "rand 0.8.5", - "sha2", + "percent-encoding", "time", + "version_check", ] -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - [[package]] name = "cpufeatures" version = "0.2.2" @@ -540,265 +406,70 @@ dependencies = [ ] [[package]] -name = "cpuid-bool" -version = "0.2.0" +name = "crc32fast" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - -[[package]] -name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if 1.0.0", - "lazy_static", + "cfg-if", ] [[package]] -name = "crypto-mac" -version = "0.10.1" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.5", - "subtle", + "generic-array", + "typenum", ] [[package]] -name = "ctor" -version = "0.1.22" +name = "derive_more" +version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" -dependencies = [ - "cipher", -] - -[[package]] -name = "data-encoding" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" - -[[package]] -name = "devise" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd716c4a507adc5a2aa7c2a372d06c7497727e0892b243d3036bc7478a13e526" -dependencies = [ - "devise_codegen", - "devise_core", -] - -[[package]] -name = "devise_codegen" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea7b8290d118127c08e3669da20b331bed56b09f20be5945b7da6c116d8fab53" -dependencies = [ - "devise_core", - "quote 0.6.13", -] - -[[package]] -name = "devise_core" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1053e9d5d5aade9bcedb5ab53b78df2b56ff9408a3138ce77eaaef87f932373" -dependencies = [ - "bitflags", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", ] [[package]] name = "digest" -version = "0.8.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "generic-array 0.12.4", + "block-buffer", + "crypto-common", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.5", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "email" -version = "0.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91549a51bb0241165f13d57fc4c72cef063b4088fb078b019ecbf464a45f22e4" -dependencies = [ - "base64 0.9.3", - "chrono", - "encoding", - "lazy_static", - "rand 0.4.6", - "time", - "version_check 0.1.5", -] - -[[package]] -name = "encoding" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" -dependencies = [ - "encoding-index-japanese", - "encoding-index-korean", - "encoding-index-simpchinese", - "encoding-index-singlebyte", - "encoding-index-tradchinese", -] - -[[package]] -name = "encoding-index-japanese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-korean" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-simpchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-singlebyte" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-tradchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding_index_tests" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" - [[package]] name = "encoding_rs" version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] -name = "enum-as-inner" -version = "0.3.4" +name = "firestorm" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" +checksum = "2c5f6c2c942da57e2aaaa84b8a521489486f14e75e7fa91dab70aba913975f98" + +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ - "heck", - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "event-listener" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fast-socks5" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba337793c1ee49731350a8d971d791651ed51d6e814ab4ddabd79c12b5366140" -dependencies = [ - "anyhow", - "async-std", - "futures", - "log 0.4.17", - "thiserror", -] - -[[package]] -name = "fast_chemail" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "495a39d30d624c2caabe6312bfead73e7717692b44e0b32df168c275a2e8e9e4" -dependencies = [ - "ascii_utils", -] - -[[package]] -name = "fastrand" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" -dependencies = [ - "instant", -] - -[[package]] -name = "filetime" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "winapi 0.3.9", + "crc32fast", + "miniz_oxide", ] [[package]] @@ -807,21 +478,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -829,171 +485,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "fsevent" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" -dependencies = [ - "bitflags", - "fsevent-sys", -] - -[[package]] -name = "fsevent-sys" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" -dependencies = [ - "libc", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" -dependencies = [ - "futures-core", - "futures-sink", + "percent-encoding", ] [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" - -[[package]] -name = "futures-executor" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" - -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] +checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115" [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "ca0bae1fe9752cf7fd9b0064c674ae63f97b37bc714d745cbde0afb7ec4e6765" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577" dependencies = [ - "futures-channel", "futures-core", - "futures-io", - "futures-macro", - "futures-sink", "futures-task", - "memchr", "pin-project-lite", "pin-utils", - "slab", ] [[package]] name = "generic-array" -version = "0.12.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" -dependencies = [ - "typenum", - "version_check 0.9.4", + "version_check", ] [[package]] @@ -1002,37 +534,9 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "ghash" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" -dependencies = [ - "opaque-debug 0.3.0", - "polyval", -] - -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - -[[package]] -name = "gloo-timers" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", + "wasi", ] [[package]] @@ -1056,26 +560,24 @@ dependencies = [ [[package]] name = "handlebars" -version = "1.1.0" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82e5750d8027a97b9640e3fefa66bbaf852a35228e1c90790efd13c4b09c166" +checksum = "360d9740069b2f6cbb63ce2dbaa71a20d3185350cbb990d7bebeb9318415eb17" dependencies = [ - "lazy_static", - "log 0.4.17", + "log", "pest", "pest_derive", - "quick-error", - "regex", "serde", "serde_json", + "thiserror", "walkdir", ] [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" @@ -1092,47 +594,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hkdf" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" -dependencies = [ - "digest 0.9.0", - "hmac", -] - -[[package]] -name = "hmac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" -dependencies = [ - "crypto-mac", - "digest 0.9.0", -] - -[[package]] -name = "hostname" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" -dependencies = [ - "libc", - "winutil", -] - -[[package]] -name = "hostname" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" -dependencies = [ - "libc", - "match_cfg", - "winapi 0.3.9", -] - [[package]] name = "http" version = "0.2.8" @@ -1145,15 +606,10 @@ dependencies = [ ] [[package]] -name = "http-body" -version = "0.4.5" +name = "http-range" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] +checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "httparse" @@ -1167,73 +623,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "hyper" -version = "0.10.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" -dependencies = [ - "base64 0.9.3", - "httparse", - "language-tags", - "log 0.3.9", - "mime 0.2.6", - "num_cpus", - "time", - "traitobject", - "typeable", - "unicase", - "url 1.7.2", -] - -[[package]] -name = "hyper" -version = "0.14.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2 0.4.4", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.19", - "native-tls", - "tokio", - "tokio-native-tls", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.2.3" @@ -1247,178 +636,58 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ - "autocfg 1.1.0", + "autocfg", "hashbrown", ] -[[package]] -name = "inotify" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" -dependencies = [ - "bitflags", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "ipconfig" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" -dependencies = [ - "socket2 0.3.19", - "widestring", - "winapi 0.3.9", - "winreg 0.6.2", -] - -[[package]] -name = "ipnet" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" - [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] -name = "js-sys" -version = "0.3.58" +name = "jobserver" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log 0.4.17", + "libc", ] [[package]] name = "language-tags" -version = "0.2.2" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "lettre" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ed8677138975b573ab4949c35613931a4addeadd0a8a6aa0327e2a979660de" -dependencies = [ - "base64 0.10.1", - "bufstream", - "fast_chemail", - "hostname 0.1.5", - "log 0.4.17", - "native-tls", - "nom 4.2.3", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "lettre_email" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd02480f8dcf48798e62113974d6ccca2129a51d241fa20f1ea349c8a42559d5" -dependencies = [ - "base64 0.10.1", - "email", - "lettre", - "mime 0.3.16", - "time", - "uuid", -] - -[[package]] -name = "lexical-core" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" -dependencies = [ - "arrayvec", - "bitflags", - "cfg-if 1.0.0", - "ryu", - "static_assertions", -] +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.131" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40" [[package]] -name = "linked-hash-map" -version = "0.5.4" +name = "local-channel" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" +dependencies = [ + "futures-core", + "futures-sink", + "futures-util", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" [[package]] name = "lock_api" @@ -1426,60 +695,19 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ - "autocfg 1.1.0", + "autocfg", "scopeguard", ] -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -dependencies = [ - "log 0.4.17", -] - [[package]] name = "log" version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if 1.0.0", - "value-bag", + "cfg-if", ] -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "mailchecker" -version = "4.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecfb97b7486c4792aafbea9aa1180c492686b351bb6fe98908c4daff00914d3" -dependencies = [ - "fast_chemail", - "once_cell", -] - -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - -[[package]] -name = "match_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" - [[package]] name = "matches" version = "0.1.9" @@ -1492,15 +720,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "mime" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" -dependencies = [ - "log 0.3.9", -] - [[package]] name = "mime" version = "0.3.16" @@ -1508,147 +727,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] -name = "mio" -version = "0.6.23" +name = "mime_guess" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log 0.4.17", - "miow", - "net2", - "slab", - "winapi 0.2.8", + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", ] [[package]] name = "mio" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ "libc", - "log 0.4.17", - "wasi 0.11.0+wasi-snapshot-preview1", + "log", + "wasi", "windows-sys", ] -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" -dependencies = [ - "lazycell", - "log 0.4.17", - "mio 0.6.23", - "slab", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "native-tls" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" -dependencies = [ - "lazy_static", - "libc", - "log 0.4.17", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -dependencies = [ - "memchr", - "version_check 0.1.5", -] - -[[package]] -name = "nom" -version = "5.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" -dependencies = [ - "lexical-core", - "memchr", - "version_check 0.9.4", -] - -[[package]] -name = "notify" -version = "4.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" -dependencies = [ - "bitflags", - "filetime", - "fsevent", - "fsevent-sys", - "inotify", - "libc", - "mio 0.6.23", - "mio-extras", - "walkdir", - "winapi 0.3.9", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg 1.1.0", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "num_cpus" version = "1.13.1" @@ -1659,127 +767,55 @@ dependencies = [ "libc", ] +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + [[package]] name = "once_cell" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] -name = "opaque-debug" -version = "0.2.3" +name = "os_str_bytes" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" -dependencies = [ - "autocfg 1.1.0", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ - "cfg-if 1.0.0", - "instant", + "cfg-if", "libc", "redox_syscall", "smallvec", - "winapi 0.3.9", + "windows-sys", ] [[package]] -name = "pear" -version = "0.1.5" +name = "paste" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32dfa7458144c6af7f9ce6a137ef975466aa68ffa44d4d816ee5934018ba960a" -dependencies = [ - "pear_codegen", -] - -[[package]] -name = "pear_codegen" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0288ba5d581afbc93e2bbd931c1013584c15ecf46b1cdb927edc7abddbc8ca6" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", - "version_check 0.9.4", - "yansi", -] - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" [[package]] name = "percent-encoding" @@ -1789,18 +825,19 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pest" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "69486e2b8c2d2aeb9762db7b4e00b0331156393555cff467f4163ff06821eef8" dependencies = [ + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +checksum = "b13570633aff33c6d22ce47dd566b10a3b9122c2fe9d8e7501895905be532b91" dependencies = [ "pest", "pest_generator", @@ -1808,48 +845,28 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +checksum = "b3c567e5702efdc79fb18859ea74c3eb36e14c43da7b8c1f098a4ed6514ec7a0" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "pest_meta" -version = "2.1.3" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +checksum = "5eb32be5ee3bbdafa8c7a18b0a8a8d962b66cfa2ceee4037f49267a50ee821fe" dependencies = [ - "maplit", + "once_cell", "pest", "sha-1", ] -[[package]] -name = "pin-project" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] - [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1862,36 +879,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" - -[[package]] -name = "polling" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "log 0.4.17", - "wepoll-ffi", - "winapi 0.3.9", -] - -[[package]] -name = "polyval" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -dependencies = [ - "cpuid-bool", - "opaque-debug 0.3.0", - "universal-hash", -] - [[package]] name = "ppv-lite86" version = "0.2.16" @@ -1899,77 +886,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] -name = "proc-macro2" -version = "0.4.30" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "unicode-xid", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", ] [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ "unicode-ident", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" -version = "0.6.13" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" -dependencies = [ - "proc-macro2 1.0.39", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", + "proc-macro2", ] [[package]] @@ -1979,18 +934,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -2000,24 +945,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.3" @@ -2027,91 +957,20 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -2120,146 +979,24 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "reqwest" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" -dependencies = [ - "base64 0.13.0", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper 0.14.19", - "hyper-tls", - "ipnet", - "js-sys", - "lazy_static", - "log 0.4.17", - "mime 0.3.16", - "native-tls", - "percent-encoding 2.1.0", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "tokio-socks", - "tower-service", - "url 2.2.2", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg 0.10.1", -] - -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname 0.3.1", - "quick-error", -] - -[[package]] -name = "rocket" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b9d9dc08c5dcc1d8126a9dd615545e6a358f8c13c883c8dfed8c0376fa355e" -dependencies = [ - "atty", - "base64 0.13.0", - "log 0.4.17", - "memchr", - "num_cpus", - "pear", - "rocket_codegen", - "rocket_http", - "state", - "time", - "toml", - "version_check 0.9.4", - "yansi", -] - -[[package]] -name = "rocket_codegen" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2810037b5820098af97bd4fdd309e76a8101ceb178147de775c835a2537284fe" -dependencies = [ - "devise", - "glob", - "indexmap", - "quote 0.6.13", - "rocket_http", - "version_check 0.9.4", - "yansi", -] - -[[package]] -name = "rocket_contrib" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e20efbc6a211cb3df5375accf532d4186f224b623f39eca650b19b96240c596b" -dependencies = [ - "glob", - "handlebars", - "log 0.4.17", - "notify", - "rocket", - "serde", - "serde_json", -] - -[[package]] -name = "rocket_http" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf9cbd128e1f321a2d0bebd2b7cf0aafd89ca43edf69e49b56a5c46e48eb19f" -dependencies = [ - "cookie", - "hyper 0.10.16", - "indexmap", - "pear", - "percent-encoding 1.0.1", - "smallvec", - "state", - "time", - "unicode-xid", + "semver", ] [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" - -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "same-file" @@ -2270,16 +1007,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" -dependencies = [ - "lazy_static", - "windows-sys", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -2287,53 +1014,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "security-framework" -version = "2.6.1" +name = "semver" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" -dependencies = [ - "core-foundation-sys", - "libc", -] +checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", -] +checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" dependencies = [ "itoa", "ryu", @@ -2354,37 +1050,24 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.8.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", ] [[package]] -name = "signal-hook" -version = "0.3.14" +name = "sha1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +checksum = "c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f" dependencies = [ - "libc", - "signal-hook-registry", + "cfg-if", + "cpufeatures", + "digest", ] [[package]] @@ -2398,26 +1081,18 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" - -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "winapi 0.3.9", -] +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "socket2" @@ -2426,94 +1101,79 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] -name = "state" -version = "0.4.2" +name = "strsim" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "0.15.44" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid", -] - -[[package]] -name = "syn" -version = "1.0.96" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", + "proc-macro2", + "quote", "unicode-ident", ] [[package]] -name = "tempfile" -version = "3.3.0" +name = "termcolor" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ - "cfg-if 1.0.0", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.9", + "winapi-util", ] [[package]] -name = "thiserror" -version = "1.0.31" +name = "textwrap" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "thiserror" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "time" -version = "0.1.44" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "db76ff9fa4b1458b3c7f077f3ff9887394058460d21e634355b273aaf11eea45" dependencies = [ + "itoa", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", + "num_threads", + "time-macros", ] +[[package]] +name = "time-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" + [[package]] name = "tinyvec" version = "1.6.0" @@ -2533,51 +1193,29 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" name = "tlaternet-webserver" version = "0.1.0" dependencies = [ - "check-if-email-exists", - "lettre", - "lettre_email", - "rocket", - "rocket_contrib", - "serde", + "actix-files", + "actix-web", + "clap", + "handlebars", ] [[package]] name = "tokio" -version = "1.19.2" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" dependencies = [ + "autocfg", "bytes", "libc", "memchr", - "mio 0.8.3", - "num_cpus", + "mio", "once_cell", + "parking_lot", "pin-project-lite", - "socket2 0.4.4", - "winapi 0.3.9", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-socks" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" -dependencies = [ - "either", - "futures-util", - "thiserror", - "tokio", + "signal-hook-registry", + "socket2", + "winapi", ] [[package]] @@ -2594,103 +1232,27 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -dependencies = [ - "serde", -] - -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - [[package]] name = "tracing" -version = "0.1.35" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", + "log", "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" -version = "0.1.27" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" dependencies = [ "once_cell", ] -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" - -[[package]] -name = "trust-dns-proto" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31" -dependencies = [ - "async-trait", - "cfg-if 1.0.0", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "log 0.4.17", - "rand 0.8.5", - "smallvec", - "thiserror", - "tinyvec", - "tokio", - "url 2.2.2", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecae383baad9995efaa34ce8e57d12c3f305e545887472a492b838f4b5cfb77a" -dependencies = [ - "cfg-if 1.0.0", - "futures-util", - "ipconfig", - "lazy_static", - "log 0.4.17", - "lru-cache", - "parking_lot", - "resolv-conf", - "smallvec", - "thiserror", - "trust-dns-proto", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "typeable" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" - [[package]] name = "typenum" version = "1.15.0" @@ -2699,17 +1261,17 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" [[package]] name = "unicase" -version = "1.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" dependencies = [ - "version_check 0.1.5", + "version_check", ] [[package]] @@ -2720,46 +1282,19 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array 0.14.5", - "subtle", -] - -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - [[package]] name = "url" version = "2.2.2" @@ -2767,54 +1302,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", - "idna 0.2.3", + "idna", "matches", - "percent-encoding 2.1.0", + "percent-encoding", ] -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -dependencies = [ - "rand 0.6.5", -] - -[[package]] -name = "value-bag" -version = "1.0.0-alpha.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" -dependencies = [ - "ctor", - "version_check 0.9.4", -] - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "walkdir" version = "2.3.2" @@ -2822,129 +1320,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi 0.3.9", + "winapi", "winapi-util", ] -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log 0.4.17", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" -dependencies = [ - "bumpalo", - "lazy_static", - "log 0.4.17", - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" -dependencies = [ - "quote 1.0.18", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" -dependencies = [ - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" - -[[package]] -name = "web-sys" -version = "0.3.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - -[[package]] -name = "widestring" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -2955,12 +1340,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -2973,7 +1352,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3026,44 +1405,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] -name = "winreg" -version = "0.6.2" +name = "zstd" +version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "winapi 0.3.9", + "zstd-safe", ] [[package]] -name = "winreg" -version = "0.10.1" +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" dependencies = [ - "winapi 0.3.9", + "libc", + "zstd-sys", ] [[package]] -name = "winutil" -version = "0.1.1" +name = "zstd-sys" +version = "2.0.1+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" +checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" dependencies = [ - "winapi 0.3.9", + "cc", + "libc", ] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/Cargo.toml b/Cargo.toml index a700d8a..58dda85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,10 @@ [package] name = "tlaternet-webserver" version = "0.1.0" -authors = ["Tristan Daniël Maat "] -edition = "2018" +edition = "2021" [dependencies] -check-if-email-exists = "0.8.5" -lettre = "0.9.3" -lettre_email = "0.9.3" -rocket = "0.4.4" -rocket_contrib = { version = "0.4.4", features = [ "handlebars_templates", "serve" ] } -serde = { version = "1.0.111", features = [ "derive" ] } +actix-files = "0.6.2" +actix-web = "4.1.0" +clap = { version = "3.2.17", features = ["derive"] } +handlebars = { version = "4.3.3", features = ["dir_source"] } diff --git a/src/context.rs b/src/context.rs deleted file mode 100644 index ff90a2a..0000000 --- a/src/context.rs +++ /dev/null @@ -1,38 +0,0 @@ -use rocket::request::FlashMessage; - -use serde::Serialize; - -#[derive(Default, Serialize)] -pub(crate) struct Context { - pub flash: Option, -} - -#[allow(dead_code)] // Want to keep all possible flash types -#[derive(Serialize)] -#[serde(rename_all = "lowercase", tag = "type", content = "message")] -pub(crate) enum Flash { - Primary(String), - Secondary(String), - Success(String), - Danger(String), - Warning(String), - Info(String), - Light(String), - Dark(String), -} - -impl From> for Flash { - fn from(message: FlashMessage) -> Self { - match message.name() { - "success" => Self::Success(message.msg().to_string()), - "warning" => Self::Warning(message.msg().to_string()), - "error" => Self::Danger(message.msg().to_string()), - "primary" => Self::Primary(message.msg().to_string()), - "secondary" => Self::Secondary(message.msg().to_string()), - "info" => Self::Info(message.msg().to_string()), - "light" => Self::Light(message.msg().to_string()), - "dark" => Self::Dark(message.msg().to_string()), - name => Self::Info(format!("{}: {}", name, message.msg())), - } - } -} diff --git a/src/mail.rs b/src/mail.rs deleted file mode 100644 index d8558e4..0000000 --- a/src/mail.rs +++ /dev/null @@ -1,50 +0,0 @@ -use std::fs::create_dir_all; - -use lettre::{FileTransport, Transport}; -use lettre_email::EmailBuilder; -use rocket::request::{Form, FromForm}; -use rocket::response::{Flash, Redirect}; -use rocket::{post, routes, Route}; - -#[derive(FromForm)] -struct Email { - mail: String, - subject: String, - message: String, -} - -fn send_mail(email: &Email) -> Result<(), String> { - let email = EmailBuilder::new() - .to("tm@tlater.net") - .from(email.mail.clone()) - .subject(email.subject.clone()) - .text(email.message.clone()) - .build() - .map_err(|err| format!("Invalid email contents: {}", err))?; - - let mut mailer = FileTransport::new("/srv/mail"); - if let Err(error) = create_dir_all("/srv/mail") { - println!("Could not create mail directory: {}", error); - }; - mailer.send(email.into()).map_err(|err| { - println!("Could not save mail: {}", err); - "Failed to send email due to internal issues; please try again later".to_string() - })?; - - Ok(()) -} - -#[post("/mail.html", data = "")] -fn mail_post(email: Form) -> Result, Flash> { - match send_mail(&email) { - Ok(_) => Ok(Flash::success( - Redirect::to("/mail.html"), - "Email sent successfully", - )), - Err(err) => Err(Flash::error(Redirect::to("/mail.html"), err)), - } -} - -pub fn routes() -> Vec { - routes![mail_post] -} diff --git a/src/main.rs b/src/main.rs index 9161325..013bab2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,34 +1,46 @@ -#![feature(proc_macro_hygiene, decl_macro)] +use std::io; -use rocket::fairing::AdHoc; +use actix_files::Files; +use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder}; +use clap::Parser; +use handlebars::Handlebars; -use rocket_contrib::serve::StaticFiles; -use rocket_contrib::templates::Template; - -mod context; -mod mail; -mod static_templates; - -use mail::routes as mail_routes; -use static_templates::routes as static_templates; - -fn main() { - rocket::ignite() - .attach(Template::fairing()) - .mount("/", mail_routes()) - .mount("/", static_templates()) - .attach(AdHoc::on_attach("Static files config", |rocket| { - let static_path = match rocket.config().get_string("template_dir") { - Ok(dir) => dir, - Err(rocket::config::ConfigError::Missing { .. }) => "templates".to_string(), - Err(err) => { - eprintln!("Error reading configuration: {}", err); - eprintln!("Using default templates path."); - "templates".to_string() - }, - }; - - Ok(rocket.mount("/", StaticFiles::from(static_path))) - })) - .launch(); +#[derive(Parser, Debug)] +struct Config { + template_directory: String, + address: String, + port: u16, +} + +async fn template(hb: web::Data>, req: HttpRequest) -> impl Responder { + let path: String = req + .match_info() + .query("filename") + .parse() + .expect("need a file name on the request"); + + let body = hb.render(path.strip_suffix(".html").unwrap(), &()).unwrap(); + + HttpResponse::Ok().body(body) +} + +#[actix_web::main] +async fn main() -> io::Result<()> { + let config = Config::parse(); + + let mut handlebars = Handlebars::new(); + handlebars + .register_templates_directory(".html", config.template_directory.clone()) + .expect("could not read template directory"); + let handlebars_ref = web::Data::new(handlebars); + + HttpServer::new(move || { + App::new() + .app_data(handlebars_ref.clone()) + .route("/{filename:.*.html}", web::get().to(template)) + .service(Files::new("/", config.template_directory.clone())) + }) + .bind((config.address, config.port))? + .run() + .await } diff --git a/src/static_templates.rs b/src/static_templates.rs deleted file mode 100644 index 2df632c..0000000 --- a/src/static_templates.rs +++ /dev/null @@ -1,78 +0,0 @@ -/// Serve templates "statically". -/// -/// In the generic case, we don't want to do any processing on -/// template pages. They should be served "statically", but we want to -/// transform the bits of default handlebars templating - currently -/// setting the flash to nothing. -/// -/// This module implements a catchall route for this purpose. -use rocket::request::FlashMessage; -use std::ffi::OsString; - -use rocket::http::uri::Segments; -use rocket::request::FromSegments; -use rocket::response::status; -use rocket::{get, routes, Route}; -use rocket_contrib::templates::Template; - -use crate::context::Context; - -pub struct HTMLPage { - pub page: OsString, -} - -impl<'a> FromSegments<'a> for HTMLPage { - type Error = &'static str; - - fn from_segments(segments: Segments<'a>) -> Result { - let page = segments - .into_path_buf(false) - .map_err(|_| "Invalid segments")?; - - page.extension() - .map(|extension| { - if extension == "html" { - Some(HTMLPage { - page: page - .file_stem() - .expect("Should exist if the extension does") - .to_os_string(), - }) - } else { - None - } - }) - .flatten() - .ok_or("Invalid page name") - } -} - -#[get("/")] -pub fn static_index() -> Template { - Template::render("index", Context::default()) -} - -#[get("/")] -pub fn static_templates( - path: HTMLPage, - flash: Option, -) -> Result> { - let path = path.page.into_string().map_err(|path| { - status::BadRequest(Some(format!("Invalid path: {}", path.to_string_lossy()))) - })?; - - if let Some(flash) = flash { - Ok(Template::render( - path, - Context { - flash: Some(flash.into()), - }, - )) - } else { - Ok(Template::render(path, Context::default())) - } -} - -pub fn routes() -> Vec { - routes![static_index, static_templates] -} -- 2.44.1 From d75acc8d0540dc0e28d8b27c5c588677da49c7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Tue, 16 Aug 2022 23:16:39 +0100 Subject: [PATCH 02/14] Clean up error handling, logging and 404 correctly for static files --- Cargo.lock | 21 +++++++++++ Cargo.toml | 2 ++ src/main.rs | 102 +++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 104 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47f59d5..db16587 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -456,6 +456,19 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_logger" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "firestorm" version = "0.5.1" @@ -623,6 +636,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "idna" version = "0.2.3" @@ -1196,7 +1215,9 @@ dependencies = [ "actix-files", "actix-web", "clap", + "env_logger", "handlebars", + "log", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 58dda85..30665c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,6 @@ edition = "2021" actix-files = "0.6.2" actix-web = "4.1.0" clap = { version = "3.2.17", features = ["derive"] } +env_logger = "0.9.0" handlebars = { version = "4.3.3", features = ["dir_source"] } +log = "0.4.17" diff --git a/src/main.rs b/src/main.rs index 013bab2..1820455 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,46 +1,106 @@ -use std::io; +use std::net::SocketAddr; -use actix_files::Files; -use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder}; +use actix_files::NamedFile; +use actix_web::{get, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use clap::Parser; use handlebars::Handlebars; +use std::path::PathBuf; -#[derive(Parser, Debug)] +#[derive(Parser, Debug, Clone)] struct Config { - template_directory: String, - address: String, - port: u16, + #[clap(long, value_parser)] + /// The directory from which to serve static content and + /// handlebars templates + template_directory: PathBuf, + #[clap(long, default_value = "127.0.0.1:8000", value_parser)] + /// The address on which to listen + address: SocketAddr, } -async fn template(hb: web::Data>, req: HttpRequest) -> impl Responder { - let path: String = req +struct SharedData<'a> { + handlebars: Handlebars<'a>, + config: Config, +} + +#[get("/{filename:.*.html}")] +async fn template( + shared: web::Data>, + req: HttpRequest, +) -> Result> { + let path = req .match_info() .query("filename") - .parse() - .expect("need a file name on the request"); + .strip_suffix(".html") + .expect("only paths with this suffix should get here"); - let body = hb.render(path.strip_suffix(".html").unwrap(), &()).unwrap(); + if shared.handlebars.has_template(path) { + let body = shared.handlebars.render(path, &())?; + Ok(HttpResponse::Ok().body(body)) + } else { + let body = shared + .handlebars + .render("404", &()) + .expect("404 template not found"); + Ok(HttpResponse::NotFound().body(body)) + } +} - HttpResponse::Ok().body(body) +#[get("/{filename:.*}")] +async fn static_file( + shared: web::Data>, + req: HttpRequest, +) -> Result> { + let requested = req.match_info().query("filename"); + + match shared + .config + .template_directory + .join(requested) + .canonicalize() + { + // We only want to serve paths that are both valid *and* in + // the template directory. + // + // i.e., don't serve up /etc/passwd + Ok(path) if path.starts_with(&shared.config.template_directory) => { + let file = NamedFile::open_async(path).await?; + Ok(file.use_last_modified(false).respond_to(&req)) + } + // Any other cases should 404 + _ => { + let body = shared + .handlebars + .render("404", &()) + .expect("404 template not found"); + Ok(HttpResponse::NotFound().body(body)) + } + } } #[actix_web::main] -async fn main() -> io::Result<()> { - let config = Config::parse(); +async fn main() -> Result<(), std::io::Error> { + let mut config = Config::parse(); + config.template_directory = config.template_directory.canonicalize()?; + + env_logger::init(); let mut handlebars = Handlebars::new(); handlebars .register_templates_directory(".html", config.template_directory.clone()) - .expect("could not read template directory"); - let handlebars_ref = web::Data::new(handlebars); + .expect("templates should compile correctly"); + + let shared_data = web::Data::new(SharedData { + handlebars, + config: config.clone(), + }); HttpServer::new(move || { App::new() - .app_data(handlebars_ref.clone()) - .route("/{filename:.*.html}", web::get().to(template)) - .service(Files::new("/", config.template_directory.clone())) + .app_data(shared_data.clone()) + .service(template) + .service(static_file) }) - .bind((config.address, config.port))? + .bind(config.address)? .run() .await } -- 2.44.1 From 98d71f031121c26f4f08721ca860c003e55915b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Tue, 16 Aug 2022 23:51:07 +0100 Subject: [PATCH 03/14] Add dev mode --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1820455..1a4fcc4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,10 @@ struct Config { #[clap(long, default_value = "127.0.0.1:8000", value_parser)] /// The address on which to listen address: SocketAddr, + #[clap(long, action)] + /// Whether to start the server in dev mode; this enables some + /// nice handlebars features that are not intended for production + dev_mode: bool, } struct SharedData<'a> { @@ -88,6 +92,7 @@ async fn main() -> Result<(), std::io::Error> { handlebars .register_templates_directory(".html", config.template_directory.clone()) .expect("templates should compile correctly"); + handlebars.set_dev_mode(config.dev_mode); let shared_data = web::Data::new(SharedData { handlebars, -- 2.44.1 From ab405fc1f8921eda8d0fff5c2b6c7e73d5f137b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Tue, 6 Sep 2022 15:14:42 +0100 Subject: [PATCH 04/14] Add proper error handling --- Cargo.lock | 2 ++ Cargo.toml | 2 ++ src/errors.rs | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 46 ++++++++++++++++++------------- 4 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 src/errors.rs diff --git a/Cargo.lock b/Cargo.lock index db16587..e01309f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1215,9 +1215,11 @@ dependencies = [ "actix-files", "actix-web", "clap", + "derive_more", "env_logger", "handlebars", "log", + "serde_json", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 30665c6..b2304a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,8 @@ edition = "2021" actix-files = "0.6.2" actix-web = "4.1.0" clap = { version = "3.2.17", features = ["derive"] } +derive_more = "0.99.17" env_logger = "0.9.0" handlebars = { version = "4.3.3", features = ["dir_source"] } log = "0.4.17" +serde_json = "1.0.83" diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..2f44792 --- /dev/null +++ b/src/errors.rs @@ -0,0 +1,76 @@ +use actix_web::body::BoxBody; +use actix_web::dev::ServiceResponse; +use actix_web::http::header::ContentType; +use actix_web::http::StatusCode; +use actix_web::middleware::ErrorHandlerResponse; +use actix_web::{web, HttpResponse, ResponseError}; +use derive_more::{Display, Error}; +use serde_json::json; + +use super::SharedData; + +#[derive(Debug, Display, Error)] +pub enum UserError { + // #[display(fmt = "The page could not be found.")] + NotFound, + #[display(fmt = "Internal error. Try again later.")] + InternalError, +} + +impl ResponseError for UserError { + fn error_response(&self) -> HttpResponse { + HttpResponse::build(self.status_code()) + .insert_header(ContentType::html()) + .body(self.to_string()) + } + + fn status_code(&self) -> StatusCode { + match *self { + UserError::NotFound => StatusCode::NOT_FOUND, + UserError::InternalError => StatusCode::INTERNAL_SERVER_ERROR, + } + } +} + +pub fn generic_error( + res: ServiceResponse, +) -> actix_web::Result> { + let data = res + .request() + .app_data::>() + .map(|t| t.get_ref()); + + let status_code = res.response().status(); + let message = if let Some(error) = status_code.canonical_reason() { + error + } else { + "" + }; + + let response = match data { + Some(SharedData { + handlebars, + config: _, + }) => { + let body = handlebars + .render( + "error", + &json!({ + "message": message, + "status_code": status_code.as_u16() + }), + ) + .map_err(|_| UserError::InternalError)?; + + HttpResponse::build(res.status()) + .content_type(ContentType::html()) + .body(body) + } + None => Err(UserError::InternalError)?, + }; + + Ok(ErrorHandlerResponse::Response(ServiceResponse::new( + res.into_parts().0, + response.map_into_left_body(), + ))) +} diff --git a/src/main.rs b/src/main.rs index 1a4fcc4..5af199f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,17 @@ +#![allow(dead_code)] use std::net::SocketAddr; +use std::path::PathBuf; use actix_files::NamedFile; +use actix_web::http::StatusCode; +use actix_web::middleware::ErrorHandlers; use actix_web::{get, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use clap::Parser; use handlebars::Handlebars; -use std::path::PathBuf; + +mod errors; + +use errors::{generic_error, UserError}; #[derive(Parser, Debug, Clone)] struct Config { @@ -21,16 +28,17 @@ struct Config { dev_mode: bool, } +#[derive(Debug)] struct SharedData<'a> { handlebars: Handlebars<'a>, config: Config, } -#[get("/{filename:.*.html}")] +#[get(r"/{filename:.*\.html}")] async fn template( shared: web::Data>, req: HttpRequest, -) -> Result> { +) -> actix_web::Result { let path = req .match_info() .query("filename") @@ -38,22 +46,21 @@ async fn template( .expect("only paths with this suffix should get here"); if shared.handlebars.has_template(path) { - let body = shared.handlebars.render(path, &())?; - Ok(HttpResponse::Ok().body(body)) - } else { let body = shared .handlebars - .render("404", &()) - .expect("404 template not found"); - Ok(HttpResponse::NotFound().body(body)) + .render(path, &()) + .map_err(|_| UserError::InternalError)?; + Ok(HttpResponse::Ok().body(body)) + } else { + Err(UserError::NotFound)? } } -#[get("/{filename:.*}")] +#[get("/{filename:.*[^/]+}")] async fn static_file( shared: web::Data>, req: HttpRequest, -) -> Result> { +) -> actix_web::Result { let requested = req.match_info().query("filename"); match shared @@ -67,17 +74,13 @@ async fn static_file( // // i.e., don't serve up /etc/passwd Ok(path) if path.starts_with(&shared.config.template_directory) => { - let file = NamedFile::open_async(path).await?; + let file = NamedFile::open_async(path) + .await + .map_err(|_| UserError::NotFound)?; Ok(file.use_last_modified(false).respond_to(&req)) } // Any other cases should 404 - _ => { - let body = shared - .handlebars - .render("404", &()) - .expect("404 template not found"); - Ok(HttpResponse::NotFound().body(body)) - } + _ => Err(UserError::NotFound)?, } } @@ -101,6 +104,11 @@ async fn main() -> Result<(), std::io::Error> { HttpServer::new(move || { App::new() + .wrap( + ErrorHandlers::new() + .handler(StatusCode::NOT_FOUND, generic_error) + .handler(StatusCode::INTERNAL_SERVER_ERROR, generic_error), + ) .app_data(shared_data.clone()) .service(template) .service(static_file) -- 2.44.1 From 2847dad110b6f06e39bbd308c3f2c3c286412231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 9 Sep 2022 18:40:49 +0100 Subject: [PATCH 05/14] Add index page rendering --- src/main.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5af199f..137ea57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,9 @@ use std::net::SocketAddr; use std::path::PathBuf; use actix_files::NamedFile; -use actix_web::http::StatusCode; -use actix_web::middleware::ErrorHandlers; use actix_web::{get, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; +use actix_web::http::{Method, StatusCode}; +use actix_web::middleware::{self, ErrorHandlers}; use clap::Parser; use handlebars::Handlebars; @@ -56,6 +56,19 @@ async fn template( } } +#[get(r"/")] +async fn template_index(shared: web::Data>) -> actix_web::Result { + if shared.handlebars.has_template("index") { + let body = shared + .handlebars + .render("index", &()) + .map_err(|_| UserError::InternalError)?; + Ok(HttpResponse::Ok().body(body)) + } else { + Err(UserError::NotFound)? + } +} + #[get("/{filename:.*[^/]+}")] async fn static_file( shared: web::Data>, @@ -104,6 +117,7 @@ async fn main() -> Result<(), std::io::Error> { HttpServer::new(move || { App::new() + .wrap(middleware::NormalizePath::trim()) .wrap( ErrorHandlers::new() .handler(StatusCode::NOT_FOUND, generic_error) @@ -112,6 +126,8 @@ async fn main() -> Result<(), std::io::Error> { .app_data(shared_data.clone()) .service(template) .service(static_file) + .service(template_index) + .default_service(web::route().method(Method::GET)) }) .bind(config.address)? .run() -- 2.44.1 From 91e905730e79b02c70d227977c4d7dea6bcde56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 9 Sep 2022 18:41:04 +0100 Subject: [PATCH 06/14] Handle post to mail page --- Cargo.lock | 19 +++++++++++++++++-- Cargo.toml | 1 + src/main.rs | 30 +++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e01309f..1a5cb11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1040,9 +1040,23 @@ checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" [[package]] name = "serde" -version = "1.0.143" +version = "1.0.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "serde_json" @@ -1219,6 +1233,7 @@ dependencies = [ "env_logger", "handlebars", "log", + "serde", "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index b2304a0..1ad1857 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ derive_more = "0.99.17" env_logger = "0.9.0" handlebars = { version = "4.3.3", features = ["dir_source"] } log = "0.4.17" +serde = {version = "1.0.144", features = ["derive"]} serde_json = "1.0.83" diff --git a/src/main.rs b/src/main.rs index 137ea57..44bfca1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,13 @@ use std::net::SocketAddr; use std::path::PathBuf; use actix_files::NamedFile; -use actix_web::{get, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use actix_web::http::{Method, StatusCode}; use actix_web::middleware::{self, ErrorHandlers}; +use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use clap::Parser; use handlebars::Handlebars; +use log::info; +use serde::Deserialize; mod errors; @@ -97,6 +99,31 @@ async fn static_file( } } +#[derive(Clone, Debug, Deserialize)] +struct Mail { + mail: String, + subject: String, + message: String, +} + +#[post("/mail.html")] +async fn mail_post( + shared: web::Data>, + form: web::Form, +) -> actix_web::Result { + info!("{:?}", form); + + if shared.handlebars.has_template("mail") { + let body = shared + .handlebars + .render("mail", &()) + .map_err(|_| UserError::InternalError)?; + Ok(HttpResponse::Ok().body(body)) + } else { + Err(UserError::InternalError)? + } +} + #[actix_web::main] async fn main() -> Result<(), std::io::Error> { let mut config = Config::parse(); @@ -127,6 +154,7 @@ async fn main() -> Result<(), std::io::Error> { .service(template) .service(static_file) .service(template_index) + .service(mail_post) .default_service(web::route().method(Method::GET)) }) .bind(config.address)? -- 2.44.1 From 627a7525f352e79f4f14b2008f683ce372fa44f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sun, 11 Sep 2022 17:00:41 +0100 Subject: [PATCH 07/14] Factor out resources --- Cargo.lock | 157 ++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 103 +++--------------------------- src/main_pages.rs | 97 ++++++++++++++++++++++++++++ 4 files changed, 263 insertions(+), 95 deletions(-) create mode 100644 src/main_pages.rs diff --git a/Cargo.lock b/Cargo.lock index 1a5cb11..2e8ac2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,12 +204,63 @@ dependencies = [ "syn", ] +[[package]] +name = "actix-web-flash-messages" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c89d051c33e7044e8a6e811ed06dda6ce65dfb51a1e379146f723116ca362a" +dependencies = [ + "actix-web", + "anyhow", + "percent-encoding", + "serde", + "serde_json", + "thiserror", + "time", + "tokio", +] + [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", +] + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "opaque-debug", +] + +[[package]] +name = "aes-gcm" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + [[package]] name = "ahash" version = "0.7.6" @@ -245,6 +296,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "anyhow" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9a8f622bcf6ff3df478e9deba3e03e4e04b300f8e6a139e192c05fa3490afc7" + [[package]] name = "askama_escape" version = "0.10.3" @@ -340,6 +397,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + [[package]] name = "clap" version = "3.2.17" @@ -391,7 +457,14 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ + "aes-gcm", + "base64", + "hkdf", + "hmac", "percent-encoding", + "rand", + "sha2", + "subtle", "time", "version_check", ] @@ -424,6 +497,15 @@ dependencies = [ "typenum", ] +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -445,6 +527,7 @@ checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ "block-buffer", "crypto-common", + "subtle", ] [[package]] @@ -552,6 +635,16 @@ dependencies = [ "wasi", ] +[[package]] +name = "ghash" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +dependencies = [ + "opaque-debug", + "polyval", +] + [[package]] name = "h2" version = "0.3.13" @@ -607,6 +700,24 @@ dependencies = [ "libc", ] +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "http" version = "0.2.8" @@ -801,6 +912,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "os_str_bytes" version = "6.3.0" @@ -898,6 +1015,18 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.16" @@ -1103,6 +1232,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1143,6 +1283,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + [[package]] name = "syn" version = "1.0.99" @@ -1228,6 +1374,7 @@ version = "0.1.0" dependencies = [ "actix-files", "actix-web", + "actix-web-flash-messages", "clap", "derive_more", "env_logger", @@ -1333,6 +1480,16 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "universal-hash" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +dependencies = [ + "generic-array", + "subtle", +] + [[package]] name = "url" version = "2.2.2" diff --git a/Cargo.toml b/Cargo.toml index 1ad1857..cd34634 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] actix-files = "0.6.2" actix-web = "4.1.0" +actix-web-flash-messages = {version = "0.4", features = ["cookies"]} clap = { version = "3.2.17", features = ["derive"] } derive_more = "0.99.17" env_logger = "0.9.0" diff --git a/src/main.rs b/src/main.rs index 44bfca1..a4ca4ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,18 +2,19 @@ use std::net::SocketAddr; use std::path::PathBuf; -use actix_files::NamedFile; -use actix_web::http::{Method, StatusCode}; -use actix_web::middleware::{self, ErrorHandlers}; -use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; +use actix_web::{ + http::{Method, StatusCode}, + middleware::{self, ErrorHandlers}, + web, App, HttpServer, +}; use clap::Parser; use handlebars::Handlebars; -use log::info; -use serde::Deserialize; mod errors; +mod main_pages; -use errors::{generic_error, UserError}; +use errors::generic_error; +use main_pages::{mail_post, static_file, template, template_index}; #[derive(Parser, Debug, Clone)] struct Config { @@ -36,94 +37,6 @@ struct SharedData<'a> { config: Config, } -#[get(r"/{filename:.*\.html}")] -async fn template( - shared: web::Data>, - req: HttpRequest, -) -> actix_web::Result { - let path = req - .match_info() - .query("filename") - .strip_suffix(".html") - .expect("only paths with this suffix should get here"); - - if shared.handlebars.has_template(path) { - let body = shared - .handlebars - .render(path, &()) - .map_err(|_| UserError::InternalError)?; - Ok(HttpResponse::Ok().body(body)) - } else { - Err(UserError::NotFound)? - } -} - -#[get(r"/")] -async fn template_index(shared: web::Data>) -> actix_web::Result { - if shared.handlebars.has_template("index") { - let body = shared - .handlebars - .render("index", &()) - .map_err(|_| UserError::InternalError)?; - Ok(HttpResponse::Ok().body(body)) - } else { - Err(UserError::NotFound)? - } -} - -#[get("/{filename:.*[^/]+}")] -async fn static_file( - shared: web::Data>, - req: HttpRequest, -) -> actix_web::Result { - let requested = req.match_info().query("filename"); - - match shared - .config - .template_directory - .join(requested) - .canonicalize() - { - // We only want to serve paths that are both valid *and* in - // the template directory. - // - // i.e., don't serve up /etc/passwd - Ok(path) if path.starts_with(&shared.config.template_directory) => { - let file = NamedFile::open_async(path) - .await - .map_err(|_| UserError::NotFound)?; - Ok(file.use_last_modified(false).respond_to(&req)) - } - // Any other cases should 404 - _ => Err(UserError::NotFound)?, - } -} - -#[derive(Clone, Debug, Deserialize)] -struct Mail { - mail: String, - subject: String, - message: String, -} - -#[post("/mail.html")] -async fn mail_post( - shared: web::Data>, - form: web::Form, -) -> actix_web::Result { - info!("{:?}", form); - - if shared.handlebars.has_template("mail") { - let body = shared - .handlebars - .render("mail", &()) - .map_err(|_| UserError::InternalError)?; - Ok(HttpResponse::Ok().body(body)) - } else { - Err(UserError::InternalError)? - } -} - #[actix_web::main] async fn main() -> Result<(), std::io::Error> { let mut config = Config::parse(); diff --git a/src/main_pages.rs b/src/main_pages.rs new file mode 100644 index 0000000..91cae03 --- /dev/null +++ b/src/main_pages.rs @@ -0,0 +1,97 @@ +use actix_files::NamedFile; +use actix_web::{get, post, web, HttpRequest, HttpResponse, Responder}; +use log::info; +use serde::Deserialize; + +use crate::errors::UserError; +use crate::SharedData; + +#[derive(Clone, Debug, Deserialize)] +pub(crate) struct Mail { + mail: String, + subject: String, + message: String, +} + +#[get(r"/")] +pub(crate) async fn template_index( + shared: web::Data>, +) -> actix_web::Result { + if shared.handlebars.has_template("index") { + let body = shared + .handlebars + .render("index", &()) + .map_err(|_| UserError::InternalError)?; + Ok(HttpResponse::Ok().body(body)) + } else { + Err(UserError::NotFound)? + } +} + +#[get(r"/{filename:.*\.html}")] +pub(crate) async fn template( + shared: web::Data>, + req: HttpRequest, +) -> actix_web::Result { + let path = req + .match_info() + .query("filename") + .strip_suffix(".html") + .expect("only paths with this suffix should get here"); + + if shared.handlebars.has_template(path) { + let body = shared + .handlebars + .render(path, &()) + .map_err(|_| UserError::InternalError)?; + Ok(HttpResponse::Ok().body(body)) + } else { + Err(UserError::NotFound)? + } +} + +#[get("/{filename:.*[^/]+}")] +pub(crate) async fn static_file( + shared: web::Data>, + req: HttpRequest, +) -> actix_web::Result { + let requested = req.match_info().query("filename"); + + match shared + .config + .template_directory + .join(requested) + .canonicalize() + { + // We only want to serve paths that are both valid *and* in + // the template directory. + // + // i.e., don't serve up /etc/passwd + Ok(path) if path.starts_with(&shared.config.template_directory) => { + let file = NamedFile::open_async(path) + .await + .map_err(|_| UserError::NotFound)?; + Ok(file.use_last_modified(false).respond_to(&req)) + } + // Any other cases should 404 + _ => Err(UserError::NotFound)?, + } +} + +#[post("/mail.html")] +pub(crate) async fn mail_post( + shared: web::Data>, + form: web::Form, +) -> actix_web::Result { + info!("{:?}", form); + + if shared.handlebars.has_template("mail") { + let body = shared + .handlebars + .render("mail", &()) + .map_err(|_| UserError::InternalError)?; + Ok(HttpResponse::Ok().body(body)) + } else { + Err(UserError::InternalError)? + } +} -- 2.44.1 From 9035cf5419c5d8c36a209dd4f0eac5d41ac69b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Mon, 12 Sep 2022 18:13:38 +0100 Subject: [PATCH 08/14] Implement template args more nicely --- Cargo.lock | 157 ------------------------------------------ Cargo.toml | 1 - src/errors.rs | 14 ++-- src/main.rs | 3 +- src/main_pages.rs | 8 ++- src/template_utils.rs | 87 +++++++++++++++++++++++ 6 files changed, 102 insertions(+), 168 deletions(-) create mode 100644 src/template_utils.rs diff --git a/Cargo.lock b/Cargo.lock index 2e8ac2a..1a5cb11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,63 +204,12 @@ dependencies = [ "syn", ] -[[package]] -name = "actix-web-flash-messages" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c89d051c33e7044e8a6e811ed06dda6ce65dfb51a1e379146f723116ca362a" -dependencies = [ - "actix-web", - "anyhow", - "percent-encoding", - "serde", - "serde_json", - "thiserror", - "time", - "tokio", -] - [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", - "opaque-debug", -] - -[[package]] -name = "aes-gcm" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - [[package]] name = "ahash" version = "0.7.6" @@ -296,12 +245,6 @@ dependencies = [ "alloc-no-stdlib", ] -[[package]] -name = "anyhow" -version = "1.0.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9a8f622bcf6ff3df478e9deba3e03e4e04b300f8e6a139e192c05fa3490afc7" - [[package]] name = "askama_escape" version = "0.10.3" @@ -397,15 +340,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array", -] - [[package]] name = "clap" version = "3.2.17" @@ -457,14 +391,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ - "aes-gcm", - "base64", - "hkdf", - "hmac", "percent-encoding", - "rand", - "sha2", - "subtle", "time", "version_check", ] @@ -497,15 +424,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" -dependencies = [ - "cipher", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -527,7 +445,6 @@ checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ "block-buffer", "crypto-common", - "subtle", ] [[package]] @@ -635,16 +552,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "ghash" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" -dependencies = [ - "opaque-debug", - "polyval", -] - [[package]] name = "h2" version = "0.3.13" @@ -700,24 +607,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hkdf" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" -dependencies = [ - "hmac", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "http" version = "0.2.8" @@ -912,12 +801,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "os_str_bytes" version = "6.3.0" @@ -1015,18 +898,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "polyval" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug", - "universal-hash", -] - [[package]] name = "ppv-lite86" version = "0.2.16" @@ -1232,17 +1103,6 @@ dependencies = [ "digest", ] -[[package]] -name = "sha2" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1283,12 +1143,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "1.0.99" @@ -1374,7 +1228,6 @@ version = "0.1.0" dependencies = [ "actix-files", "actix-web", - "actix-web-flash-messages", "clap", "derive_more", "env_logger", @@ -1480,16 +1333,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "url" version = "2.2.2" diff --git a/Cargo.toml b/Cargo.toml index cd34634..1ad1857 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] actix-files = "0.6.2" actix-web = "4.1.0" -actix-web-flash-messages = {version = "0.4", features = ["cookies"]} clap = { version = "3.2.17", features = ["derive"] } derive_more = "0.99.17" env_logger = "0.9.0" diff --git a/src/errors.rs b/src/errors.rs index 2f44792..6d02d1b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -5,9 +5,9 @@ use actix_web::http::StatusCode; use actix_web::middleware::ErrorHandlerResponse; use actix_web::{web, HttpResponse, ResponseError}; use derive_more::{Display, Error}; -use serde_json::json; use super::SharedData; +use crate::template_utils::{ErrorMessage, TemplateArgs}; #[derive(Debug, Display, Error)] pub enum UserError { @@ -52,14 +52,12 @@ pub fn generic_error( handlebars, config: _, }) => { + let args = TemplateArgs::builder() + .error_page(ErrorMessage::new(message, status_code.as_u16())) + .build(); + let body = handlebars - .render( - "error", - &json!({ - "message": message, - "status_code": status_code.as_u16() - }), - ) + .render("error", &args) .map_err(|_| UserError::InternalError)?; HttpResponse::build(res.status()) diff --git a/src/main.rs b/src/main.rs index a4ca4ab..94327fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use handlebars::Handlebars; mod errors; mod main_pages; +mod template_utils; use errors::generic_error; use main_pages::{mail_post, static_file, template, template_index}; @@ -38,7 +39,7 @@ struct SharedData<'a> { } #[actix_web::main] -async fn main() -> Result<(), std::io::Error> { +async fn main() -> std::io::Result<()> { let mut config = Config::parse(); config.template_directory = config.template_directory.canonicalize()?; diff --git a/src/main_pages.rs b/src/main_pages.rs index 91cae03..3f247a7 100644 --- a/src/main_pages.rs +++ b/src/main_pages.rs @@ -4,6 +4,8 @@ use log::info; use serde::Deserialize; use crate::errors::UserError; +use crate::template_utils::TemplateArgs; +use crate::template_utils::{Flash, FlashType}; use crate::SharedData; #[derive(Clone, Debug, Deserialize)] @@ -85,10 +87,14 @@ pub(crate) async fn mail_post( ) -> actix_web::Result { info!("{:?}", form); + let args = TemplateArgs::builder() + .flash(Flash::new("Mail successfully sent!", FlashType::Success)) + .build(); + if shared.handlebars.has_template("mail") { let body = shared .handlebars - .render("mail", &()) + .render("mail", &args) .map_err(|_| UserError::InternalError)?; Ok(HttpResponse::Ok().body(body)) } else { diff --git a/src/template_utils.rs b/src/template_utils.rs new file mode 100644 index 0000000..84be858 --- /dev/null +++ b/src/template_utils.rs @@ -0,0 +1,87 @@ +use serde::Serialize; + +/** All arguments that can be given to a template. */ +#[derive(Serialize)] +pub struct TemplateArgs { + flash: Option, + error: Option, +} + +impl TemplateArgs { + pub fn builder() -> TemplateArgsBuilder { + TemplateArgsBuilder::new() + } +} + +pub struct TemplateArgsBuilder { + flash: Option, + error: Option, +} + +impl TemplateArgsBuilder { + pub fn new() -> Self { + TemplateArgsBuilder { + flash: None, + error: None, + } + } + + pub fn flash(mut self, flash: Flash) -> Self { + self.flash = Some(flash); + self + } + + pub fn error_page(mut self, error: ErrorMessage) -> Self { + self.error = Some(error); + self + } + + pub fn build(self) -> TemplateArgs { + TemplateArgs { + flash: self.flash, + error: self.error, + } + } +} + +/** A flash message that should be displayed as a notification on the page. */ +#[derive(Serialize)] +pub struct Flash { + message: String, + #[serde(rename = "type")] + level: FlashType, +} + +impl Flash { + pub fn new(message: &str, level: FlashType) -> Self { + Self { + message: message.to_string(), + level, + } + } +} + +#[derive(Serialize)] +#[serde(rename_all = "lowercase")] +pub enum FlashType { + Info, + Success, + Warning, + Danger, +} + +/** Contents of an error page. */ +#[derive(Serialize)] +pub struct ErrorMessage { + message: String, + status_code: u16, +} + +impl ErrorMessage { + pub fn new(message: &str, status_code: u16) -> Self { + Self { + message: message.to_string(), + status_code, + } + } +} -- 2.44.1 From a960bf4b27459258a5063da5999641cd68a07477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 16 Sep 2022 17:16:12 +0100 Subject: [PATCH 09/14] Use actix-web 4.2.1 features to clean up resource handling --- Cargo.lock | 13 +++---- Cargo.toml | 2 +- src/errors.rs | 5 ++- src/main.rs | 6 ++-- src/main_pages.rs | 82 +++++++------------------------------------ src/template_utils.rs | 18 +++++++++- 6 files changed, 42 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a5cb11..e5fde96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,9 +44,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.2.1" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f9ffb6db08c1c3a1f4aef540f1a63193adc73c4fbd40b75a95fc8c5258f6e51" +checksum = "0c83abf9903e1f0ad9973cc4f7b9767fd5a03a583f51a5b7a339e07987cd2724" dependencies = [ "actix-codec", "actix-rt", @@ -154,9 +154,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.1.0" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27e8fe9ba4ae613c21f677c2cfaf0696c3744030c6f485b34634e502d6bb379" +checksum = "d48f7b6534e06c7bfc72ee91db7917d4af6afe23e7d223b51e68fffbb21e96b9" dependencies = [ "actix-codec", "actix-http", @@ -176,6 +176,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", + "http", "itoa", "language-tags", "log", @@ -194,9 +195,9 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "4.0.1" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f270541caec49c15673b0af0e9a00143421ad4f118d2df7edcb68b627632f56" +checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" dependencies = [ "actix-router", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 1ad1857..14a5f17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] actix-files = "0.6.2" -actix-web = "4.1.0" +actix-web = { version = "4.2.1", features = ["macros"] } clap = { version = "3.2.17", features = ["derive"] } derive_more = "0.99.17" env_logger = "0.9.0" diff --git a/src/errors.rs b/src/errors.rs index 6d02d1b..9770c00 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -7,7 +7,7 @@ use actix_web::{web, HttpResponse, ResponseError}; use derive_more::{Display, Error}; use super::SharedData; -use crate::template_utils::{ErrorMessage, TemplateArgs}; +use crate::template_utils::{render_template, ErrorMessage, TemplateArgs}; #[derive(Debug, Display, Error)] pub enum UserError { @@ -56,8 +56,7 @@ pub fn generic_error( .error_page(ErrorMessage::new(message, status_code.as_u16())) .build(); - let body = handlebars - .render("error", &args) + let body = render_template(handlebars, "error", &args) .map_err(|_| UserError::InternalError)?; HttpResponse::build(res.status()) diff --git a/src/main.rs b/src/main.rs index 94327fb..df73a34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::net::SocketAddr; use std::path::PathBuf; +use actix_files::Files; use actix_web::{ http::{Method, StatusCode}, middleware::{self, ErrorHandlers}, @@ -15,7 +16,7 @@ mod main_pages; mod template_utils; use errors::generic_error; -use main_pages::{mail_post, static_file, template, template_index}; +use main_pages::{mail_post, template}; #[derive(Parser, Debug, Clone)] struct Config { @@ -66,9 +67,8 @@ async fn main() -> std::io::Result<()> { ) .app_data(shared_data.clone()) .service(template) - .service(static_file) - .service(template_index) .service(mail_post) + .service(Files::new("/", &config.template_directory)) .default_service(web::route().method(Method::GET)) }) .bind(config.address)? diff --git a/src/main_pages.rs b/src/main_pages.rs index 3f247a7..ab77276 100644 --- a/src/main_pages.rs +++ b/src/main_pages.rs @@ -1,11 +1,8 @@ -use actix_files::NamedFile; -use actix_web::{get, post, web, HttpRequest, HttpResponse, Responder}; +use actix_web::{post, routes, web, HttpRequest, HttpResponse, Responder}; use log::info; use serde::Deserialize; -use crate::errors::UserError; -use crate::template_utils::TemplateArgs; -use crate::template_utils::{Flash, FlashType}; +use crate::template_utils::{render_template, Flash, FlashType, TemplateArgs}; use crate::SharedData; #[derive(Clone, Debug, Deserialize)] @@ -15,69 +12,22 @@ pub(crate) struct Mail { message: String, } +#[routes] #[get(r"/")] -pub(crate) async fn template_index( - shared: web::Data>, -) -> actix_web::Result { - if shared.handlebars.has_template("index") { - let body = shared - .handlebars - .render("index", &()) - .map_err(|_| UserError::InternalError)?; - Ok(HttpResponse::Ok().body(body)) - } else { - Err(UserError::NotFound)? - } -} - #[get(r"/{filename:.*\.html}")] pub(crate) async fn template( shared: web::Data>, req: HttpRequest, ) -> actix_web::Result { - let path = req - .match_info() - .query("filename") - .strip_suffix(".html") - .expect("only paths with this suffix should get here"); + let path = match req.match_info().query("filename") { + "" => "index", + other => other + .strip_suffix(".html") + .expect("only paths with this suffix should get here"), + }; - if shared.handlebars.has_template(path) { - let body = shared - .handlebars - .render(path, &()) - .map_err(|_| UserError::InternalError)?; - Ok(HttpResponse::Ok().body(body)) - } else { - Err(UserError::NotFound)? - } -} - -#[get("/{filename:.*[^/]+}")] -pub(crate) async fn static_file( - shared: web::Data>, - req: HttpRequest, -) -> actix_web::Result { - let requested = req.match_info().query("filename"); - - match shared - .config - .template_directory - .join(requested) - .canonicalize() - { - // We only want to serve paths that are both valid *and* in - // the template directory. - // - // i.e., don't serve up /etc/passwd - Ok(path) if path.starts_with(&shared.config.template_directory) => { - let file = NamedFile::open_async(path) - .await - .map_err(|_| UserError::NotFound)?; - Ok(file.use_last_modified(false).respond_to(&req)) - } - // Any other cases should 404 - _ => Err(UserError::NotFound)?, - } + render_template(&shared.handlebars, path, &TemplateArgs::default()) + .map(|body| HttpResponse::Ok().body(body)) } #[post("/mail.html")] @@ -91,13 +41,5 @@ pub(crate) async fn mail_post( .flash(Flash::new("Mail successfully sent!", FlashType::Success)) .build(); - if shared.handlebars.has_template("mail") { - let body = shared - .handlebars - .render("mail", &args) - .map_err(|_| UserError::InternalError)?; - Ok(HttpResponse::Ok().body(body)) - } else { - Err(UserError::InternalError)? - } + render_template(&shared.handlebars, "mail", &args).map(|body| HttpResponse::Ok().body(body)) } diff --git a/src/template_utils.rs b/src/template_utils.rs index 84be858..d80b82c 100644 --- a/src/template_utils.rs +++ b/src/template_utils.rs @@ -1,7 +1,23 @@ use serde::Serialize; +use crate::errors::UserError; + +pub fn render_template( + handlebars: &handlebars::Handlebars, + name: &str, + args: &TemplateArgs, +) -> actix_web::Result { + if handlebars.has_template(name) { + Ok(handlebars + .render(name, args) + .map_err(|_| UserError::InternalError)?) + } else { + Err(UserError::NotFound)? + } +} + /** All arguments that can be given to a template. */ -#[derive(Serialize)] +#[derive(Default, Serialize)] pub struct TemplateArgs { flash: Option, error: Option, -- 2.44.1 From 527c476fb44a0ef672e6e81c8879b51183eb40ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 16 Sep 2022 17:16:32 +0100 Subject: [PATCH 10/14] .dir-locals.el: Set up projectile run command --- .dir-locals.el | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..867e61c --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,4 @@ +((nil . ((indent-tabs-mode . nil) + (tab-width . 4) + (fill-column . 80) + (projectile-project-run-cmd . "cargo run -- --dev-mode --template-directory ~/Documents/Projects/tlaternet-templates/result")))) -- 2.44.1 From b653d3a3f6da6c7bc92d371392e062aff13ca550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 16 Sep 2022 17:18:03 +0100 Subject: [PATCH 11/14] errors.rs: Remove superfluous comment --- src/errors.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/errors.rs b/src/errors.rs index 9770c00..1f076f1 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -11,7 +11,6 @@ use crate::template_utils::{render_template, ErrorMessage, TemplateArgs}; #[derive(Debug, Display, Error)] pub enum UserError { - // #[display(fmt = "The page could not be found.")] NotFound, #[display(fmt = "Internal error. Try again later.")] InternalError, -- 2.44.1 From 20a6291ac9d3d0380381a4df24ea4417c36d944a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 16 Sep 2022 17:22:46 +0100 Subject: [PATCH 12/14] main.rs: Add comment about better error handling --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index df73a34..b86c60b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,6 +60,10 @@ async fn main() -> std::io::Result<()> { HttpServer::new(move || { App::new() .wrap(middleware::NormalizePath::trim()) + // TODO(tlater): When actix-web 4.3 releases, this can be improved a + // lot because of this PR: + // + // https://github.com/actix/actix-web/pull/2784 .wrap( ErrorHandlers::new() .handler(StatusCode::NOT_FOUND, generic_error) -- 2.44.1 From f0f799a6930576afa2ebb53dc2ac5cf25471e2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 16 Sep 2022 17:42:41 +0100 Subject: [PATCH 13/14] template_utils.rs: Add error message when a template can't be found --- src/template_utils.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/template_utils.rs b/src/template_utils.rs index d80b82c..3df4c7c 100644 --- a/src/template_utils.rs +++ b/src/template_utils.rs @@ -1,3 +1,4 @@ +use log::error; use serde::Serialize; use crate::errors::UserError; @@ -12,6 +13,7 @@ pub fn render_template( .render(name, args) .map_err(|_| UserError::InternalError)?) } else { + error!("template not found: {}", name); Err(UserError::NotFound)? } } -- 2.44.1 From 3a5d4b97564c12db1671c107c220832b1cba906a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 16 Sep 2022 17:43:00 +0100 Subject: [PATCH 14/14] flake.nix: Update inputs and fix `nix run` command --- flake.lock | 125 ++++++++++++++++++++--------------------------------- flake.nix | 6 +-- 2 files changed, 50 insertions(+), 81 deletions(-) diff --git a/flake.lock b/flake.lock index ee0c0e3..eb6c162 100644 --- a/flake.lock +++ b/flake.lock @@ -15,21 +15,6 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1631561581, - "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "naersk": { "inputs": { "nixpkgs": [ @@ -37,11 +22,11 @@ ] }, "locked": { - "lastModified": 1659610603, - "narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=", + "lastModified": 1662220400, + "narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=", "owner": "nmattia", "repo": "naersk", - "rev": "c6a45e4277fa58abd524681466d3450f896dc094", + "rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3", "type": "github" }, "original": { @@ -50,28 +35,38 @@ "type": "github" } }, - "naersk_2": { - "inputs": { - "nixpkgs": [ - "tlaternet-templates", - "nixpkgs" - ] - }, + "nix-filter": { "locked": { - "lastModified": 1632266297, - "narHash": "sha256-J1yeJk6Gud9ef2pEf6aKQemrfg1pVngYDSh+SAY94xk=", - "owner": "nmattia", - "repo": "naersk", - "rev": "ee7edec50b49ab6d69b06d62f1de554efccb1ccd", + "lastModified": 1661201956, + "narHash": "sha256-RizGJH/buaw9A2+fiBf9WnXYw4LZABB5kMAZIEE5/T8=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "3b821578685d661a10b563cba30b1861eec05748", "type": "github" }, "original": { - "owner": "nmattia", - "repo": "naersk", + "owner": "numtide", + "repo": "nix-filter", "type": "github" } }, "nixpkgs": { + "locked": { + "lastModified": 1663244735, + "narHash": "sha256-+EukKkeAx6ithOLM1u5x4D12ZFuoi6vpPYjhNDmLz1o=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "178fea1414ae708a5704490f4c49ec3320be9815", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1660318005, "narHash": "sha256-g9WCa9lVUmOV6dYRbEPjv/TLOR5hamjeCcKExVGS3OQ=", @@ -87,19 +82,19 @@ "type": "github" } }, - "nixpkgs_2": { + "npmlock2nix": { + "flake": false, "locked": { - "lastModified": 1632408697, - "narHash": "sha256-JqTfu361AwFmV0WszXLAjfukqGxBbHRopRgdp9A2w8s=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "a13824fe5e38187fbc75cd598b5c06bdcc13501f", + "lastModified": 1654775747, + "narHash": "sha256-9pXHDpIjmsK5390wmpGHu9aA4QOPpegPBvThHeBlef4=", + "owner": "nix-community", + "repo": "npmlock2nix", + "rev": "5c4f247688fc91d665df65f71c81e0726621aaa8", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-20.09", - "repo": "nixpkgs", + "owner": "nix-community", + "repo": "npmlock2nix", "type": "github" } }, @@ -119,36 +114,11 @@ ] }, "locked": { - "lastModified": 1660358625, - "narHash": "sha256-uv+ZtOAEeM5tw78CLdRQmbZyDZYc0piSflthG2kNnrc=", + "lastModified": 1663297375, + "narHash": "sha256-7pjd2x9fSXXynIzp9XiXjbYys7sR6MKCot/jfGL7dgE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "18354cce8137aaef0d505d6f677e9bbdd542020d", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { - "inputs": { - "flake-utils": [ - "tlaternet-templates", - "flake-utils" - ], - "nixpkgs": [ - "tlaternet-templates", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1633400100, - "narHash": "sha256-kHQV7jZ2vVHVI9sfda1mUROVBbQbdfKcbIpKG9WdqGo=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "9c2fc6a62ccbc6f420d71ecac6bf0b84dbbee64f", + "rev": "0678b6187a153eb0baa9688335b002fe14ba6712", "type": "github" }, "original": { @@ -159,23 +129,22 @@ }, "tlaternet-templates": { "inputs": { - "flake-utils": "flake-utils_2", - "naersk": "naersk_2", + "nix-filter": "nix-filter", "nixpkgs": "nixpkgs_2", - "rust-overlay": "rust-overlay_2" + "npmlock2nix": "npmlock2nix" }, "locked": { - "lastModified": 1633433130, - "narHash": "sha256-jkW+HV8cJvE86gppOEXQl2ke+bDHJ7SAp8eJp8pJ0N8=", + "lastModified": 1663345814, + "narHash": "sha256-wIl8P+Hv8zHwBATlEoppPNJMpcR2EiQ4dbkgGXszmf8=", "ref": "master", - "rev": "1232950c06ae16bf17fb16ac1f5f2231e971936b", - "revCount": 16, + "rev": "789431c13cf1e906cbaf48e9b1078056c8ec3cc8", + "revCount": 111, "type": "git", - "url": "https://gitea.tlater.net/tlaternet/tlaternet.git" + "url": "https://gitea.tlater.net/tlaternet/tlaternet-templates.git" }, "original": { "type": "git", - "url": "https://gitea.tlater.net/tlaternet/tlaternet.git" + "url": "https://gitea.tlater.net/tlaternet/tlaternet-templates.git" } } }, diff --git a/flake.nix b/flake.nix index 8e5c476..252b372 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,7 @@ }; tlaternet-templates = { - url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git"; + url = "git+https://gitea.tlater.net/tlaternet/tlaternet-templates.git"; # No need to override anything here; we can save some downloads # if we rely on the webserver to do that. }; @@ -57,8 +57,8 @@ apps.${system} = { run-with-templates = let script = pkgs.writeShellScriptBin "run-with-templates" '' - export ROCKET_TEMPLATE_DIR=${tlaternet-templates.packages.${system}.tlaternet-templates} - ${self.packages.${system}.tlaternet-webserver}/bin/tlaternet-webserver + RUST_LOG=info ${self.packages.${system}.tlaternet-webserver}/bin/tlaternet-webserver \ + --template-directory ${tlaternet-templates.packages.${system}.default} ''; in { type = "app"; -- 2.44.1