From 211c9234541b1208cca078862bf84aaac9e3e839 Mon Sep 17 00:00:00 2001 From: notplants Date: Tue, 2 Nov 2021 17:14:15 +0100 Subject: [PATCH 1/8] Update lib.rs to use rocket 0.5 --- Cargo.lock | 1435 +++++++++++++++++++++++++++++++++--------- peach-web/Cargo.toml | 2 +- peach-web/src/lib.rs | 8 +- 3 files changed, 1133 insertions(+), 312 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c4b07f..30cd7fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,60 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher", -] - -[[package]] -name = "aes-gcm" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher", - "opaque-debug 0.3.0", -] - [[package]] name = "aho-corasick" version = "0.7.15" @@ -89,12 +35,62 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "arrayvec" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "async-stream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", +] + +[[package]] +name = "async-trait" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", +] + +[[package]] +name = "atomic" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" +dependencies = [ + "autocfg 1.0.1", +] + [[package]] name = "atomicwrites" version = "0.2.5" @@ -144,6 +140,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + [[package]] name = "base64" version = "0.9.3" @@ -169,6 +171,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "binascii" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" + [[package]] name = "bitflags" version = "0.3.3" @@ -208,16 +216,7 @@ dependencies = [ "block-padding", "byte-tools", "byteorder", - "generic-array 0.12.4", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -238,6 +237,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "bumpalo" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" + [[package]] name = "byte-tools" version = "0.3.1" @@ -261,6 +266,12 @@ dependencies = [ "iovec", ] +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + [[package]] name = "bytesize" version = "1.1.0" @@ -309,7 +320,7 @@ dependencies = [ "libc", "num-integer", "num-traits 0.2.14", - "time", + "time 0.1.44", "winapi 0.3.9", ] @@ -323,22 +334,13 @@ dependencies = [ "parse-zoneinfo", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.4", -] - [[package]] name = "clap" version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ - "ansi_term", + "ansi_term 0.11.0", "atty", "bitflags 1.3.2", "strsim", @@ -356,6 +358,12 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "const_fn" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" + [[package]] name = "const_format" version = "0.2.17" @@ -382,14 +390,19 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80f6044740a4a516b8aac14c140cdf35c1a640b1bd6b98b6224e49143b2f1566" dependencies = [ - "aes-gcm", - "base64 0.13.0", - "hkdf", - "hmac", "percent-encoding 2.1.0", - "rand 0.8.4", - "sha2", - "time", + "time 0.1.44", +] + +[[package]] +name = "cookie" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" +dependencies = [ + "percent-encoding 2.1.0", + "time 0.2.27", + "version_check 0.9.3", ] [[package]] @@ -408,21 +421,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" -[[package]] -name = "cpufeatures" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" -dependencies = [ - "libc", -] - -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - [[package]] name = "crossbeam-channel" version = "0.3.9" @@ -500,25 +498,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "crypto-mac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" -dependencies = [ - "generic-array 0.14.4", - "subtle", -] - -[[package]] -name = "ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" -dependencies = [ - "cipher", -] - [[package]] name = "ctrlc" version = "3.1.9" @@ -541,8 +520,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74e04ba2d03c5fa0d954c061fc8c9c288badadffc272ebb87679a89846de3ed3" dependencies = [ - "devise_codegen", - "devise_core", + "devise_codegen 0.2.0", + "devise_core 0.2.0", +] + +[[package]] +name = "devise" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c7580b072f1c8476148f16e0a0d5dedddab787da98d86c5082c5e9ed8ab595" +dependencies = [ + "devise_codegen 0.3.1", + "devise_core 0.3.1", ] [[package]] @@ -551,10 +540,20 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "066ceb7928ca93a9bedc6d0e612a8a0424048b0ab1f75971b203d01420c055d7" dependencies = [ - "devise_core", + "devise_core 0.2.0", "quote 0.6.13", ] +[[package]] +name = "devise_codegen" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "123c73e7a6e51b05c75fe1a1b2f4e241399ea5740ed810b0e3e6cacd9db5e7b2" +dependencies = [ + "devise_core 0.3.1", + "quote 1.0.9", +] + [[package]] name = "devise_core" version = "0.2.0" @@ -567,23 +566,33 @@ dependencies = [ "syn 0.15.44", ] +[[package]] +name = "devise_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841ef46f4787d9097405cac4e70fb8644fc037b526e8c14054247c0263c400d0" +dependencies = [ + "bitflags 1.3.2", + "proc-macro2 1.0.28", + "proc-macro2-diagnostics", + "quote 1.0.9", + "syn 1.0.74", +] + [[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.4", + "generic-array", ] [[package]] -name = "digest" -version = "0.9.0" +name = "discard" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.4", -] +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" [[package]] name = "doc-comment" @@ -623,6 +632,15 @@ dependencies = [ "void", ] +[[package]] +name = "encoding_rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "env_logger" version = "0.6.2" @@ -687,6 +705,20 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "figment" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790b4292c72618abbab50f787a477014fe15634f96291de45672ce46afe122df" +dependencies = [ + "atomic", + "pear 0.2.3", + "serde 1.0.127", + "toml 0.5.8", + "uncased", + "version_check 0.9.3", +] + [[package]] name = "filetime" version = "0.2.14" @@ -783,22 +815,129 @@ version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" +[[package]] +name = "futures" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" + [[package]] name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" dependencies = [ - "futures", + "futures 0.1.31", "num_cpus", ] +[[package]] +name = "futures-executor" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" + +[[package]] +name = "futures-macro" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +dependencies = [ + "autocfg 1.0.1", + "proc-macro-hack", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", +] + +[[package]] +name = "futures-sink" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" + +[[package]] +name = "futures-task" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" + +[[package]] +name = "futures-util" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +dependencies = [ + "autocfg 1.0.1", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab 0.4.4", +] + [[package]] name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +[[package]] +name = "generator" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee" +dependencies = [ + "cc", + "libc", + "log 0.4.14", + "rustversion", + "winapi 0.3.9", +] + [[package]] name = "generic-array" version = "0.12.4" @@ -808,16 +947,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check 0.9.3", -] - [[package]] name = "get_if_addrs" version = "0.5.3" @@ -862,16 +991,6 @@ dependencies = [ "wasi 0.10.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 = "gimli" version = "0.24.0" @@ -933,10 +1052,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" dependencies = [ "byteorder", - "bytes", + "bytes 0.4.12", "fnv", - "futures", - "http", + "futures 0.1.31", + "http 0.1.21", "indexmap", "log 0.4.14", "slab 0.4.4", @@ -944,6 +1063,25 @@ dependencies = [ "tokio-io", ] +[[package]] +name = "h2" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +dependencies = [ + "bytes 1.1.0", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.5", + "indexmap", + "slab 0.4.4", + "tokio 1.13.0", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -968,33 +1106,24 @@ 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 = "http" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" dependencies = [ - "bytes", + "bytes 0.4.12", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +dependencies = [ + "bytes 1.1.0", "fnv", "itoa", ] @@ -1005,17 +1134,34 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" dependencies = [ - "bytes", - "futures", - "http", + "bytes 0.4.12", + "futures 0.1.31", + "http 0.1.21", "tokio-buf", ] [[package]] -name = "httparse" -version = "1.4.1" +name = "http-body" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +dependencies = [ + "bytes 1.1.0", + "http 0.2.5", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" + +[[package]] +name = "httpdate" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" [[package]] name = "humansize" @@ -1050,7 +1196,7 @@ dependencies = [ "log 0.3.9", "mime 0.2.6", "num_cpus", - "time", + "time 0.1.44", "traitobject", "typeable", "unicase 1.4.2", @@ -1064,8 +1210,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7" dependencies = [ "base64 0.9.3", - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "futures-cpupool", "httparse", "iovec", @@ -1075,7 +1221,7 @@ dependencies = [ "net2", "percent-encoding 1.0.1", "relay", - "time", + "time 0.1.44", "tokio-core", "tokio-io", "tokio-proto", @@ -1090,20 +1236,20 @@ version = "0.12.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c843caf6296fc1f93444735205af9ed4e109a539005abb2564ae1d6fad34c52" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "futures-cpupool", - "h2", - "http", - "http-body", + "h2 0.1.26", + "http 0.1.21", + "http-body 0.1.0", "httparse", "iovec", "itoa", "log 0.4.14", "net2", "rustc_version 0.2.3", - "time", - "tokio", + "time 0.1.44", + "tokio 0.1.22", "tokio-buf", "tokio-executor", "tokio-io", @@ -1114,6 +1260,30 @@ dependencies = [ "want 0.2.0", ] +[[package]] +name = "hyper" +version = "0.14.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b91bb1f221b6ea1f1e4371216b70f40748774c2fb5971b450c07773fb92d26b" +dependencies = [ + "bytes 1.1.0", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.7", + "http 0.2.5", + "http-body 0.4.4", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio 1.13.0", + "tower-service", + "tracing", + "want 0.3.0", +] + [[package]] name = "i2cdev" version = "0.4.4" @@ -1163,8 +1333,15 @@ checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ "autocfg 1.0.1", "hashbrown", + "serde 1.0.127", ] +[[package]] +name = "inlinable_string" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3094308123a0e9fd59659ce45e22de9f53fc1d2ac6e1feb9fef988e4f76cad77" + [[package]] name = "inotify" version = "0.7.1" @@ -1185,6 +1362,15 @@ 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" @@ -1207,7 +1393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29cb249837420fb0cee7fb0fbf1d22679e121b160e71bb5e0d90b9df241c23e" dependencies = [ "error-chain", - "futures", + "futures 0.1.31", "jsonrpc-core 8.0.1", "log 0.4.14", "serde 1.0.127", @@ -1221,7 +1407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e642eb74423b9dfcb4512fda167148746b76f788a823cd712fadf409f31d302" dependencies = [ "error-chain", - "futures", + "futures 0.1.31", "hyper 0.11.27", "jsonrpc-client-core", "log 0.4.14", @@ -1235,7 +1421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2773fa94a2a1fd51efb89a8f45b8861023dbb415d18d3c9235ae9388d780f9ec" dependencies = [ "failure", - "futures", + "futures 0.1.31", "jsonrpc-core 14.2.0", "jsonrpc-pubsub 14.2.0", "log 0.4.14", @@ -1250,7 +1436,7 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c" dependencies = [ - "futures", + "futures 0.1.31", "log 0.3.9", "serde 1.0.127", "serde_derive", @@ -1263,7 +1449,7 @@ version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b83fdc5e0218128d0d270f2f2e7a5ea716f3240c8518a58bc89e6716ba8581" dependencies = [ - "futures", + "futures 0.1.31", "log 0.4.14", "serde 1.0.127", "serde_derive", @@ -1276,7 +1462,7 @@ version = "14.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0747307121ffb9703afd93afbd0fb4f854c38fb873f2c8b90e0e902f27c7b62" dependencies = [ - "futures", + "futures 0.1.31", "log 0.4.14", "serde 1.0.127", "serde_derive", @@ -1290,7 +1476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c889ca27072f038496a62f38356e8f827acf194d7276030120265362b2974eab" dependencies = [ "failure", - "futures", + "futures 0.1.31", "jsonrpc-core 11.0.0", "log 0.4.14", "serde 1.0.127", @@ -1351,13 +1537,13 @@ version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3372b3248a53abcca8f61924f188052bb0c4cd80b482b2b4eaf9f8667efb9f4" dependencies = [ - "bytes", + "bytes 0.4.12", "globset", "jsonrpc-core 11.0.0", "lazy_static", "log 0.4.14", "num_cpus", - "tokio", + "tokio 0.1.22", "tokio-codec", "unicase 2.6.0", ] @@ -1499,6 +1685,15 @@ dependencies = [ "scopeguard 1.1.0", ] +[[package]] +name = "lock_api" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard 1.1.0", +] + [[package]] name = "log" version = "0.3.9" @@ -1517,12 +1712,36 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "loom" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b9df80a3804094bf49bb29881d18f6f05048db72127e84e09c26fc7c2324f5" +dependencies = [ + "cfg-if 1.0.0", + "generator", + "scoped-tls 1.0.0", + "serde 1.0.127", + "serde_json", + "tracing", + "tracing-subscriber", +] + [[package]] name = "maplit" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.8" @@ -1588,12 +1807,25 @@ dependencies = [ "kernel32-sys", "libc", "log 0.4.14", - "miow", + "miow 0.2.2", "net2", "slab 0.4.4", "winapi 0.2.8", ] +[[package]] +name = "mio" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +dependencies = [ + "libc", + "log 0.4.14", + "miow 0.3.7", + "ntapi", + "winapi 0.3.9", +] + [[package]] name = "mio-extras" version = "2.0.6" @@ -1602,7 +1834,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log 0.4.14", - "mio", + "mio 0.6.23", "slab 0.4.4", ] @@ -1614,7 +1846,7 @@ checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" dependencies = [ "iovec", "libc", - "mio", + "mio 0.6.23", ] [[package]] @@ -1629,12 +1861,41 @@ dependencies = [ "ws2_32-sys", ] +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "mkdirp" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9796ba90f2e7187d7837ea05033ed6dff5320cbf2944fe2dc1da53569396ca07" +[[package]] +name = "multer" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "408327e2999b839cd1af003fc01b2019a6c10a1361769542203f6fedc5179680" +dependencies = [ + "bytes 1.1.0", + "encoding_rs", + "futures-util", + "http 0.2.5", + "httparse", + "log 0.4.14", + "mime 0.3.16", + "spin", + "tokio 1.13.0", + "tokio-util", + "twoway", + "version_check 0.9.3", +] + [[package]] name = "native-tls" version = "0.2.7" @@ -1719,7 +1980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7fd5681d13fda646462cfbd4e5f2051279a89a544d50eb98c365b507246839f" dependencies = [ "bitflags 1.3.2", - "bytes", + "bytes 0.4.12", "cfg-if 0.1.10", "gcc", "libc", @@ -1809,12 +2070,21 @@ dependencies = [ "fsevent-sys", "inotify", "libc", - "mio", + "mio 0.6.23", "mio-extras", "walkdir", "winapi 0.3.9", ] +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1877,12 +2147,6 @@ version = "0.2.3" 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.35" @@ -1966,6 +2230,17 @@ dependencies = [ "parking_lot_core 0.7.2", ] +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api 0.4.5", + "parking_lot_core 0.8.5", +] + [[package]] name = "parking_lot_core" version = "0.4.0" @@ -2008,6 +2283,20 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.2.10", + "smallvec 1.6.1", + "winapi 0.3.9", +] + [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -2192,7 +2481,7 @@ dependencies = [ "peach-lib", "percent-encoding 2.1.0", "regex", - "rocket", + "rocket 0.5.0-rc.1", "rocket_contrib", "serde 1.0.127", "serde_json", @@ -2208,7 +2497,18 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5320f212db967792b67cfe12bd469d08afd6318a249bd917d5c19bc92200ab8a" dependencies = [ - "pear_codegen", + "pear_codegen 0.1.4", +] + +[[package]] +name = "pear" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e44241c5e4c868e3eaa78b7c1848cadd6344ed4f54d029832d32b415a58702" +dependencies = [ + "inlinable_string", + "pear_codegen 0.2.3", + "yansi", ] [[package]] @@ -2224,6 +2524,18 @@ dependencies = [ "yansi", ] +[[package]] +name = "pear_codegen" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a5ca643c2303ecb740d506539deba189e16f2754040a42901cd8105d0282d0" +dependencies = [ + "proc-macro2 1.0.28", + "proc-macro2-diagnostics", + "quote 1.0.9", + "syn 1.0.74", +] + [[package]] name = "percent-encoding" version = "1.0.1" @@ -2279,23 +2591,24 @@ dependencies = [ "sha-1", ] +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" -[[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.10" @@ -2309,7 +2622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f77e66f6d6d898cbbd4a09c48fd3507cfc210b7c83055de02a38b5f7a1e6d216" dependencies = [ "libc", - "time", + "time 0.1.44", ] [[package]] @@ -2319,7 +2632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bb02a28631f195f482c19529ec82bec8e4ffa2d96159e67eb1ae9f5c5c902d8" dependencies = [ "libc", - "time", + "time 0.1.44", ] [[package]] @@ -2346,6 +2659,18 @@ dependencies = [ "version_check 0.9.3", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -2364,6 +2689,19 @@ dependencies = [ "unicode-xid 0.2.2", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", + "version_check 0.9.3", + "yansi", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -2628,6 +2966,26 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "ref-cast" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", +] + [[package]] name = "regex" version = "1.4.6" @@ -2639,6 +2997,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.25" @@ -2651,7 +3018,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" dependencies = [ - "futures", + "futures 0.1.31", ] [[package]] @@ -2674,31 +3041,85 @@ dependencies = [ "log 0.4.14", "memchr", "num_cpus", - "pear", - "rocket_codegen", - "rocket_http", - "state", - "time", + "pear 0.1.4", + "rocket_codegen 0.4.10", + "rocket_http 0.4.10", + "state 0.4.2", + "time 0.1.44", "toml 0.4.10", "version_check 0.9.3", "yansi", ] +[[package]] +name = "rocket" +version = "0.5.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a71c18c42a0eb15bf3816831caf0dad11e7966f2a41aaf486a701979c4dd1f2" +dependencies = [ + "async-stream", + "async-trait", + "atomic", + "atty", + "binascii", + "bytes 1.1.0", + "either", + "figment", + "futures 0.3.17", + "indexmap", + "log 0.4.14", + "memchr", + "multer", + "num_cpus", + "parking_lot 0.11.2", + "pin-project-lite", + "rand 0.8.4", + "ref-cast", + "rocket_codegen 0.5.0-rc.1", + "rocket_http 0.5.0-rc.1", + "serde 1.0.127", + "state 0.5.2", + "tempfile", + "time 0.2.27", + "tokio 1.13.0", + "tokio-stream", + "tokio-util", + "ubyte", + "version_check 0.9.3", + "yansi", +] + [[package]] name = "rocket_codegen" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1729e687d6d2cf434d174da84fb948f7fef4fac22d20ce94ca61c28b72dbcf9f" dependencies = [ - "devise", + "devise 0.2.0", "glob 0.3.0", "indexmap", "quote 0.6.13", - "rocket_http", + "rocket_http 0.4.10", "version_check 0.9.3", "yansi", ] +[[package]] +name = "rocket_codegen" +version = "0.5.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66f5fa462f7eb958bba8710c17c5d774bbbd59809fa76fb1957af7e545aea8bb" +dependencies = [ + "devise 0.3.1", + "glob 0.3.0", + "indexmap", + "proc-macro2 1.0.28", + "quote 1.0.9", + "rocket_http 0.5.0-rc.1", + "syn 1.0.74", + "unicode-xid 0.2.2", +] + [[package]] name = "rocket_contrib" version = "0.4.10" @@ -2708,7 +3129,7 @@ dependencies = [ "glob 0.3.0", "log 0.4.14", "notify", - "rocket", + "rocket 0.4.10", "serde 1.0.127", "serde_json", "tera 0.11.20", @@ -2720,17 +3141,45 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6131e6e6d38a9817f4a494ff5da95971451c2eb56a53915579fc9c80f6ef0117" dependencies = [ - "cookie", + "cookie 0.11.4", "hyper 0.10.16", "indexmap", - "pear", + "pear 0.1.4", "percent-encoding 1.0.1", "smallvec 1.6.1", - "state", - "time", + "state 0.4.2", + "time 0.1.44", "unicode-xid 0.1.0", ] +[[package]] +name = "rocket_http" +version = "0.5.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23c8b7d512d2fcac2316ebe590cde67573844b99e6cc9ee0f53375fa16e25ebd" +dependencies = [ + "cookie 0.15.1", + "either", + "http 0.2.5", + "hyper 0.14.14", + "indexmap", + "log 0.4.14", + "memchr", + "mime 0.3.16", + "parking_lot 0.11.2", + "pear 0.2.3", + "percent-encoding 2.1.0", + "pin-project-lite", + "ref-cast", + "serde 1.0.127", + "smallvec 1.6.1", + "stable-pattern", + "state 0.5.2", + "time 0.2.27", + "tokio 1.13.0", + "uncased", +] + [[package]] name = "rustc-demangle" version = "0.1.20" @@ -2764,6 +3213,12 @@ dependencies = [ "semver 1.0.4", ] +[[package]] +name = "rustversion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" + [[package]] name = "ryu" version = "1.0.5" @@ -2801,6 +3256,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "0.3.3" @@ -2941,23 +3402,34 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", + "block-buffer", + "digest", "fake-simd", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] -name = "sha2" -version = "0.9.5" +name = "sha1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", ] [[package]] @@ -3066,6 +3538,16 @@ dependencies = [ "syn 1.0.74", ] +[[package]] +name = "socket2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "spidev" version = "0.3.0" @@ -3077,6 +3559,12 @@ dependencies = [ "nix 0.6.0", ] +[[package]] +name = "spin" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" + [[package]] name = "ssd1306" version = "0.2.6" @@ -3087,31 +3575,107 @@ dependencies = [ "embedded-hal", ] +[[package]] +name = "stable-pattern" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045" +dependencies = [ + "memchr", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check 0.9.3", +] + [[package]] name = "state" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483" +[[package]] +name = "state" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cf4f5369e6d3044b5e365c9690f451516ac8f0954084622b49ea3fde2f6de5" +dependencies = [ + "loom", +] + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version 0.2.3", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "serde 1.0.127", + "serde_derive", + "syn 1.0.74", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2 1.0.28", + "quote 1.0.9", + "serde 1.0.127", + "serde_derive", + "serde_json", + "sha1", + "syn 1.0.74", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + [[package]] name = "string" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" dependencies = [ - "bytes", + "bytes 0.4.12", ] [[package]] @@ -3144,12 +3708,6 @@ dependencies = [ "syn 1.0.74", ] -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "0.15.44" @@ -3204,7 +3762,7 @@ dependencies = [ "lazy_static", "libc", "nom 6.2.1", - "time", + "time 0.1.44", "winapi 0.3.9", ] @@ -3325,6 +3883,44 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "time" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check 0.9.3", + "winapi 0.3.9", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +dependencies = [ + "proc-macro-hack", + "proc-macro2 1.0.28", + "quote 1.0.9", + "standback", + "syn 1.0.74", +] + [[package]] name = "tinybmp" version = "0.1.1" @@ -3364,9 +3960,9 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" dependencies = [ - "bytes", - "futures", - "mio", + "bytes 0.4.12", + "futures 0.1.31", + "mio 0.6.23", "num_cpus", "tokio-codec", "tokio-current-thread", @@ -3382,15 +3978,34 @@ dependencies = [ "tokio-uds", ] +[[package]] +name = "tokio" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee" +dependencies = [ + "autocfg 1.0.1", + "bytes 1.1.0", + "libc", + "memchr", + "mio 0.7.14", + "num_cpus", + "once_cell", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "winapi 0.3.9", +] + [[package]] name = "tokio-buf" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" dependencies = [ - "bytes", + "bytes 0.4.12", "either", - "futures", + "futures 0.1.31", ] [[package]] @@ -3399,8 +4014,8 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "tokio-io", ] @@ -3410,13 +4025,13 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87b1395334443abca552f63d4f61d0486f12377c2ba8b368e523f89e828cffd4" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "iovec", "log 0.4.14", - "mio", - "scoped-tls", - "tokio", + "mio 0.6.23", + "scoped-tls 0.1.2", + "tokio 0.1.22", "tokio-executor", "tokio-io", "tokio-reactor", @@ -3429,7 +4044,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ - "futures", + "futures 0.1.31", "tokio-executor", ] @@ -3440,7 +4055,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ "crossbeam-utils 0.7.2", - "futures", + "futures 0.1.31", ] [[package]] @@ -3449,7 +4064,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" dependencies = [ - "futures", + "futures 0.1.31", "tokio-io", "tokio-threadpool", ] @@ -3460,18 +4075,29 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "log 0.4.14", ] +[[package]] +name = "tokio-macros" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "114383b041aa6212c579467afa0075fbbdd0718de036100bc0ba7961d8cb9095" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", +] + [[package]] name = "tokio-proto" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" dependencies = [ - "futures", + "futures 0.1.31", "log 0.3.9", "net2", "rand 0.3.23", @@ -3490,10 +4116,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ "crossbeam-utils 0.7.2", - "futures", + "futures 0.1.31", "lazy_static", "log 0.4.14", - "mio", + "mio 0.6.23", "num_cpus", "parking_lot 0.9.0", "slab 0.4.4", @@ -3508,7 +4134,18 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" dependencies = [ - "futures", + "futures 0.1.31", +] + +[[package]] +name = "tokio-stream" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio 1.13.0", ] [[package]] @@ -3518,7 +4155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ "fnv", - "futures", + "futures 0.1.31", ] [[package]] @@ -3527,10 +4164,10 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "iovec", - "mio", + "mio 0.6.23", "tokio-io", "tokio-reactor", ] @@ -3544,7 +4181,7 @@ dependencies = [ "crossbeam-deque", "crossbeam-queue", "crossbeam-utils 0.7.2", - "futures", + "futures 0.1.31", "lazy_static", "log 0.4.14", "num_cpus", @@ -3559,7 +4196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ "crossbeam-utils 0.7.2", - "futures", + "futures 0.1.31", "slab 0.4.4", "tokio-executor", ] @@ -3570,7 +4207,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" dependencies = [ - "futures", + "futures 0.1.31", "native-tls", "tokio-io", ] @@ -3581,10 +4218,10 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "log 0.4.14", - "mio", + "mio 0.6.23", "tokio-codec", "tokio-io", "tokio-reactor", @@ -3596,18 +4233,32 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "iovec", "libc", "log 0.4.14", - "mio", + "mio 0.6.23", "mio-uds", "tokio-codec", "tokio-io", "tokio-reactor", ] +[[package]] +name = "tokio-util" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +dependencies = [ + "bytes 1.1.0", + "futures-core", + "futures-sink", + "log 0.4.14", + "pin-project-lite", + "tokio 1.13.0", +] + [[package]] name = "toml" version = "0.4.10" @@ -3627,6 +4278,87 @@ dependencies = [ "serde 1.0.127", ] +[[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.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", +] + +[[package]] +name = "tracing-core" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log 0.4.14", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +dependencies = [ + "serde 1.0.127", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term 0.12.1", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde 1.0.127", + "serde_json", + "sharded-slab", + "smallvec 1.6.1", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "traitobject" version = "0.1.0" @@ -3645,6 +4377,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "twoway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" +dependencies = [ + "memchr", + "unchecked-index", +] + [[package]] name = "typeable" version = "0.1.2" @@ -3657,12 +4399,37 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +[[package]] +name = "ubyte" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42756bb9e708855de2f8a98195643dff31a97f0485d90d8467b39dc24be9e8fe" +dependencies = [ + "serde 1.0.127", +] + [[package]] name = "ucd-trie" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +[[package]] +name = "uncased" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baeed7327e25054889b9bd4f975f32e5f4c5d434042d59ab6cd4142c0a76ed0" +dependencies = [ + "serde 1.0.127", + "version_check 0.9.3", +] + +[[package]] +name = "unchecked-index" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" + [[package]] name = "unic-char-property" version = "0.7.0" @@ -3823,16 +4590,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" -[[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.4", - "subtle", -] - [[package]] name = "url" version = "1.7.2" @@ -3891,7 +4648,7 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" dependencies = [ - "futures", + "futures 0.1.31", "log 0.4.14", "try-lock 0.1.0", ] @@ -3902,7 +4659,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" dependencies = [ - "futures", + "futures 0.1.31", + "log 0.4.14", + "try-lock 0.2.3", +] + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ "log 0.4.14", "try-lock 0.2.3", ] @@ -3919,14 +4686,68 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasm-bindgen" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +dependencies = [ + "bumpalo", + "lazy_static", + "log 0.4.14", + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +dependencies = [ + "quote 1.0.9", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +dependencies = [ + "proc-macro2 1.0.28", + "quote 1.0.9", + "syn 1.0.74", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" + [[package]] name = "websocket" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "723abe6b75286edc51d8ecabb38a2353f62a9e9b0588998b59111474f1dcd637" dependencies = [ - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "hyper 0.10.16", "native-tls", "rand 0.6.5", @@ -3949,8 +4770,8 @@ dependencies = [ "base64 0.10.1", "bitflags 1.3.2", "byteorder", - "bytes", - "futures", + "bytes 0.4.12", + "futures 0.1.31", "native-tls", "rand 0.6.5", "sha-1", @@ -4021,10 +4842,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec91ea61b83ce033c43c06c52ddc7532f465c0153281610d44c58b74083aee1a" dependencies = [ "byteorder", - "bytes", + "bytes 0.4.12", "httparse", "log 0.4.14", - "mio", + "mio 0.6.23", "mio-extras", "rand 0.6.5", "sha-1", diff --git a/peach-web/Cargo.toml b/peach-web/Cargo.toml index 9cf3abc..6e725c5 100644 --- a/peach-web/Cargo.toml +++ b/peach-web/Cargo.toml @@ -40,7 +40,7 @@ log = "0.4" nest = "1.0.0" peach-lib = { path = "../peach-lib" } percent-encoding = "2.1.0" -rocket = "0.4.6" +rocket = "0.5.0-rc.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" snafu = "0.6" diff --git a/peach-web/src/lib.rs b/peach-web/src/lib.rs index a6e4cf0..ed32b7a 100644 --- a/peach-web/src/lib.rs +++ b/peach-web/src/lib.rs @@ -39,7 +39,7 @@ use std::{env, thread}; use log::{debug, error, info}; -use rocket::{catchers, routes}; +use rocket::{catchers, routes, Rocket, Build}; use rocket_contrib::templates::Template; use crate::routes::authentication::*; @@ -57,8 +57,8 @@ use crate::ws::*; pub type BoxError = Box; // create rocket instance & mount web & json routes (makes testing easier) -fn rocket() -> rocket::Rocket { - rocket::ignite() +fn rocket() -> Rocket { + rocket::build() .mount( "/", routes![ @@ -128,7 +128,7 @@ fn rocket() -> rocket::Rocket { reset_password_form_endpoint, // JSON API ], ) - .register(catchers![not_found, internal_error]) + .register("/", catchers![not_found, internal_error]) .attach(Template::fairing()) } -- 2.40.1 From 346b6c30c48ad21bb00839eef805bf725dcc7b01 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 3 Nov 2021 15:08:57 +0100 Subject: [PATCH 2/8] Use rocket::serde::json instead of rocket_contrib::json --- peach-web/src/routes/authentication.rs | 11 ++--- peach-web/src/routes/device.rs | 11 ++--- peach-web/src/routes/ping.rs | 19 ++++---- peach-web/src/routes/settings/dns.rs | 7 +-- peach-web/src/routes/settings/network.rs | 57 ++++++++++++------------ 5 files changed, 55 insertions(+), 50 deletions(-) diff --git a/peach-web/src/routes/authentication.rs b/peach-web/src/routes/authentication.rs index 7a90b3c..e1b7dab 100644 --- a/peach-web/src/routes/authentication.rs +++ b/peach-web/src/routes/authentication.rs @@ -9,7 +9,8 @@ use rocket::serde::{Deserialize, Serialize}; use peach_lib::password_utils; use crate::error::PeachWebError; -use crate::utils::{build_json_response, JsonResponse}; +use crate::utils::build_json_response; +use rocket::serde::json::Value; // HELPERS AND ROUTES FOR /login @@ -185,12 +186,12 @@ pub fn reset_password_form_endpoint( Ok(_) => { let status = "success".to_string(); let msg = "New password is now saved. Return home to login.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(err) => { let status = "error".to_string(); let msg = format!("{}", err); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -337,12 +338,12 @@ pub fn save_password_form_endpoint(password_form: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "Your password was successfully changed".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(err) => { let status = "error".to_string(); let msg = format!("{}", err); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/device.rs b/peach-web/src/routes/device.rs index e63a3bb..1494721 100644 --- a/peach-web/src/routes/device.rs +++ b/peach-web/src/routes/device.rs @@ -16,7 +16,8 @@ use peach_lib::config_manager::load_peach_config; use peach_lib::stats_client::{CpuStatPercentages, DiskUsage, LoadAverage, MemStat}; use peach_lib::{dyndns_client, network_client, oled_client, sbot_client, stats_client}; -use crate::utils::{build_json_response, JsonResponse}; +use crate::utils::build_json_response; +use rocket::serde::json::Value; // HELPERS AND ROUTES FOR /device @@ -195,13 +196,13 @@ pub fn reboot_device() -> Value { debug!("Going down for reboot..."); let status = "success".to_string(); let msg = "Going down for reboot.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("Reboot failed"); let status = "error".to_string(); let msg = "Failed to reboot the device.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -233,13 +234,13 @@ pub fn shutdown_device() -> Value { debug!("Going down for shutdown..."); let status = "success".to_string(); let msg = "Going down for shutdown.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("Shutdown failed"); let status = "error".to_string(); let msg = "Failed to shutdown the device.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/ping.rs b/peach-web/src/routes/ping.rs index 3ea66ca..2cd2393 100644 --- a/peach-web/src/routes/ping.rs +++ b/peach-web/src/routes/ping.rs @@ -8,7 +8,8 @@ use peach_lib::network_client; use peach_lib::oled_client; use peach_lib::stats_client; -use crate::utils::{build_json_response, JsonResponse}; +use crate::utils::build_json_response; +use rocket::serde::json::Value; /// Status route: useful for checking connectivity from web client. #[get("/api/v1/ping")] @@ -16,7 +17,7 @@ pub fn ping_pong() -> Value { // ping pong let status = "success".to_string(); let msg = "pong!".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } /// Test route: useful for ad hoc testing. @@ -25,7 +26,7 @@ pub fn test_route() -> Value { let val = is_dns_updater_online().unwrap(); let status = "success".to_string(); let msg = val.to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } /// Status route: check availability of `peach-network` microservice. @@ -36,13 +37,13 @@ pub fn ping_network() -> Value { debug!("peach-network responded successfully"); let status = "success".to_string(); let msg = "peach-network is available.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("peach-network failed to respond"); let status = "error".to_string(); let msg = "peach-network is unavailable.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -55,13 +56,13 @@ pub fn ping_oled() -> Value { debug!("peach-oled responded successfully"); let status = "success".to_string(); let msg = "peach-oled is available.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("peach-oled failed to respond"); let status = "error".to_string(); let msg = "peach-oled is unavailable.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -74,13 +75,13 @@ pub fn ping_stats() -> Value { debug!("peach-stats responded successfully"); let status = "success".to_string(); let msg = "peach-stats is available.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("peach-stats failed to respond"); let status = "error".to_string(); let msg = "peach-stats is unavailable.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/settings/dns.rs b/peach-web/src/routes/settings/dns.rs index db4a9f9..ab73b66 100644 --- a/peach-web/src/routes/settings/dns.rs +++ b/peach-web/src/routes/settings/dns.rs @@ -19,7 +19,8 @@ use peach_lib::jsonrpc_client_core::{Error, ErrorKind}; use peach_lib::jsonrpc_core::types::error::ErrorCode; use crate::error::PeachWebError; -use crate::utils::{build_json_response, JsonResponse}; +use crate::utils::build_json_response; +use rocket::serde::json::Value; #[derive(Debug, Deserialize, FromForm)] pub struct DnsForm { @@ -157,12 +158,12 @@ pub fn save_dns_configuration_endpoint(dns_form: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "New dynamic dns configuration is now enabled".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(err) => { let status = "error".to_string(); let msg = format!("{}", err); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/settings/network.rs b/peach-web/src/routes/settings/network.rs index af0412d..a515903 100644 --- a/peach-web/src/routes/settings/network.rs +++ b/peach-web/src/routes/settings/network.rs @@ -19,7 +19,8 @@ use peach_lib::stats_client::Traffic; use crate::utils::monitor; use crate::utils::monitor::{Alert, Data, Threshold}; -use crate::utils::{build_json_response, JsonResponse}; +use crate::utils::build_json_response; +use rocket::serde::json::Value; // STRUCTS USED BY NETWORK ROUTES @@ -766,13 +767,13 @@ pub fn update_wifi_alerts(thresholds: Json) -> Value { debug!("WiFi data usage thresholds updated."); let status = "success".to_string(); let msg = "Updated alert threshold and flags.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("Failed to update WiFi data usage thresholds."); let status = "error".to_string(); let msg = "Failed to update WiFi data usage thresholds.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -796,13 +797,13 @@ pub fn reset_data_total() -> Value { let data = json!(current_traffic); let status = "success".to_string(); let msg = "Reset network data usage total.".to_string(); - Json(build_json_response(status, Some(data), Some(msg))) + build_json_responses(status, Some(data), Some(msg)) } Err(_) => { warn!("Failed to reset network data usage total."); let status = "error".to_string(); let msg = "Failed to reset network data usage total.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -816,12 +817,12 @@ pub fn activate_ap() -> Value { match network_client::activate_ap() { Ok(_) => { let status = "success".to_string(); - Json(build_json_response(status, None, None)) + build_json_response(status, None, None) } Err(_) => { let status = "error".to_string(); let msg = "Failed to activate WiFi access point.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -835,12 +836,12 @@ pub fn activate_client() -> Value { match network_client::activate_client() { Ok(_) => { let status = "success".to_string(); - Json(build_json_response(status, None, None)) + build_json_response(status, None, None) } Err(_) => { let status = "error".to_string(); let msg = "Failed to activate WiFi client mode.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -859,14 +860,14 @@ pub fn add_wifi(wifi: Json) -> Value { // json response for successful update let status = "success".to_string(); let msg = "WiFi credentials added.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { debug!("Failed to add WiFi credentials."); // json response for failed update let status = "error".to_string(); let msg = "Failed to add WiFi credentials.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -880,18 +881,18 @@ pub fn connect_ap(ssid: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "Connected to chosen network.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { let status = "error".to_string(); let msg = "Failed to connect to chosen network.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } }, Err(_) => { let status = "error".to_string(); let msg = "Failed to retrieve the network ID.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -903,12 +904,12 @@ pub fn disconnect_ap(ssid: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "Disconnected from WiFi network.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { let status = "error".to_string(); let msg = "Failed to disconnect from WiFi network.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -921,13 +922,13 @@ pub fn forget_ap(network: Json) -> Value { debug!("Removed WiFi credentials for chosen network."); let status = "success".to_string(); let msg = "WiFi network credentials removed.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("Failed to remove WiFi credentials."); let status = "error".to_string(); let msg = "Failed to remove WiFi network credentials.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -944,13 +945,13 @@ pub fn modify_password(wifi: Json) -> Value { debug!("WiFi password updated for chosen network."); let status = "success".to_string(); let msg = "WiFi password updated.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } Err(_) => { warn!("Failed to update WiFi password."); let status = "error".to_string(); let msg = "Failed to update WiFi password.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -974,7 +975,7 @@ pub fn return_ip() -> Value { "ap0": ap_ip }); let status = "success".to_string(); - Json(build_json_response(status, Some(data), None)) + build_json_response(status, Some(data), None) } #[get("/api/v1/network/rssi")] @@ -984,12 +985,12 @@ pub fn return_rssi() -> Value { Ok(rssi) => { let status = "success".to_string(); let data = json!(rssi); - Json(build_json_response(status, Some(data), None)) + build_json_response(status, Some(data), None) } Err(_) => { let status = "success".to_string(); let msg = "Not currently connected to an access point.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -1001,12 +1002,12 @@ pub fn return_ssid() -> Value { Ok(network) => { let status = "success".to_string(); let data = json!(network); - Json(build_json_response(status, Some(data), None)) + build_json_response(status, Some(data), None) } Err(_) => { let status = "success".to_string(); let msg = "Not currently connected to an access point.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } @@ -1028,7 +1029,7 @@ pub fn return_state() -> Value { "ap0": ap_state }); let status = "success".to_string(); - Json(build_json_response(status, Some(data), None)) + build_json_response(status, Some(data), None) } #[get("/api/v1/network/status")] @@ -1038,12 +1039,12 @@ pub fn return_status() -> Value { Ok(network) => { let status = "success".to_string(); let data = json!(network); - Json(build_json_response(status, Some(data), None)) + build_json_response(status, Some(data), None) } Err(_) => { let status = "success".to_string(); let msg = "Not currently connected to an access point.".to_string(); - Json(build_json_response(status, None, Some(msg))) + build_json_responses(status, None, Some(msg)) } } } -- 2.40.1 From b654d913ad74923efea8fbc05b0b6cb3f06fff5f Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 4 Nov 2021 12:03:40 +0100 Subject: [PATCH 3/8] Use rocket_dyn_templates --- Cargo.lock | 313 +++++------------------ peach-web/Cargo.toml | 12 +- peach-web/src/lib.rs | 2 +- peach-web/src/routes/authentication.rs | 26 +- peach-web/src/routes/device.rs | 18 +- peach-web/src/routes/helpers.rs | 2 +- peach-web/src/routes/index.rs | 6 +- peach-web/src/routes/ping.rs | 19 +- peach-web/src/routes/scuttlebutt.rs | 14 +- peach-web/src/routes/settings/admin.rs | 10 +- peach-web/src/routes/settings/dns.rs | 10 +- peach-web/src/routes/settings/network.rs | 72 +++--- 12 files changed, 161 insertions(+), 343 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a177bd4..0393175 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -159,12 +159,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - [[package]] name = "binascii" version = "0.1.4" @@ -384,16 +378,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "cookie" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f6044740a4a516b8aac14c140cdf35c1a640b1bd6b98b6224e49143b2f1566" -dependencies = [ - "percent-encoding 2.1.0", - "time 0.1.44", -] - [[package]] name = "cookie" version = "0.15.1" @@ -527,34 +511,14 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" -[[package]] -name = "devise" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e04ba2d03c5fa0d954c061fc8c9c288badadffc272ebb87679a89846de3ed3" -dependencies = [ - "devise_codegen 0.2.0", - "devise_core 0.2.0", -] - [[package]] name = "devise" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50c7580b072f1c8476148f16e0a0d5dedddab787da98d86c5082c5e9ed8ab595" dependencies = [ - "devise_codegen 0.3.1", - "devise_core 0.3.1", -] - -[[package]] -name = "devise_codegen" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "066ceb7928ca93a9bedc6d0e612a8a0424048b0ab1f75971b203d01420c055d7" -dependencies = [ - "devise_core 0.2.0", - "quote 0.6.13", + "devise_codegen", + "devise_core", ] [[package]] @@ -563,22 +527,10 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "123c73e7a6e51b05c75fe1a1b2f4e241399ea5740ed810b0e3e6cacd9db5e7b2" dependencies = [ - "devise_core 0.3.1", + "devise_core", "quote 1.0.10", ] -[[package]] -name = "devise_core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf41c59b22b5e3ec0ea55c7847e5f358d340f3a8d6d53a5cf4f1564967f96487" -dependencies = [ - "bitflags 1.3.2", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - [[package]] name = "devise_core" version = "0.3.1" @@ -758,9 +710,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "790b4292c72618abbab50f787a477014fe15634f96291de45672ce46afe122df" dependencies = [ "atomic", - "pear 0.2.3", + "pear", "serde 1.0.130", - "toml 0.5.8", + "toml", "uncased", "version_check 0.9.3", ] @@ -1039,12 +991,6 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" -[[package]] -name = "glob" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" - [[package]] name = "glob" version = "0.3.0" @@ -1124,6 +1070,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "handlebars" +version = "3.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3" +dependencies = [ + "log 0.4.14", + "pest", + "pest_derive", + "quick-error 2.0.1", + "serde 1.0.130", + "serde_json", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -1217,7 +1177,7 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" dependencies = [ - "quick-error", + "quick-error 1.2.3", ] [[package]] @@ -2115,7 +2075,7 @@ dependencies = [ "serde_json", "serde_yaml", "snafu 0.2.3", - "toml 0.5.8", + "toml", ] [[package]] @@ -2227,6 +2187,15 @@ dependencies = [ "version_check 0.9.3", ] +[[package]] +name = "normpath" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "640c20e9df4a2d4a5adad5b47e17d76dac3e824346b181931c3ec9f7a85687b1" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "notify" version = "4.0.17" @@ -2651,25 +2620,16 @@ dependencies = [ "peach-lib", "percent-encoding 2.1.0", "regex", - "rocket 0.5.0-rc.1", - "rocket_contrib", + "rocket", + "rocket_dyn_templates", "serde 1.0.130", "serde_json", "snafu 0.6.10", - "tera 1.15.0", + "tera", "websocket", "xdg", ] -[[package]] -name = "pear" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5320f212db967792b67cfe12bd469d08afd6318a249bd917d5c19bc92200ab8a" -dependencies = [ - "pear_codegen 0.1.4", -] - [[package]] name = "pear" version = "0.2.3" @@ -2677,20 +2637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e44241c5e4c868e3eaa78b7c1848cadd6344ed4f54d029832d32b415a58702" dependencies = [ "inlinable_string", - "pear_codegen 0.2.3", - "yansi", -] - -[[package]] -name = "pear_codegen" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc1c836fdc3d1ef87c348b237b5b5c4dff922156fb2d968f57734f9669768ca" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", - "version_check 0.9.3", + "pear_codegen", "yansi", ] @@ -2917,6 +2864,12 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quote" version = "0.6.13" @@ -3243,27 +3196,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rocket" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a7ab1dfdc75bb8bd2be381f37796b1b300c45a3c9145b34d86715e8dd90bf28" -dependencies = [ - "atty", - "base64 0.13.0", - "log 0.4.14", - "memchr", - "num_cpus", - "pear 0.1.4", - "rocket_codegen 0.4.10", - "rocket_http 0.4.10", - "state 0.4.2", - "time 0.1.44", - "toml 0.4.10", - "version_check 0.9.3", - "yansi", -] - [[package]] name = "rocket" version = "0.5.0-rc.1" @@ -3288,11 +3220,11 @@ dependencies = [ "pin-project-lite", "rand 0.8.4", "ref-cast", - "rocket_codegen 0.5.0-rc.1", - "rocket_http 0.5.0-rc.1", + "rocket_codegen", + "rocket_http", "serde 1.0.130", "serde_json", - "state 0.5.2", + "state", "tempfile", "time 0.2.27", "tokio 1.13.0", @@ -3303,67 +3235,36 @@ dependencies = [ "yansi", ] -[[package]] -name = "rocket_codegen" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1729e687d6d2cf434d174da84fb948f7fef4fac22d20ce94ca61c28b72dbcf9f" -dependencies = [ - "devise 0.2.0", - "glob 0.3.0", - "indexmap", - "quote 0.6.13", - "rocket_http 0.4.10", - "version_check 0.9.3", - "yansi", -] - [[package]] name = "rocket_codegen" version = "0.5.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66f5fa462f7eb958bba8710c17c5d774bbbd59809fa76fb1957af7e545aea8bb" dependencies = [ - "devise 0.3.1", - "glob 0.3.0", + "devise", + "glob", "indexmap", "proc-macro2 1.0.32", "quote 1.0.10", - "rocket_http 0.5.0-rc.1", + "rocket_http", "syn 1.0.81", "unicode-xid 0.2.2", ] [[package]] -name = "rocket_contrib" -version = "0.4.10" +name = "rocket_dyn_templates" +version = "0.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b6303dccab46dce6c7ac26c9b9d8d8cde1b19614b027c3f913be6611bff6d9b" +checksum = "c83f1287ad8fa034410928297a91db37518d5c46d7cc7e1e1b4a77aec0cd8807" dependencies = [ - "glob 0.3.0", - "log 0.4.14", + "glob", + "handlebars", + "normpath", "notify", - "rocket 0.4.10", + "rocket", "serde 1.0.130", "serde_json", - "tera 0.11.20", -] - -[[package]] -name = "rocket_http" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6131e6e6d38a9817f4a494ff5da95971451c2eb56a53915579fc9c80f6ef0117" -dependencies = [ - "cookie 0.11.4", - "hyper 0.10.16", - "indexmap", - "pear 0.1.4", - "percent-encoding 1.0.1", - "smallvec 1.7.0", - "state 0.4.2", - "time 0.1.44", - "unicode-xid 0.1.0", + "tera", ] [[package]] @@ -3372,7 +3273,7 @@ version = "0.5.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23c8b7d512d2fcac2316ebe590cde67573844b99e6cc9ee0f53375fa16e25ebd" dependencies = [ - "cookie 0.15.1", + "cookie", "either", "http 0.2.5", "hyper 0.14.14", @@ -3381,14 +3282,14 @@ dependencies = [ "memchr", "mime 0.3.16", "parking_lot 0.11.2", - "pear 0.2.3", + "pear", "percent-encoding 2.1.0", "pin-project-lite", "ref-cast", "serde 1.0.130", "smallvec 1.7.0", "stable-pattern", - "state 0.5.2", + "state", "time 0.2.27", "tokio 1.13.0", "uncased", @@ -3846,12 +3747,6 @@ dependencies = [ "version_check 0.9.3", ] -[[package]] -name = "state" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483" - [[package]] name = "state" version = "0.5.2" @@ -4036,27 +3931,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "tera" -version = "0.11.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" -dependencies = [ - "chrono", - "error-chain", - "glob 0.2.11", - "humansize", - "lazy_static", - "pest", - "pest_derive", - "regex", - "serde 1.0.130", - "serde_json", - "slug", - "unic-segment 0.7.0", - "url", -] - [[package]] name = "tera" version = "1.15.0" @@ -4076,7 +3950,7 @@ dependencies = [ "serde 1.0.130", "serde_json", "slug", - "unic-segment 0.9.0", + "unic-segment", ] [[package]] @@ -4502,15 +4376,6 @@ dependencies = [ "tokio 1.13.0", ] -[[package]] -name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -dependencies = [ - "serde 1.0.130", -] - [[package]] name = "toml" version = "0.5.8" @@ -4673,75 +4538,34 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" -[[package]] -name = "unic-char-property" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36d3f7ce754afdbccccf8ff0dd0134e50fb44aaae579f96218856e9e5dbd1e" -dependencies = [ - "unic-char-range 0.7.0", -] - [[package]] name = "unic-char-property" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" dependencies = [ - "unic-char-range 0.9.0", + "unic-char-range", ] -[[package]] -name = "unic-char-range" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9ab85fab42ad1b26cafc03bf891f69cb4d6e15f491030e89a0122197baa8ae8" - [[package]] name = "unic-char-range" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" -[[package]] -name = "unic-common" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8d4a7ade929ef7d971e16ced21a8cd56a63869aa6032dfb8cb083cf7d077bf" - [[package]] name = "unic-common" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" -[[package]] -name = "unic-segment" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ca47cbb09fb5fcd066b5867d11dc528302fa465277882797d6a836e1ee6f9e" -dependencies = [ - "unic-ucd-segment 0.7.0", -] - [[package]] name = "unic-segment" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" dependencies = [ - "unic-ucd-segment 0.9.0", -] - -[[package]] -name = "unic-ucd-segment" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f1a08ce0409a9e391b88d1930118eec48af12742fc538bcec55f775865776e" -dependencies = [ - "unic-char-property 0.7.0", - "unic-char-range 0.7.0", - "unic-ucd-version 0.7.0", + "unic-ucd-segment", ] [[package]] @@ -4750,18 +4574,9 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" dependencies = [ - "unic-char-property 0.9.0", - "unic-char-range 0.9.0", - "unic-ucd-version 0.9.0", -] - -[[package]] -name = "unic-ucd-version" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1f5e6c6c53c2d0ece4a5964bc55fcff8602153063cb4fab20958ff32998ff6" -dependencies = [ - "unic-common 0.7.0", + "unic-char-property", + "unic-char-range", + "unic-ucd-version", ] [[package]] @@ -4770,7 +4585,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" dependencies = [ - "unic-common 0.9.0", + "unic-common", ] [[package]] diff --git a/peach-web/Cargo.toml b/peach-web/Cargo.toml index fef4ac9..7d3a766 100644 --- a/peach-web/Cargo.toml +++ b/peach-web/Cargo.toml @@ -50,7 +50,11 @@ regex = "1" xdg = "2.2.0" openssl = { version = "0.10", features = ["vendored"] } -[dependencies.rocket_contrib] -version = "0.4.10" -default-features = false -features = ["tera_templates"] +#[dependencies.rocket_contrib] +#version = "0.4.10" +#default-features = false +#features = ["tera_templates"] + +[dependencies.rocket_dyn_templates] +version = "0.1.0-rc.1" +features = ["handlebars", "tera"] diff --git a/peach-web/src/lib.rs b/peach-web/src/lib.rs index a2928a0..eff8c14 100644 --- a/peach-web/src/lib.rs +++ b/peach-web/src/lib.rs @@ -37,7 +37,7 @@ use std::{env, thread}; use log::{debug, error, info}; use rocket::{catchers, routes, Rocket, Build}; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use crate::routes::authentication::*; use crate::routes::device::*; diff --git a/peach-web/src/routes/authentication.rs b/peach-web/src/routes/authentication.rs index e1b7dab..9f8d367 100644 --- a/peach-web/src/routes/authentication.rs +++ b/peach-web/src/routes/authentication.rs @@ -3,7 +3,7 @@ use rocket::request::{FlashMessage, Form, FromForm}; use rocket::response::{Flash, Redirect}; use rocket::{get, post}; use rocket::serde::json::Json; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use rocket::serde::{Deserialize, Serialize}; use peach_lib::password_utils; @@ -41,8 +41,8 @@ pub fn login(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("login", &context) } @@ -140,8 +140,8 @@ pub fn reset_password(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("password/reset_password", &context) } @@ -186,12 +186,12 @@ pub fn reset_password_form_endpoint( Ok(_) => { let status = "success".to_string(); let msg = "New password is now saved. Return home to login.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(err) => { let status = "error".to_string(); let msg = format!("{}", err); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -226,8 +226,8 @@ pub fn send_password_reset_page(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("password/send_password_reset", &context) } @@ -297,8 +297,8 @@ pub fn change_password(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("password/change_password", &context) } @@ -338,12 +338,12 @@ pub fn save_password_form_endpoint(password_form: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "Your password was successfully changed".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(err) => { let status = "error".to_string(); let msg = format!("{}", err); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/device.rs b/peach-web/src/routes/device.rs index 1494721..248779c 100644 --- a/peach-web/src/routes/device.rs +++ b/peach-web/src/routes/device.rs @@ -5,7 +5,7 @@ use rocket::{ response::{Flash, Redirect}, }; use rocket::serde::json::Json; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use serde::Serialize; use std::{ io, @@ -158,8 +158,8 @@ pub fn device_stats(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("device", &context) @@ -196,13 +196,13 @@ pub fn reboot_device() -> Value { debug!("Going down for reboot..."); let status = "success".to_string(); let msg = "Going down for reboot.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("Reboot failed"); let status = "error".to_string(); let msg = "Failed to reboot the device.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -234,13 +234,13 @@ pub fn shutdown_device() -> Value { debug!("Going down for shutdown..."); let status = "success".to_string(); let msg = "Going down for shutdown.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("Shutdown failed"); let status = "error".to_string(); let msg = "Failed to shutdown the device.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -274,8 +274,8 @@ pub fn shutdown_menu(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("shutdown", &context) } diff --git a/peach-web/src/routes/helpers.rs b/peach-web/src/routes/helpers.rs index 11fa1b2..da5786a 100644 --- a/peach-web/src/routes/helpers.rs +++ b/peach-web/src/routes/helpers.rs @@ -1,6 +1,6 @@ use log::debug; use rocket::{catch, get, response::NamedFile}; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use serde::Serialize; use std::path::{Path, PathBuf}; diff --git a/peach-web/src/routes/index.rs b/peach-web/src/routes/index.rs index 5d57d2d..4a89487 100644 --- a/peach-web/src/routes/index.rs +++ b/peach-web/src/routes/index.rs @@ -1,5 +1,5 @@ use rocket::{get, request::FlashMessage}; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use serde::Serialize; // HELPERS AND ROUTES FOR / (HOME PAGE) @@ -60,8 +60,8 @@ pub fn help(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("help", &context) } diff --git a/peach-web/src/routes/ping.rs b/peach-web/src/routes/ping.rs index 2cd2393..8abe470 100644 --- a/peach-web/src/routes/ping.rs +++ b/peach-web/src/routes/ping.rs @@ -1,7 +1,7 @@ //! Helper routes for pinging services to check that they are active use log::{debug, warn}; use rocket::get; -use rocket_contrib::json::Json; +use rocket::serde::json::{Value, Json}; use peach_lib::dyndns_client::is_dns_updater_online; use peach_lib::network_client; @@ -9,7 +9,6 @@ use peach_lib::oled_client; use peach_lib::stats_client; use crate::utils::build_json_response; -use rocket::serde::json::Value; /// Status route: useful for checking connectivity from web client. #[get("/api/v1/ping")] @@ -17,7 +16,7 @@ pub fn ping_pong() -> Value { // ping pong let status = "success".to_string(); let msg = "pong!".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } /// Test route: useful for ad hoc testing. @@ -26,7 +25,7 @@ pub fn test_route() -> Value { let val = is_dns_updater_online().unwrap(); let status = "success".to_string(); let msg = val.to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } /// Status route: check availability of `peach-network` microservice. @@ -37,13 +36,13 @@ pub fn ping_network() -> Value { debug!("peach-network responded successfully"); let status = "success".to_string(); let msg = "peach-network is available.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("peach-network failed to respond"); let status = "error".to_string(); let msg = "peach-network is unavailable.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -56,13 +55,13 @@ pub fn ping_oled() -> Value { debug!("peach-oled responded successfully"); let status = "success".to_string(); let msg = "peach-oled is available.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("peach-oled failed to respond"); let status = "error".to_string(); let msg = "peach-oled is unavailable.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -75,13 +74,13 @@ pub fn ping_stats() -> Value { debug!("peach-stats responded successfully"); let status = "success".to_string(); let msg = "peach-stats is available.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("peach-stats failed to respond"); let status = "error".to_string(); let msg = "peach-stats is unavailable.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/scuttlebutt.rs b/peach-web/src/routes/scuttlebutt.rs index a68095c..9a705a8 100644 --- a/peach-web/src/routes/scuttlebutt.rs +++ b/peach-web/src/routes/scuttlebutt.rs @@ -1,7 +1,7 @@ //! Routes for ScuttleButt related functionality. use rocket::{get, request::FlashMessage}; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use serde::Serialize; // HELPERS AND ROUTES FOR /messages @@ -33,8 +33,8 @@ pub fn messages(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("messages", &context) } @@ -68,8 +68,8 @@ pub fn peers(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("peers", &context) } @@ -103,8 +103,8 @@ pub fn profile(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("profile", &context) } diff --git a/peach-web/src/routes/settings/admin.rs b/peach-web/src/routes/settings/admin.rs index b3c1fad..cf02564 100644 --- a/peach-web/src/routes/settings/admin.rs +++ b/peach-web/src/routes/settings/admin.rs @@ -4,7 +4,7 @@ use rocket::{ response::{Flash, Redirect}, uri, }; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use rocket::serde::{Deserialize, Serialize}; use peach_lib::config_manager; @@ -47,8 +47,8 @@ pub fn configure_admin(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("admin/configure_admin", &context) } @@ -93,8 +93,8 @@ pub fn add_admin(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("admin/add_admin", &context) diff --git a/peach-web/src/routes/settings/dns.rs b/peach-web/src/routes/settings/dns.rs index ab73b66..b7ff5f0 100644 --- a/peach-web/src/routes/settings/dns.rs +++ b/peach-web/src/routes/settings/dns.rs @@ -4,7 +4,7 @@ use rocket::{ request::{FlashMessage, Form, FromForm}, }; use rocket::serde::json::Json; -use rocket_contrib::templates::Template; +use rocket_dyn_templates::Template; use rocket::serde::{Deserialize, Serialize}; use peach_lib::config_manager; @@ -120,8 +120,8 @@ pub fn configure_dns(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; Template::render("configure_dns", &context) } @@ -158,12 +158,12 @@ pub fn save_dns_configuration_endpoint(dns_form: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "New dynamic dns configuration is now enabled".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(err) => { let status = "error".to_string(); let msg = format!("{}", err); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } diff --git a/peach-web/src/routes/settings/network.rs b/peach-web/src/routes/settings/network.rs index a515903..3462313 100644 --- a/peach-web/src/routes/settings/network.rs +++ b/peach-web/src/routes/settings/network.rs @@ -9,7 +9,7 @@ use rocket::{ uri, UriDisplayQuery, }; use rocket::serde::json::{json, Json}; -use rocket_contrib::{templates::Template}; +use rocket_dyn_templates::Template; use rocket::serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -99,8 +99,8 @@ pub fn wifi_password(ssid: &RawStr, flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_modify", &context) @@ -285,8 +285,8 @@ pub fn network_home(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_card", &context) @@ -385,8 +385,8 @@ pub fn wifi_list(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_list", &context) @@ -553,8 +553,8 @@ pub fn network_detail(ssid: &RawStr, flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_detail", &context) @@ -583,8 +583,8 @@ pub fn network_add_wifi(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_add", &context) @@ -623,8 +623,8 @@ pub fn network_add_ssid(ssid: &RawStr, flash: Option) -> Template // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_add", &context) @@ -733,8 +733,8 @@ pub fn wifi_usage(flash: Option) -> Template { // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object - context.flash_name = Some(flash.name().to_string()); - context.flash_msg = Some(flash.msg().to_string()); + context.flash_name = Some(flash.kind().to_string()); + context.flash_msg = Some(flash.message().to_string()); }; // template_dir is set in Rocket.toml Template::render("network_usage", &context) @@ -767,13 +767,13 @@ pub fn update_wifi_alerts(thresholds: Json) -> Value { debug!("WiFi data usage thresholds updated."); let status = "success".to_string(); let msg = "Updated alert threshold and flags.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("Failed to update WiFi data usage thresholds."); let status = "error".to_string(); let msg = "Failed to update WiFi data usage thresholds.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -797,13 +797,13 @@ pub fn reset_data_total() -> Value { let data = json!(current_traffic); let status = "success".to_string(); let msg = "Reset network data usage total.".to_string(); - build_json_responses(status, Some(data), Some(msg)) + build_json_response(status, Some(data), Some(msg)) } Err(_) => { warn!("Failed to reset network data usage total."); let status = "error".to_string(); let msg = "Failed to reset network data usage total.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -822,7 +822,7 @@ pub fn activate_ap() -> Value { Err(_) => { let status = "error".to_string(); let msg = "Failed to activate WiFi access point.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -841,7 +841,7 @@ pub fn activate_client() -> Value { Err(_) => { let status = "error".to_string(); let msg = "Failed to activate WiFi client mode.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -860,14 +860,14 @@ pub fn add_wifi(wifi: Json) -> Value { // json response for successful update let status = "success".to_string(); let msg = "WiFi credentials added.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { debug!("Failed to add WiFi credentials."); // json response for failed update let status = "error".to_string(); let msg = "Failed to add WiFi credentials.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -881,18 +881,18 @@ pub fn connect_ap(ssid: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "Connected to chosen network.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { let status = "error".to_string(); let msg = "Failed to connect to chosen network.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } }, Err(_) => { let status = "error".to_string(); let msg = "Failed to retrieve the network ID.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -904,12 +904,12 @@ pub fn disconnect_ap(ssid: Json) -> Value { Ok(_) => { let status = "success".to_string(); let msg = "Disconnected from WiFi network.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { let status = "error".to_string(); let msg = "Failed to disconnect from WiFi network.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -922,13 +922,13 @@ pub fn forget_ap(network: Json) -> Value { debug!("Removed WiFi credentials for chosen network."); let status = "success".to_string(); let msg = "WiFi network credentials removed.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("Failed to remove WiFi credentials."); let status = "error".to_string(); let msg = "Failed to remove WiFi network credentials.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -945,13 +945,13 @@ pub fn modify_password(wifi: Json) -> Value { debug!("WiFi password updated for chosen network."); let status = "success".to_string(); let msg = "WiFi password updated.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } Err(_) => { warn!("Failed to update WiFi password."); let status = "error".to_string(); let msg = "Failed to update WiFi password.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -990,7 +990,7 @@ pub fn return_rssi() -> Value { Err(_) => { let status = "success".to_string(); let msg = "Not currently connected to an access point.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -1007,7 +1007,7 @@ pub fn return_ssid() -> Value { Err(_) => { let status = "success".to_string(); let msg = "Not currently connected to an access point.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } @@ -1044,13 +1044,13 @@ pub fn return_status() -> Value { Err(_) => { let status = "success".to_string(); let msg = "Not currently connected to an access point.".to_string(); - build_json_responses(status, None, Some(msg)) + build_json_response(status, None, Some(msg)) } } } #[get("/api/v1/network/wifi")] -pub fn scan_networks() -> JsonResponse { +pub fn scan_networks() -> Value { // retrieve scan results for access-points within range of wlan0 match network_client::available_networks("wlan0") { Ok(networks) => { -- 2.40.1 From b0cdd1ba5c464573ee3b7e358e8ff855545628e6 Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 4 Nov 2021 14:10:41 +0100 Subject: [PATCH 4/8] Upgrade to 0.5 complete --- peach-web/src/lib.rs | 150 ----------------------- peach-web/src/main.rs | 148 ++++++++++++++++++++-- peach-web/src/routes/authentication.rs | 3 +- peach-web/src/routes/helpers.rs | 8 +- peach-web/src/routes/settings/admin.rs | 3 +- peach-web/src/routes/settings/dns.rs | 3 +- peach-web/src/routes/settings/network.rs | 25 ++-- peach-web/src/utils/monitor.rs | 2 +- 8 files changed, 157 insertions(+), 185 deletions(-) delete mode 100644 peach-web/src/lib.rs diff --git a/peach-web/src/lib.rs b/peach-web/src/lib.rs deleted file mode 100644 index eff8c14..0000000 --- a/peach-web/src/lib.rs +++ /dev/null @@ -1,150 +0,0 @@ -//! # peach-web -//! -//! `peach-web` provides a web interface for monitoring and interacting with the -//! PeachCloud device. This allows administration of the single-board computer -//! (ie. Raspberry Pi) running PeachCloud, as well as the ssb-server and related -//! plugins. -//! -//! ## Design -//! -//! `peach-web` is written primarily in Rust and presents a web interface for -//! interacting with the device. The stack currently consists of Rocket (Rust -//! web framework), Tera (Rust template engine inspired by Jinja2 and the Django -//! template language), HTML, CSS and JavaScript. Additional functionality is -//! provided by JSON-RPC clients for the `peach-network` and `peach-stats` -//! microservices. -//! -//! HTML is rendered server-side. Request handlers call JSON-RPC microservices -//! and serve HTML and assets. A JSON API is exposed for remote calls and -//! dynamic client-side content updates via vanilla JavaScript following -//! unobstructive design principles. A basic Websockets server is included, -//! though is not currently utilised. Each Tera template is passed a context -//! object. In the case of Rust, this object is a `struct` and must implement -//! `Serialize`. The fields of the context object are available in the context -//! of the template to be rendered. - -#![feature(proc_macro_hygiene, decl_macro)] - -pub mod error; -pub mod routes; -#[cfg(test)] -mod tests; -pub mod utils; -mod ws; - -use std::{env, thread}; - -use log::{debug, error, info}; - -use rocket::{catchers, routes, Rocket, Build}; -use rocket_dyn_templates::Template; - -use crate::routes::authentication::*; -use crate::routes::device::*; -use crate::routes::helpers::*; -use crate::routes::index::*; -use crate::routes::ping::*; -use crate::routes::scuttlebutt::*; - -use crate::routes::settings::admin::*; -use crate::routes::settings::dns::*; -use crate::routes::settings::network::*; -use crate::ws::*; - -pub type BoxError = Box; - -// create rocket instance & mount web & json routes (makes testing easier) -fn rocket() -> Rocket { - rocket::build() - .mount( - "/", - routes![ - add_credentials, // WEB ROUTE - connect_wifi, // WEB ROUTE - disconnect_wifi, // WEB ROUTE - deploy_ap, // WEB ROUTE - deploy_client, // WEB ROUTE - device_stats, // WEB ROUTE - files, // WEB ROUTE - forget_wifi, // WEB ROUTE - help, // WEB ROUTE - index, // WEB ROUTE - login, // WEB ROUTE - logout, // WEB ROUTE - messages, // WEB ROUTE - network_home, // WEB ROUTE - network_add_ssid, // WEB ROUTE - network_add_wifi, // WEB ROUTE - network_detail, // WEB ROUTE - peers, // WEB ROUTE - profile, // WEB ROUTE - reboot_cmd, // WEB ROUTE - shutdown_cmd, // WEB ROUTE - shutdown_menu, // WEB ROUTE - wifi_list, // WEB ROUTE - wifi_password, // WEB ROUTE - wifi_set_password, // WEB ROUTE - wifi_usage, // WEB ROUTE - wifi_usage_alerts, // WEB ROUTE - wifi_usage_reset, // WEB ROUTE - configure_dns, // WEB ROUTE - configure_dns_post, // WEB ROUTE - change_password, // WEB ROUTE - reset_password, // WEB ROUTE - reset_password_post, // WEB ROUTE - send_password_reset_page, // WEB ROUTE - send_password_reset_post, // WEB ROUTE - configure_admin, // WEB ROUTE - add_admin, // WEB ROUTE - add_admin_post, // WEB ROUTE - delete_admin_post, // WEB ROUTE - activate_ap, // JSON API - activate_client, // JSON API - add_wifi, // JSON API - connect_ap, // JSON API - disconnect_ap, // JSON API - forget_ap, // JSON API - modify_password, // JSON API - ping_pong, // JSON API - test_route, // JSON API - ping_network, // JSON API - ping_oled, // JSON API - ping_stats, // JSON API - reset_data_total, // JSON API - return_ip, // JSON API - return_rssi, // JSON API - return_ssid, // JSON API - return_state, // JSON API - return_status, // JSON API - reboot_device, // JSON API - scan_networks, // JSON API - shutdown_device, // JSON API - update_wifi_alerts, // JSON API - save_dns_configuration_endpoint, // JSON API - save_password_form_endpoint, // JSON API - reset_password_form_endpoint, // JSON API - ], - ) - .register("/", catchers![not_found, internal_error]) - .attach(Template::fairing()) -} - -// launch the rocket server -pub fn run() -> Result<(), BoxError> { - info!("Starting up."); - - // spawn a separate thread for rocket to prevent blocking websockets - thread::spawn(|| { - info!("Launching Rocket server."); - rocket().launch(); - }); - - // NOTE: websockets are not currently in use (may be in the future) - let ws_addr = env::var("PEACH_WEB_WS").unwrap_or_else(|_| "0.0.0.0:5115".to_string()); - match websocket_server(ws_addr) { - Ok(_) => debug!("Websocket server terminated without error."), - Err(e) => error!("Error starting the websocket server: {}", e), - }; - - Ok(()) -} diff --git a/peach-web/src/main.rs b/peach-web/src/main.rs index 4588e5d..f52a2f7 100644 --- a/peach-web/src/main.rs +++ b/peach-web/src/main.rs @@ -1,16 +1,144 @@ -//! Initialize the logger and run the application, catching any errors. +//! # peach-web +//! +//! `peach-web` provides a web interface for monitoring and interacting with the +//! PeachCloud device. This allows administration of the single-board computer +//! (ie. Raspberry Pi) running PeachCloud, as well as the ssb-server and related +//! plugins. +//! +//! ## Design +//! +//! `peach-web` is written primarily in Rust and presents a web interface for +//! interacting with the device. The stack currently consists of Rocket (Rust +//! web framework), Tera (Rust template engine inspired by Jinja2 and the Django +//! template language), HTML, CSS and JavaScript. Additional functionality is +//! provided by JSON-RPC clients for the `peach-network` and `peach-stats` +//! microservices. +//! +//! HTML is rendered server-side. Request handlers call JSON-RPC microservices +//! and serve HTML and assets. A JSON API is exposed for remote calls and +//! dynamic client-side content updates via vanilla JavaScript following +//! unobstructive design principles. A basic Websockets server is included, +//! though is not currently utilised. Each Tera template is passed a context +//! object. In the case of Rust, this object is a `struct` and must implement +//! `Serialize`. The fields of the context object are available in the context +//! of the template to be rendered. -use std::process; +#![feature(proc_macro_hygiene, decl_macro)] -use log::error; +pub mod error; +pub mod routes; +#[cfg(test)] +mod tests; +pub mod utils; +mod ws; -fn main() { - // initialize the logger +use std::{env, thread}; +use log::{debug, error, info}; + +use rocket::{catchers, routes, Rocket, Build, fs::FileServer}; +use rocket_dyn_templates::Template; + +use crate::routes::authentication::*; +use crate::routes::device::*; +use crate::routes::helpers::*; +use crate::routes::index::*; +use crate::routes::ping::*; +use crate::routes::scuttlebutt::*; + +use crate::routes::settings::admin::*; +use crate::routes::settings::dns::*; +use crate::routes::settings::network::*; +use crate::ws::*; + +pub type BoxError = Box; + +/// Create rocket instance & mount all routes. +fn init_rocket() -> Rocket { + rocket::build() + .mount( + "/", + routes![ + add_credentials, // WEB ROUTE + connect_wifi, // WEB ROUTE + disconnect_wifi, // WEB ROUTE + deploy_ap, // WEB ROUTE + deploy_client, // WEB ROUTE + device_stats, // WEB ROUTE + forget_wifi, // WEB ROUTE + help, // WEB ROUTE + index, // WEB ROUTE + login, // WEB ROUTE + logout, // WEB ROUTE + messages, // WEB ROUTE + network_home, // WEB ROUTE + network_add_ssid, // WEB ROUTE + network_add_wifi, // WEB ROUTE + network_detail, // WEB ROUTE + peers, // WEB ROUTE + profile, // WEB ROUTE + reboot_cmd, // WEB ROUTE + shutdown_cmd, // WEB ROUTE + shutdown_menu, // WEB ROUTE + wifi_list, // WEB ROUTE + wifi_password, // WEB ROUTE + wifi_set_password, // WEB ROUTE + wifi_usage, // WEB ROUTE + wifi_usage_alerts, // WEB ROUTE + wifi_usage_reset, // WEB ROUTE + configure_dns, // WEB ROUTE + configure_dns_post, // WEB ROUTE + change_password, // WEB ROUTE + reset_password, // WEB ROUTE + reset_password_post, // WEB ROUTE + send_password_reset_page, // WEB ROUTE + send_password_reset_post, // WEB ROUTE + configure_admin, // WEB ROUTE + add_admin, // WEB ROUTE + add_admin_post, // WEB ROUTE + delete_admin_post, // WEB ROUTE + activate_ap, // JSON API + activate_client, // JSON API + add_wifi, // JSON API + connect_ap, // JSON API + disconnect_ap, // JSON API + forget_ap, // JSON API + modify_password, // JSON API + ping_pong, // JSON API + test_route, // JSON API + ping_network, // JSON API + ping_oled, // JSON API + ping_stats, // JSON API + reset_data_total, // JSON API + return_ip, // JSON API + return_rssi, // JSON API + return_ssid, // JSON API + return_state, // JSON API + return_status, // JSON API + reboot_device, // JSON API + scan_networks, // JSON API + shutdown_device, // JSON API + update_wifi_alerts, // JSON API + save_dns_configuration_endpoint, // JSON API + save_password_form_endpoint, // JSON API + reset_password_form_endpoint, // JSON API + ], + ) + .mount("/", FileServer::from("static")) + .register("/", catchers![not_found, internal_error]) + .attach(Template::fairing()) +} + +/// Launch the peach-web rocket server. +#[rocket::main] +async fn main() { + + // initialize logger env_logger::init(); - // handle errors returned from `run` - if let Err(e) = peach_web::run() { - error!("Application error: {}", e); - process::exit(1); - } + // initialize and launch rocket + info!("Initializing Rocket"); + let rocket = init_rocket(); + + info!("Launching Rocket"); + rocket.launch().await; } diff --git a/peach-web/src/routes/authentication.rs b/peach-web/src/routes/authentication.rs index 9f8d367..a82bcba 100644 --- a/peach-web/src/routes/authentication.rs +++ b/peach-web/src/routes/authentication.rs @@ -1,5 +1,6 @@ use log::{debug, info}; -use rocket::request::{FlashMessage, Form, FromForm}; +use rocket::request::{FlashMessage}; +use rocket::form::{Form, FromForm}; use rocket::response::{Flash, Redirect}; use rocket::{get, post}; use rocket::serde::json::Json; diff --git a/peach-web/src/routes/helpers.rs b/peach-web/src/routes/helpers.rs index da5786a..5ef54d7 100644 --- a/peach-web/src/routes/helpers.rs +++ b/peach-web/src/routes/helpers.rs @@ -1,13 +1,7 @@ use log::debug; -use rocket::{catch, get, response::NamedFile}; +use rocket::{catch, get}; use rocket_dyn_templates::Template; use serde::Serialize; -use std::path::{Path, PathBuf}; - -#[get("/", rank = 2)] -pub fn files(file: PathBuf) -> Option { - NamedFile::open(Path::new("static/").join(file)).ok() -} // HELPERS AND ROUTES FOR 404 ERROR diff --git a/peach-web/src/routes/settings/admin.rs b/peach-web/src/routes/settings/admin.rs index cf02564..a688744 100644 --- a/peach-web/src/routes/settings/admin.rs +++ b/peach-web/src/routes/settings/admin.rs @@ -1,6 +1,7 @@ use rocket::{ get, post, - request::{FlashMessage, Form, FromForm}, + request::FlashMessage, + form::{Form, FromForm}, response::{Flash, Redirect}, uri, }; diff --git a/peach-web/src/routes/settings/dns.rs b/peach-web/src/routes/settings/dns.rs index b7ff5f0..6b021a3 100644 --- a/peach-web/src/routes/settings/dns.rs +++ b/peach-web/src/routes/settings/dns.rs @@ -1,7 +1,8 @@ use log::info; use rocket::{ get, post, - request::{FlashMessage, Form, FromForm}, + request::FlashMessage, + form::{Form, FromForm} }; use rocket::serde::json::Json; use rocket_dyn_templates::Template; diff --git a/peach-web/src/routes/settings/network.rs b/peach-web/src/routes/settings/network.rs index 3462313..f63300d 100644 --- a/peach-web/src/routes/settings/network.rs +++ b/peach-web/src/routes/settings/network.rs @@ -2,9 +2,9 @@ use log::{debug, warn}; use percent_encoding::percent_decode; use rocket::{ get, - http::RawStr, post, - request::{FlashMessage, Form, FromForm}, + request::FlashMessage, + form::{Form, FromForm}, response::{Flash, Redirect}, uri, UriDisplayQuery, }; @@ -52,7 +52,7 @@ pub fn wifi_usage_reset() -> Flash { #[post("/network/wifi/connect", data = "")] pub fn connect_wifi(network: Form) -> Flash { let ssid = &network.ssid; - let url = uri!(network_detail: ssid); + let url = uri!(network_detail(ssid = ssid)); match network_client::id("wlan0", ssid) { Ok(id) => match network_client::connect(&id, "wlan0") { Ok(_) => Flash::success(Redirect::to(url), "Connected to chosen network"), @@ -86,14 +86,12 @@ pub fn forget_wifi(network: Form) -> Flash { } #[get("/network/wifi/modify?")] -pub fn wifi_password(ssid: &RawStr, flash: Option) -> Template { - // decode ssid from url - let decoded_ssid = percent_decode(ssid.as_bytes()).decode_utf8().unwrap(); +pub fn wifi_password(ssid: &str, flash: Option) -> Template { let mut context = NetworkAddContext { back: Some("/network/wifi".to_string()), flash_name: None, flash_msg: None, - selected: Some(decoded_ssid.to_string()), + selected: Some(ssid.to_string()), title: Some("Update WiFi Password".to_string()), }; // check to see if there is a flash message to display @@ -110,7 +108,7 @@ pub fn wifi_password(ssid: &RawStr, flash: Option) -> Template { pub fn wifi_set_password(wifi: Form) -> Flash { let ssid = &wifi.ssid; let pass = &wifi.pass; - let url = uri!(network_detail: ssid); + let url = uri!(network_detail(ssid = ssid)); match network_client::update("wlan0", ssid, pass) { Ok(_) => Flash::success(Redirect::to(url), "WiFi password updated".to_string()), Err(_) => Flash::error( @@ -542,14 +540,12 @@ impl NetworkDetailContext { } #[get("/network/wifi?")] -pub fn network_detail(ssid: &RawStr, flash: Option) -> Template { +pub fn network_detail(ssid: &str, flash: Option) -> Template { // assign context through context_builder call let mut context = NetworkDetailContext::build(); context.back = Some("/network/wifi".to_string()); context.title = Some("WiFi Network".to_string()); - // decode ssid from url - let decoded_ssid = percent_decode(ssid.as_bytes()).decode_utf8().unwrap(); - context.selected = Some(decoded_ssid.to_string()); + context.selected = Some(ssid.to_string()); // check to see if there is a flash message to display if let Some(flash) = flash { // add flash message contents to the context object @@ -613,9 +609,10 @@ impl NetworkAddContext { } #[get("/network/wifi/add?")] -pub fn network_add_ssid(ssid: &RawStr, flash: Option) -> Template { +pub fn network_add_ssid(ssid: &str, flash: Option) -> Template { // decode ssid from url - let decoded_ssid = percent_decode(ssid.as_bytes()).decode_utf8().unwrap(); + let decoded_ssid = ssid; +// let decoded_ssid = percent_decode(ssid.as_bytes()).decode_utf8().unwrap(); let mut context = NetworkAddContext::build(); context.back = Some("/network/wifi".to_string()); context.selected = Some(decoded_ssid.to_string()); diff --git a/peach-web/src/utils/monitor.rs b/peach-web/src/utils/monitor.rs index 619ffe3..6b87d15 100644 --- a/peach-web/src/utils/monitor.rs +++ b/peach-web/src/utils/monitor.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; use nest::{Error, Store, Value}; -use rocket::request::FromForm; +use rocket::form::{Form, FromForm}; use rocket::serde::{Deserialize, Serialize}; use serde_json::json; -- 2.40.1 From 64e083f51644e433bac853e5cecf3e259130bf06 Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 4 Nov 2021 22:30:29 +0100 Subject: [PATCH 5/8] Fix tests --- peach-web/src/main.rs | 6 +- peach-web/src/routes/device.rs | 2 +- peach-web/src/routes/helpers.rs | 2 +- peach-web/src/routes/ping.rs | 2 +- peach-web/src/routes/settings/network.rs | 2 +- peach-web/src/tests.rs | 142 +++++++++++------------ peach-web/src/utils.rs | 2 +- peach-web/src/utils/monitor.rs | 2 +- 8 files changed, 80 insertions(+), 80 deletions(-) diff --git a/peach-web/src/main.rs b/peach-web/src/main.rs index f52a2f7..a054e85 100644 --- a/peach-web/src/main.rs +++ b/peach-web/src/main.rs @@ -17,8 +17,7 @@ //! HTML is rendered server-side. Request handlers call JSON-RPC microservices //! and serve HTML and assets. A JSON API is exposed for remote calls and //! dynamic client-side content updates via vanilla JavaScript following -//! unobstructive design principles. A basic Websockets server is included, -//! though is not currently utilised. Each Tera template is passed a context +//! unobstructive design principles. Each Tera template is passed a context //! object. In the case of Rust, this object is a `struct` and must implement //! `Serialize`. The fields of the context object are available in the context //! of the template to be rendered. @@ -135,10 +134,11 @@ async fn main() { // initialize logger env_logger::init(); - // initialize and launch rocket + // initialize rocket info!("Initializing Rocket"); let rocket = init_rocket(); + // launch rocket info!("Launching Rocket"); rocket.launch().await; } diff --git a/peach-web/src/routes/device.rs b/peach-web/src/routes/device.rs index 248779c..73b2aaf 100644 --- a/peach-web/src/routes/device.rs +++ b/peach-web/src/routes/device.rs @@ -4,7 +4,7 @@ use rocket::{ request::FlashMessage, response::{Flash, Redirect}, }; -use rocket::serde::json::Json; + use rocket_dyn_templates::Template; use serde::Serialize; use std::{ diff --git a/peach-web/src/routes/helpers.rs b/peach-web/src/routes/helpers.rs index 5ef54d7..c1fdf6c 100644 --- a/peach-web/src/routes/helpers.rs +++ b/peach-web/src/routes/helpers.rs @@ -1,5 +1,5 @@ use log::debug; -use rocket::{catch, get}; +use rocket::{catch}; use rocket_dyn_templates::Template; use serde::Serialize; diff --git a/peach-web/src/routes/ping.rs b/peach-web/src/routes/ping.rs index 8abe470..a8ffd7c 100644 --- a/peach-web/src/routes/ping.rs +++ b/peach-web/src/routes/ping.rs @@ -1,7 +1,7 @@ //! Helper routes for pinging services to check that they are active use log::{debug, warn}; use rocket::get; -use rocket::serde::json::{Value, Json}; +use rocket::serde::json::{Value}; use peach_lib::dyndns_client::is_dns_updater_online; use peach_lib::network_client; diff --git a/peach-web/src/routes/settings/network.rs b/peach-web/src/routes/settings/network.rs index f63300d..757e13d 100644 --- a/peach-web/src/routes/settings/network.rs +++ b/peach-web/src/routes/settings/network.rs @@ -1,5 +1,5 @@ use log::{debug, warn}; -use percent_encoding::percent_decode; + use rocket::{ get, post, diff --git a/peach-web/src/tests.rs b/peach-web/src/tests.rs index a6402ae..17558c2 100644 --- a/peach-web/src/tests.rs +++ b/peach-web/src/tests.rs @@ -2,23 +2,23 @@ use std::fs::File; use std::io::Read; use rocket::http::{ContentType, Status}; -use rocket::local::Client; -use rocket_contrib::json; +use rocket::local::blocking::Client; +use rocket::serde::json::{json, Json, Value}; use crate::utils::build_json_response; -use super::rocket; +use super::init_rocket; // helper function to test correct retrieval and content of a file fn test_query_file(path: &str, file: T, status: Status) where T: Into>, { - let client = Client::new(rocket()).unwrap(); + let client = Client::tracked(init_rocket()).unwrap(); let mut response = client.get(path).dispatch(); assert_eq!(response.status(), status); - let body_data = response.body().and_then(|body| body.into_bytes()); + let body_data = response.into_bytes(); if let Some(filename) = file.into() { let expected_data = read_file_content(filename); assert!(body_data.map_or(false, |s| s == expected_data)); @@ -39,11 +39,11 @@ fn read_file_content(path: &str) -> Vec { #[test] fn index_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("/peers")); assert!(body.contains("/profile")); assert!(body.contains("/messages")); @@ -54,11 +54,11 @@ fn index_html() { #[test] fn network_card_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/network").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("MODE")); assert!(body.contains("SSID")); assert!(body.contains("IP")); @@ -72,11 +72,11 @@ fn network_card_html() { #[test] fn network_list_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/network/wifi").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("WiFi Networks")); assert!(body.contains("No saved or available networks found.")); } @@ -84,21 +84,21 @@ fn network_list_html() { // TODO: needs further testing once template has been refactored #[test] fn network_detail_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client.get("/network/wifi?ssid=Home").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - //let body = response.body_string().unwrap(); + //let body = response.into_string().unwrap(); //assert!(body.contains("Network not found")); } #[test] fn network_add_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/network/wifi/add").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Add WiFi Network")); assert!(body.contains("SSID")); assert!(body.contains("Password")); @@ -108,11 +108,11 @@ fn network_add_html() { #[test] fn network_add_ssid_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/network/wifi/add?ssid=Home").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Add WiFi Network")); assert!(body.contains("Home")); assert!(body.contains("Password")); @@ -122,11 +122,11 @@ fn network_add_ssid_html() { #[test] fn device_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/device").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Device Status")); assert!(body.contains("Networking")); assert!(body.contains("Display")); @@ -135,71 +135,71 @@ fn device_html() { #[test] fn help_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/help").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Help")); } #[test] fn login_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/login").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Login")); } #[test] fn messages_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/messages").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Private Messages")); } #[test] fn peers_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/peers").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Scuttlebutt Peers")); } #[test] fn profile_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/profile").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Profile")); } #[test] fn shutdown_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/shutdown").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Shutdown Device")); } #[test] fn network_usage_html() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client.get("/network/wifi/usage").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Network Data Usage")); assert!(body.contains("WARNING THRESHOLD")); assert!(body.contains("Update")); @@ -208,7 +208,7 @@ fn network_usage_html() { #[test] fn add_credentials() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client .post("/network/wifi/add") .header(ContentType::Form) @@ -220,7 +220,7 @@ fn add_credentials() { #[test] fn forget_wifi() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client .post("/network/wifi/forget") .header(ContentType::Form) @@ -232,7 +232,7 @@ fn forget_wifi() { #[test] fn modify_password() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client .post("/network/wifi/modify") .header(ContentType::Form) @@ -244,7 +244,7 @@ fn modify_password() { #[test] fn deploy_ap() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client.get("/network/ap/activate").dispatch(); // check for 303 status (redirect) assert_eq!(response.status(), Status::SeeOther); @@ -253,7 +253,7 @@ fn deploy_ap() { #[test] fn deploy_client() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client.get("/network/wifi/activate").dispatch(); // check for 303 status (redirect) assert_eq!(response.status(), Status::SeeOther); @@ -264,7 +264,7 @@ fn deploy_client() { #[test] fn activate_ap() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client .post("/api/v1/network/activate_ap") .header(ContentType::JSON) @@ -275,7 +275,7 @@ fn activate_ap() { #[test] fn activate_client() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let response = client .post("/api/v1/network/activate_client") .header(ContentType::JSON) @@ -286,54 +286,54 @@ fn activate_client() { #[test] fn return_ip() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/network/ip") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("wlan0")); assert!(body.contains("ap0")); } #[test] fn return_rssi() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/network/rssi") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Not currently connected to an access point.")); } #[test] fn return_ssid() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/network/ssid") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Not currently connected to an access point.")); } #[test] fn return_state() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/network/state") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("ap0")); assert!(body.contains("wlan0")); assert!(body.contains("unavailable")); @@ -341,33 +341,33 @@ fn return_state() { #[test] fn return_status() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/network/status") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Not currently connected to an access point.")); } #[test] fn scan_networks() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/network/wifi") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Unable to scan for networks. Interface may be deactivated.")); } #[test] fn add_wifi() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .post("/api/v1/network/wifi") .header(ContentType::JSON) @@ -375,13 +375,13 @@ fn add_wifi() { .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Failed to add WiFi credentials.")); } #[test] fn remove_wifi() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .post("/api/v1/network/wifi/forget") .header(ContentType::JSON) @@ -389,13 +389,13 @@ fn remove_wifi() { .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Failed to remove WiFi network credentials.")); } #[test] fn new_password() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .post("/api/v1/network/wifi/modify") .header(ContentType::JSON) @@ -403,34 +403,34 @@ fn new_password() { .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("Failed to update WiFi password.")); } #[test] fn ping_pong() { - let client = Client::new(rocket()).expect("valid rocket instance"); + let client = Client::tracked(init_rocket()).expect("valid rocket instance"); let mut response = client .get("/api/v1/ping") .header(ContentType::JSON) .dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::JSON)); - let body = response.body_string().unwrap(); + let body = response.into_string().unwrap(); assert!(body.contains("pong!")); } // HELPER FUNCTION TESTS -#[test] -fn test_build_json_response() { - let status = "success".to_string(); - let data = json!("WiFi credentials added.".to_string()); - let json = build_json_response(status, Some(data), None); - assert_eq!(json.status, "success"); - assert_eq!(json.data, Some(json!("WiFi credentials added."))); - assert_eq!(json.msg, None); -} +//#[test] +//fn test_build_json_response() { +// let status = "success".to_string(); +// let data = json!("WiFi credentials added.".to_string()); +// let j:Value = build_json_response(status, Some(data), None); +// assert_eq!(j.status, "success"); +// assert_eq!(j.data, Some(json!("WiFi credentials added."))); +// assert_eq!(j.message, None); +//} // FILE TESTS @@ -471,7 +471,7 @@ fn invalid_path() { #[test] fn invalid_get_request() { - let client = Client::new(rocket()).unwrap(); + let client = Client::tracked(init_rocket()).unwrap(); // try to get a path that doesn't exist let mut res = client @@ -480,7 +480,7 @@ fn invalid_get_request() { .dispatch(); assert_eq!(res.status(), Status::NotFound); - let body = res.body_string().unwrap(); + let body = res.into_string().unwrap(); assert!(body.contains("404: Page Not Found")); assert!(body.contains("No PeachCloud resource exists for this URL.")); } diff --git a/peach-web/src/utils.rs b/peach-web/src/utils.rs index 01c1995..a36963c 100644 --- a/peach-web/src/utils.rs +++ b/peach-web/src/utils.rs @@ -1,6 +1,6 @@ pub mod monitor; -use rocket::serde::json::{Json, Value, json}; +use rocket::serde::json::{Value, json}; use rocket::serde::{Serialize, Deserialize}; // HELPER FUNCTIONS diff --git a/peach-web/src/utils/monitor.rs b/peach-web/src/utils/monitor.rs index 6b87d15..77edcfd 100644 --- a/peach-web/src/utils/monitor.rs +++ b/peach-web/src/utils/monitor.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; use nest::{Error, Store, Value}; -use rocket::form::{Form, FromForm}; +use rocket::form::{FromForm}; use rocket::serde::{Deserialize, Serialize}; use serde_json::json; -- 2.40.1 From 4f6fb170695496b2038f2e799b45789a77cdab8a Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 4 Nov 2021 22:39:40 +0100 Subject: [PATCH 6/8] Fix clippy warnings --- peach-web/src/main.rs | 12 ++++---- peach-web/src/tests.rs | 54 +++++++++++++++++------------------ peach-web/src/ws.rs | 65 ------------------------------------------ 3 files changed, 34 insertions(+), 97 deletions(-) delete mode 100644 peach-web/src/ws.rs diff --git a/peach-web/src/main.rs b/peach-web/src/main.rs index a054e85..ce2785c 100644 --- a/peach-web/src/main.rs +++ b/peach-web/src/main.rs @@ -29,10 +29,9 @@ pub mod routes; #[cfg(test)] mod tests; pub mod utils; -mod ws; -use std::{env, thread}; -use log::{debug, error, info}; +use log::{info, error}; +use std::process; use rocket::{catchers, routes, Rocket, Build, fs::FileServer}; use rocket_dyn_templates::Template; @@ -47,7 +46,7 @@ use crate::routes::scuttlebutt::*; use crate::routes::settings::admin::*; use crate::routes::settings::dns::*; use crate::routes::settings::network::*; -use crate::ws::*; + pub type BoxError = Box; @@ -140,5 +139,8 @@ async fn main() { // launch rocket info!("Launching Rocket"); - rocket.launch().await; + if let Err(e) = rocket.launch().await { + error!("Error in Rocket application: {}", e); + process::exit(1); + } } diff --git a/peach-web/src/tests.rs b/peach-web/src/tests.rs index 17558c2..0dde736 100644 --- a/peach-web/src/tests.rs +++ b/peach-web/src/tests.rs @@ -3,9 +3,9 @@ use std::io::Read; use rocket::http::{ContentType, Status}; use rocket::local::blocking::Client; -use rocket::serde::json::{json, Json, Value}; -use crate::utils::build_json_response; + + use super::init_rocket; @@ -15,7 +15,7 @@ where T: Into>, { let client = Client::tracked(init_rocket()).unwrap(); - let mut response = client.get(path).dispatch(); + let response = client.get(path).dispatch(); assert_eq!(response.status(), status); let body_data = response.into_bytes(); @@ -40,7 +40,7 @@ fn read_file_content(path: &str) -> Vec { #[test] fn index_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/").dispatch(); + let response = client.get("/").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -55,7 +55,7 @@ fn index_html() { #[test] fn network_card_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/network").dispatch(); + let response = client.get("/network").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -73,7 +73,7 @@ fn network_card_html() { #[test] fn network_list_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/network/wifi").dispatch(); + let response = client.get("/network/wifi").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -95,7 +95,7 @@ fn network_detail_html() { #[test] fn network_add_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/network/wifi/add").dispatch(); + let response = client.get("/network/wifi/add").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -109,7 +109,7 @@ fn network_add_html() { #[test] fn network_add_ssid_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/network/wifi/add?ssid=Home").dispatch(); + let response = client.get("/network/wifi/add?ssid=Home").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -123,7 +123,7 @@ fn network_add_ssid_html() { #[test] fn device_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/device").dispatch(); + let response = client.get("/device").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -136,7 +136,7 @@ fn device_html() { #[test] fn help_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/help").dispatch(); + let response = client.get("/help").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -146,7 +146,7 @@ fn help_html() { #[test] fn login_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/login").dispatch(); + let response = client.get("/login").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -156,7 +156,7 @@ fn login_html() { #[test] fn messages_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/messages").dispatch(); + let response = client.get("/messages").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -166,7 +166,7 @@ fn messages_html() { #[test] fn peers_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/peers").dispatch(); + let response = client.get("/peers").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -176,7 +176,7 @@ fn peers_html() { #[test] fn profile_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/profile").dispatch(); + let response = client.get("/profile").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -186,7 +186,7 @@ fn profile_html() { #[test] fn shutdown_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/shutdown").dispatch(); + let response = client.get("/shutdown").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -196,7 +196,7 @@ fn shutdown_html() { #[test] fn network_usage_html() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client.get("/network/wifi/usage").dispatch(); + let response = client.get("/network/wifi/usage").dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.content_type(), Some(ContentType::HTML)); let body = response.into_string().unwrap(); @@ -287,7 +287,7 @@ fn activate_client() { #[test] fn return_ip() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/network/ip") .header(ContentType::JSON) .dispatch(); @@ -301,7 +301,7 @@ fn return_ip() { #[test] fn return_rssi() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/network/rssi") .header(ContentType::JSON) .dispatch(); @@ -314,7 +314,7 @@ fn return_rssi() { #[test] fn return_ssid() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/network/ssid") .header(ContentType::JSON) .dispatch(); @@ -327,7 +327,7 @@ fn return_ssid() { #[test] fn return_state() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/network/state") .header(ContentType::JSON) .dispatch(); @@ -342,7 +342,7 @@ fn return_state() { #[test] fn return_status() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/network/status") .header(ContentType::JSON) .dispatch(); @@ -355,7 +355,7 @@ fn return_status() { #[test] fn scan_networks() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/network/wifi") .header(ContentType::JSON) .dispatch(); @@ -368,7 +368,7 @@ fn scan_networks() { #[test] fn add_wifi() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .post("/api/v1/network/wifi") .header(ContentType::JSON) .body(r#"{ "ssid": "Home", "pass": "Password" }"#) @@ -382,7 +382,7 @@ fn add_wifi() { #[test] fn remove_wifi() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .post("/api/v1/network/wifi/forget") .header(ContentType::JSON) .body(r#"{ "ssid": "Home" }"#) @@ -396,7 +396,7 @@ fn remove_wifi() { #[test] fn new_password() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .post("/api/v1/network/wifi/modify") .header(ContentType::JSON) .body(r#"{ "ssid": "Home", "pass": "Password" }"#) @@ -410,7 +410,7 @@ fn new_password() { #[test] fn ping_pong() { let client = Client::tracked(init_rocket()).expect("valid rocket instance"); - let mut response = client + let response = client .get("/api/v1/ping") .header(ContentType::JSON) .dispatch(); @@ -474,7 +474,7 @@ fn invalid_get_request() { let client = Client::tracked(init_rocket()).unwrap(); // try to get a path that doesn't exist - let mut res = client + let res = client .get("/message/99") .header(ContentType::JSON) .dispatch(); diff --git a/peach-web/src/ws.rs b/peach-web/src/ws.rs deleted file mode 100644 index fb83b89..0000000 --- a/peach-web/src/ws.rs +++ /dev/null @@ -1,65 +0,0 @@ -// NOTE: websockets are not currently in use for PeachCloud but may be in the -// future. - -use std::io; -use std::thread; - -use log::{debug, info}; -use websocket::sync::Server; -use websocket::{Message, OwnedMessage}; - -pub fn websocket_server(address: String) -> io::Result<()> { - // start listening for WebSocket connections - let ws_server = Server::bind(address)?; - - info!("Listening for WebSocket connections."); - for connection in ws_server.filter_map(Result::ok) { - // spawn a new thread for each connection - thread::spawn(move || { - if !connection - .protocols() - .contains(&"rust-websocket".to_string()) - { - connection.reject().unwrap(); - return; - } - - let mut client = connection.use_protocol("rust-websocket").accept().unwrap(); - - let client_ip = client.peer_addr().unwrap(); - - debug!("Websocket connection from {}.", client_ip); - - let msg_text = "Websocket successfully connected.".to_string(); - let message = Message::text(msg_text); - client.send_message(&message).unwrap(); - - let (mut receiver, mut sender) = client.split().unwrap(); - - for message in receiver.incoming_messages() { - let message = message.unwrap(); - - match message { - OwnedMessage::Close(_) => { - debug!("Received close message."); - let message = Message::close(); - sender.send_message(&message).unwrap(); - debug!("Websocket client {} disconnected.", client_ip); - return; - } - OwnedMessage::Ping(data) => { - debug!("Received ping message."); - let message = Message::pong(data); - sender.send_message(&message).unwrap(); - } - _ => { - sender.send_message(&message).unwrap(); - debug!("Received unknown message: {:?}", message); - } - } - } - }); - } - - Ok(()) -} -- 2.40.1 From 4021e17bbf53fe0e059fc8ca538956fe21279ce4 Mon Sep 17 00:00:00 2001 From: notplants Date: Thu, 4 Nov 2021 22:59:46 +0100 Subject: [PATCH 7/8] Comment out failing test --- peach-web/src/tests.rs | 8 ++++++-- peach-web/src/utils.rs | 11 +---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/peach-web/src/tests.rs b/peach-web/src/tests.rs index 0dde736..c9c799e 100644 --- a/peach-web/src/tests.rs +++ b/peach-web/src/tests.rs @@ -1,11 +1,12 @@ use std::fs::File; use std::io::Read; +use log::info; +use rocket::serde::json::{Value, json}; use rocket::http::{ContentType, Status}; use rocket::local::blocking::Client; - - +use crate::utils::build_json_response; use super::init_rocket; @@ -422,6 +423,9 @@ fn ping_pong() { // HELPER FUNCTION TESTS +// TODO: fix this test +// it currently fails with +// error[E0609]: no field `message` on type `JsonValue` //#[test] //fn test_build_json_response() { // let status = "success".to_string(); diff --git a/peach-web/src/utils.rs b/peach-web/src/utils.rs index a36963c..9021338 100644 --- a/peach-web/src/utils.rs +++ b/peach-web/src/utils.rs @@ -1,19 +1,10 @@ pub mod monitor; use rocket::serde::json::{Value, json}; -use rocket::serde::{Serialize, Deserialize}; +use rocket::serde::{Serialize}; // HELPER FUNCTIONS -#[derive(Serialize, Deserialize)] -pub struct JsonResponse { - pub status: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub data: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub msg: Option, -} - pub fn build_json_response( status: String, data: Option, -- 2.40.1 From 1b66ee8d9eca38383d1e0b3dd3100c4c0bc76ce5 Mon Sep 17 00:00:00 2001 From: notplants Date: Fri, 5 Nov 2021 11:44:41 +0100 Subject: [PATCH 8/8] Response to code review --- Cargo.lock | 23 +---------------------- peach-web/Cargo.toml | 7 +------ peach-web/src/main.rs | 1 - peach-web/src/routes/ping.rs | 10 ---------- peach-web/src/routes/settings/network.rs | 5 +---- peach-web/src/tests.rs | 23 ++++++++++------------- 6 files changed, 13 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0393175..8d19591 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1070,20 +1070,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "handlebars" -version = "3.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3" -dependencies = [ - "log 0.4.14", - "pest", - "pest_derive", - "quick-error 2.0.1", - "serde 1.0.130", - "serde_json", -] - [[package]] name = "hashbrown" version = "0.11.2" @@ -1177,7 +1163,7 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" dependencies = [ - "quick-error 1.2.3", + "quick-error", ] [[package]] @@ -2864,12 +2850,6 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -[[package]] -name = "quick-error" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" - [[package]] name = "quote" version = "0.6.13" @@ -3258,7 +3238,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c83f1287ad8fa034410928297a91db37518d5c46d7cc7e1e1b4a77aec0cd8807" dependencies = [ "glob", - "handlebars", "normpath", "notify", "rocket", diff --git a/peach-web/Cargo.toml b/peach-web/Cargo.toml index 7d3a766..979a9ec 100644 --- a/peach-web/Cargo.toml +++ b/peach-web/Cargo.toml @@ -50,11 +50,6 @@ regex = "1" xdg = "2.2.0" openssl = { version = "0.10", features = ["vendored"] } -#[dependencies.rocket_contrib] -#version = "0.4.10" -#default-features = false -#features = ["tera_templates"] - [dependencies.rocket_dyn_templates] version = "0.1.0-rc.1" -features = ["handlebars", "tera"] +features = ["tera"] diff --git a/peach-web/src/main.rs b/peach-web/src/main.rs index ce2785c..cdfcaf5 100644 --- a/peach-web/src/main.rs +++ b/peach-web/src/main.rs @@ -102,7 +102,6 @@ fn init_rocket() -> Rocket { forget_ap, // JSON API modify_password, // JSON API ping_pong, // JSON API - test_route, // JSON API ping_network, // JSON API ping_oled, // JSON API ping_stats, // JSON API diff --git a/peach-web/src/routes/ping.rs b/peach-web/src/routes/ping.rs index a8ffd7c..8e87cd0 100644 --- a/peach-web/src/routes/ping.rs +++ b/peach-web/src/routes/ping.rs @@ -3,7 +3,6 @@ use log::{debug, warn}; use rocket::get; use rocket::serde::json::{Value}; -use peach_lib::dyndns_client::is_dns_updater_online; use peach_lib::network_client; use peach_lib::oled_client; use peach_lib::stats_client; @@ -19,15 +18,6 @@ pub fn ping_pong() -> Value { build_json_response(status, None, Some(msg)) } -/// Test route: useful for ad hoc testing. -#[get("/api/v1/test")] -pub fn test_route() -> Value { - let val = is_dns_updater_online().unwrap(); - let status = "success".to_string(); - let msg = val.to_string(); - build_json_response(status, None, Some(msg)) -} - /// Status route: check availability of `peach-network` microservice. #[get("/api/v1/ping/network")] pub fn ping_network() -> Value { diff --git a/peach-web/src/routes/settings/network.rs b/peach-web/src/routes/settings/network.rs index 757e13d..28fddd8 100644 --- a/peach-web/src/routes/settings/network.rs +++ b/peach-web/src/routes/settings/network.rs @@ -610,12 +610,9 @@ impl NetworkAddContext { #[get("/network/wifi/add?")] pub fn network_add_ssid(ssid: &str, flash: Option) -> Template { - // decode ssid from url - let decoded_ssid = ssid; -// let decoded_ssid = percent_decode(ssid.as_bytes()).decode_utf8().unwrap(); let mut context = NetworkAddContext::build(); context.back = Some("/network/wifi".to_string()); - context.selected = Some(decoded_ssid.to_string()); + context.selected = Some(ssid.to_string()); context.title = Some("Add WiFi Network".to_string()); // check to see if there is a flash message to display if let Some(flash) = flash { diff --git a/peach-web/src/tests.rs b/peach-web/src/tests.rs index c9c799e..0339192 100644 --- a/peach-web/src/tests.rs +++ b/peach-web/src/tests.rs @@ -1,6 +1,5 @@ use std::fs::File; use std::io::Read; -use log::info; use rocket::serde::json::{Value, json}; use rocket::http::{ContentType, Status}; @@ -423,18 +422,16 @@ fn ping_pong() { // HELPER FUNCTION TESTS -// TODO: fix this test -// it currently fails with -// error[E0609]: no field `message` on type `JsonValue` -//#[test] -//fn test_build_json_response() { -// let status = "success".to_string(); -// let data = json!("WiFi credentials added.".to_string()); -// let j:Value = build_json_response(status, Some(data), None); -// assert_eq!(j.status, "success"); -// assert_eq!(j.data, Some(json!("WiFi credentials added."))); -// assert_eq!(j.message, None); -//} +#[test] +fn test_build_json_response() { + let status = "success".to_string(); + let data = json!("WiFi credentials added.".to_string()); + let j: Value = build_json_response(status, Some(data), None); + assert_eq!(j["status"], "success"); + assert_eq!(j["data"], "WiFi credentials added."); + assert_eq!(j["msg"], json!(null)); +} + // FILE TESTS -- 2.40.1