diff --git a/Cargo.lock b/Cargo.lock index 1f5e3f1..7b73382 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ checksum = "3a5da1d857ec9ca65ef8d0469cdd64e7b93b59d6cad26f1444bf84b62f3eadd4" dependencies = [ "chrono", "mime", - "serde 1.0.127", + "serde 1.0.130", "serde_json", "thiserror", "url", @@ -23,7 +23,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb8e19a0810cc25df3535061a08b7d8f8a734d309ea4411c57a9767e4a2ffa0e" dependencies = [ "activitystreams", - "serde 1.0.127", + "serde 1.0.130", "serde_json", ] @@ -45,9 +45,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.0-beta.8" +version = "3.0.0-beta.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd16d6b846983ffabfd081e1a67abd7698094fcbe7b3d9bcf1acbc6f546a516" +checksum = "dd38a862fa7fead2b47ee55e550982aba583ebc7365ccf0155b49934ad6f16f9" dependencies = [ "actix-codec", "actix-rt", @@ -57,12 +57,10 @@ dependencies = [ "ahash", "base64", "bitflags", - "brotli2", "bytes", "bytestring", "derive_more", "encoding_rs", - "flate2", "futures-core", "futures-util", "h2", @@ -79,12 +77,11 @@ dependencies = [ "pin-project-lite", "rand 0.8.4", "regex", - "serde 1.0.127", + "serde 1.0.130", "sha-1", "smallvec", "time 0.2.27", "tokio", - "zstd", ] [[package]] @@ -99,15 +96,16 @@ dependencies = [ [[package]] name = "actix-router" -version = "0.2.7" +version = "0.5.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" +checksum = "36b95ce0d76d1aa2f98b681702807475ade0f99bd4552546a6843a966d42ea3d" dependencies = [ "bytestring", + "firestorm", "http", "log", "regex", - "serde 1.0.127", + "serde 1.0.130", ] [[package]] @@ -180,9 +178,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.0-beta.8" +version = "4.0.0-beta.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c503f726f895e55dac39adeafd14b5ee00cc956796314e9227fc7ae2e176f443" +checksum = "d34aa2b23ec9c7c9a799b3cf9258f67c91b18ac3f0f5f484e175c7ac46739bb5" dependencies = [ "actix-codec", "actix-http", @@ -209,7 +207,7 @@ dependencies = [ "paste", "pin-project", "regex", - "serde 1.0.127", + "serde 1.0.130", "serde_json", "serde_urlencoded", "smallvec", @@ -220,10 +218,11 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "0.5.0-beta.3" +version = "0.5.0-beta.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d048c6986743105c1e8e9729fbc8d5d1667f2f62393a58be8d85a7d9a5a6c8d" +checksum = "4a11fd6f322120a74b23327e778ef0a4950b1f44a2b76468a69316a150f5c6dd" dependencies = [ + "actix-router", "proc-macro2", "quote", "syn", @@ -238,17 +237,11 @@ dependencies = [ "actix-rt", "actix-web", "awc", - "serde 1.0.127", + "serde 1.0.130", "serde_derive", "thiserror", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.7.4" @@ -262,9 +255,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] @@ -294,10 +287,19 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.42" +name = "ansi_term" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" [[package]] name = "arrayvec" @@ -360,9 +362,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "awc" -version = "3.0.0-beta.7" +version = "3.0.0-beta.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364ef81705bf38403a3c3da4fab9eeec1e1503cd72dd6cd7c4259d2a6b08aa98" +checksum = "5b276021b5aa1df71969acc8adc03973e4fc7d00bba0cbb6338e6f8ad0d7a3c2" dependencies = [ "actix-codec", "actix-http", @@ -380,16 +382,15 @@ dependencies = [ "pin-project-lite", "rand 0.8.4", "rustls", - "serde 1.0.127", + "serde 1.0.130", "serde_json", "serde_urlencoded", ] [[package]] name = "background-jobs" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8953ce13a4bc359900fca168b64e47d5f0af1c02f2d45527221babbb73a27" +version = "0.10.0" +source = "git+https://git.asonix.dog/asonix/background-jobs#68a80085dedbe01d2952adfef9c810661e4aa513" dependencies = [ "background-jobs-actix", "background-jobs-core", @@ -397,9 +398,8 @@ dependencies = [ [[package]] name = "background-jobs-actix" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e170bb20c0ca37c8bdd212753a0c51dbe570fcb13dba2d2c819241bc376fb70" +version = "0.10.0" +source = "git+https://git.asonix.dog/asonix/background-jobs#68a80085dedbe01d2952adfef9c810661e4aa513" dependencies = [ "actix-rt", "anyhow", @@ -407,31 +407,32 @@ dependencies = [ "async-trait", "background-jobs-core", "chrono", - "log", "num_cpus", - "serde 1.0.127", + "serde 1.0.130", "serde_json", "thiserror", "tokio", + "tracing", + "tracing-futures", "uuid", ] [[package]] name = "background-jobs-core" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fc10cc1d7bc1cf5695efa5f56e0f9d6906f7863bc14acb03ff8a6fff8b6e95" +version = "0.10.0" +source = "git+https://git.asonix.dog/asonix/background-jobs#68a80085dedbe01d2952adfef9c810661e4aa513" dependencies = [ "actix-rt", "anyhow", "async-mutex", "async-trait", "chrono", - "log", - "serde 1.0.127", + "serde 1.0.130", "serde_json", "thiserror", "tokio", + "tracing", + "tracing-futures", "uuid", ] @@ -449,15 +450,15 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "base64ct" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d27fb6b6f1e43147af148af49d49329413ba781aa0d5e10979831c210173b5" +checksum = "40a96587c05c810ddbb79e2674d519cff1379517e7b91d166dff7a7cc0e9af6e" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" @@ -480,31 +481,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "brotli-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "brotli2" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" -dependencies = [ - "brotli-sys", - "libc", -] - [[package]] name = "bumpalo" -version = "3.7.0" +version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" +checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" [[package]] name = "bytecount" @@ -520,9 +501,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "bytestring" @@ -535,12 +516,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" -dependencies = [ - "jobserver", -] +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" [[package]] name = "cfg-if" @@ -557,7 +535,7 @@ dependencies = [ "libc", "num-integer", "num-traits 0.2.14", - "serde 1.0.127", + "serde 1.0.130", "time 0.1.44", "winapi", ] @@ -568,7 +546,7 @@ 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", "strsim", @@ -586,7 +564,7 @@ dependencies = [ "lazy_static", "nom 5.1.2", "rust-ini", - "serde 1.0.127", + "serde 1.0.130", "serde-hjson", "serde_json", "toml", @@ -595,9 +573,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c32f031ea41b4291d695026c023b95d59db2d8a2c7640800ed56bc8f510f22" +checksum = "fdab415d6744056100f40250a66bc430c1a46f7a02e20bc11c94c79a0f0464df" [[package]] name = "const_fn" @@ -613,9 +591,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cpufeatures" -version = "0.1.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" dependencies = [ "libc", ] @@ -654,9 +632,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.2.2" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b32a398eb1ccfbe7e4f452bc749c44d38dd732e9a253f19da224c416f00ee7f4" +checksum = "51e7ef8604ba15f1ea2cef61e17577e630ee39aef7f94305d138dbf1a216ada3" dependencies = [ "generic-array", "rand_core 0.6.3", @@ -665,9 +643,9 @@ dependencies = [ [[package]] name = "der" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f215f706081a44cb702c71c39a52c05da637822e9c1645a50b7202689e982d" +checksum = "2adca118c71ecd9ae094d4b68257b3fdfcb711a612b9eec7b5a0d27a5a70a5b4" dependencies = [ "const-oid", "crypto-bigint", @@ -722,32 +700,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" -dependencies = [ - "atty", - "humantime 2.1.0", - "log", - "regex", - "termcolor", -] - [[package]] name = "event-listener" version = "2.5.1" @@ -755,16 +707,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] -name = "flate2" -version = "1.0.20" +name = "firestorm" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" -dependencies = [ - "cfg-if", - "crc32fast", - "libc", - "miniz_oxide", -] +checksum = "31586bda1b136406162e381a3185a506cdfc1631708dd40cba2f6628d8634499" [[package]] name = "fnv" @@ -808,59 +754,17 @@ dependencies = [ "new_debug_unreachable", ] -[[package]] -name = "futures" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" -dependencies = [ - "futures-core", - "futures-sink", -] - [[package]] name = "futures-core" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" - -[[package]] -name = "futures-executor" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" [[package]] name = "futures-macro" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" dependencies = [ "autocfg 1.0.1", "proc-macro-hack", @@ -871,30 +775,27 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" [[package]] name = "futures-task" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" [[package]] name = "futures-util" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +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", @@ -945,9 +846,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472" dependencies = [ "bytes", "fnv", @@ -1016,9 +917,8 @@ dependencies = [ [[package]] name = "http-signature-normalization" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3a020c37b48d2258910fae9c9b4f8455651f56abfdde1ae68a9397b2765c31" +version = "0.5.4" +source = "git+https://git.asonix.dog/asonix/http-signature-normalization#11be605f5b7aa3aa1938aaf34a12b0fd905fca50" dependencies = [ "chrono", "thiserror", @@ -1027,40 +927,27 @@ dependencies = [ [[package]] name = "http-signature-normalization-actix" version = "0.5.0-beta.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa7cf7b03512ba7341b4252794751c5ff46635e0ff33eb864a929a5b7381e17a" +source = "git+https://git.asonix.dog/asonix/http-signature-normalization#11be605f5b7aa3aa1938aaf34a12b0fd905fca50" dependencies = [ "actix-web", "awc", "base64", "chrono", - "futures", + "futures-util", "http-signature-normalization", - "log", "sha2", "thiserror", + "tokio", + "tracing", + "tracing-error", + "tracing-futures", ] [[package]] name = "httparse" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "idna" @@ -1103,24 +990,15 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "jobserver" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" -dependencies = [ - "libc", -] +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "js-sys" -version = "0.3.51" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] @@ -1155,9 +1033,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.98" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" [[package]] name = "libm" @@ -1191,9 +1069,9 @@ checksum = "84f9a2d3e27ce99ce2c3aad0b09b1a7b916293ea9b2bf624c13fe646fadd8da4" [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ "scopeguard", ] @@ -1255,10 +1133,19 @@ dependencies = [ ] [[package]] -name = "matches" -version = "0.1.8" +name = "matchers" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "md5" @@ -1268,9 +1155,9 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" @@ -1287,16 +1174,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg 1.0.1", -] - [[package]] name = "mio" version = "0.7.13" @@ -1338,9 +1215,9 @@ dependencies = [ [[package]] name = "nom" -version = "6.2.1" +version = "6.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" dependencies = [ "bitvec", "funty", @@ -1357,7 +1234,7 @@ checksum = "4689294073dda8a54e484212171efdcb6b12b1908fd70c3dc3eec15b8833b06d" dependencies = [ "bytecount", "memchr", - "nom 6.2.1", + "nom 6.1.2", ] [[package]] @@ -1371,9 +1248,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512" +checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535" dependencies = [ "autocfg 1.0.1", "num-integer", @@ -1394,7 +1271,7 @@ dependencies = [ "num-iter", "num-traits 0.2.14", "rand 0.8.4", - "serde 1.0.127", + "serde 1.0.130", "smallvec", "zeroize", ] @@ -1474,9 +1351,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", @@ -1485,9 +1362,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ "cfg-if", "instant", @@ -1505,9 +1382,9 @@ checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" [[package]] name = "pem-rfc7468" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fe90c78c9a17442665a41a1a45dcd24bbab0e1794748edc19b27fffb146c13" +checksum = "e71fb2d401a15271d52aade6d9410fb4ead603a86da5503f92e872e1df790265" dependencies = [ "base64ct", ] @@ -1599,9 +1476,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs1" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "359e7852310174a810f078124edb73c66e88a1a731b2fd586dba34ee32dbe416" +checksum = "116bee8279d783c0cf370efa1a94632f2108e5ef0bb32df31f051647810a4e2c" dependencies = [ "der", "pem-rfc7468", @@ -1610,9 +1487,9 @@ dependencies = [ [[package]] name = "pkcs8" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee84ed13e44dd82689fa18348a49934fa79cc774a344c42fc9b301c71b140a" +checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" dependencies = [ "der", "pem-rfc7468", @@ -1633,16 +1510,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -dependencies = [ - "env_logger 0.7.1", - "log", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1681,19 +1548,13 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.9" @@ -1802,24 +1663,33 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.4.6" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", "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" @@ -1845,23 +1715,26 @@ dependencies = [ "chrono", "config", "dotenv", - "env_logger 0.9.0", - "futures", + "futures-util", "http-signature-normalization-actix", - "log", "lru", "mime", - "pretty_env_logger", "rand 0.8.4", "rsa", "rsa-magic-public-key", "ructe", - "serde 1.0.127", + "serde 1.0.130", "serde_json", "sha2", "sled", "structopt", "thiserror", + "tracing", + "tracing-actix-web", + "tracing-error", + "tracing-futures", + "tracing-log", + "tracing-subscriber", "uuid", ] @@ -1919,7 +1792,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d12b2ef4a0638222476c8ca9cb0a51184647404fe637a088fc0dc06f0c14512d" dependencies = [ "lazy_static", - "nom 6.2.1", + "nom 6.1.2", "nom_locate", "num-bigint", "num-integer", @@ -1939,7 +1812,7 @@ dependencies = [ "itertools", "md5", "mime", - "nom 6.2.1", + "nom 6.1.2", "rsass", ] @@ -2043,9 +1916,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.127" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -2064,9 +1937,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.127" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -2075,13 +1948,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", - "serde 1.0.127", + "serde 1.0.130", ] [[package]] @@ -2093,14 +1966,14 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.127", + "serde 1.0.130", ] [[package]] name = "sha-1" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer", "cfg-if", @@ -2117,9 +1990,9 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", "cfg-if", @@ -2128,6 +2001,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740223c51853f3145fe7c90360d2d4232f2b62e3449489c207eccde818979982" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -2139,21 +2021,21 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729a25c17d72b06c68cb47955d44fda88ad2d3e7d77e025663fdd69b93dd71a1" +checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" [[package]] name = "slab" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" +checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" [[package]] name = "sled" -version = "0.34.6" +version = "0.34.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0132f3e393bcb7390c60bb45769498cf4550bcb7a21d7f95c02b69f6362cdc" +checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" dependencies = [ "crc32fast", "crossbeam-epoch", @@ -2173,9 +2055,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" dependencies = [ "libc", "winapi", @@ -2189,9 +2071,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spki" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987637c5ae6b3121aba9d513f869bd2bff11c4cc086c22473befd6649c0bd521" +checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" dependencies = [ "der", ] @@ -2233,7 +2115,7 @@ checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ "proc-macro2", "quote", - "serde 1.0.127", + "serde 1.0.130", "serde_derive", "syn", ] @@ -2247,7 +2129,7 @@ dependencies = [ "base-x", "proc-macro2", "quote", - "serde 1.0.127", + "serde 1.0.130", "serde_derive", "serde_json", "sha1", @@ -2270,7 +2152,7 @@ dependencies = [ "new_debug_unreachable", "phf_shared", "precomputed-hash", - "serde 1.0.127", + "serde 1.0.130", ] [[package]] @@ -2293,9 +2175,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b041cdcb67226aca307e6e7be44c8806423d83e018bd662360a93dabce4d71" +checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" dependencies = [ "clap", "lazy_static", @@ -2304,9 +2186,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7813934aecf5f51a54775e00068c237de98489463968231a51746bbbc03f9c10" +checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" dependencies = [ "heck", "proc-macro-error", @@ -2323,9 +2205,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.74" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" dependencies = [ "proc-macro2", "quote", @@ -2361,15 +2243,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "termcolor" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -2381,24 +2254,33 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "thread_local" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +dependencies = [ + "once_cell", +] + [[package]] name = "time" version = "0.1.44" @@ -2450,9 +2332,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" +checksum = "5241dd6f21443a3606b432718b166d3cedc962fd4b8bea54a8bc7f514ebda986" dependencies = [ "tinyvec_macros", ] @@ -2465,9 +2347,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.9.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7b349f11a7047e6d1276853e612d152f5e8a352c61917887cc2169e2366b4c" +checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce" dependencies = [ "autocfg 1.0.1", "bytes", @@ -2494,9 +2376,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" dependencies = [ "bytes", "futures-core", @@ -2512,34 +2394,120 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ - "serde 1.0.127", + "serde 1.0.130", ] [[package]] name = "tracing" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8" dependencies = [ "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] [[package]] -name = "tracing-core" -version = "0.1.18" +name = "tracing-actix-web" +version = "0.4.0-beta.12" +source = "git+https://github.com/asonix/tracing-actix-web?branch=asonix/tracing-error-work-around#51e7911af7d1dd6a9c8265fa19b94224ddff56e2" +dependencies = [ + "actix-web", + "tracing", + "tracing-futures", + "uuid", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf" dependencies = [ "lazy_static", ] [[package]] -name = "typenum" -version = "1.13.0" +name = "tracing-error" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "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.130", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c42e73a9d277d4d2b6a88389a137ccf3c58599660b17e8f5fc39305e490669" +dependencies = [ + "ansi_term 0.12.1", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde 1.0.130", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "typenum" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "ucd-trie" @@ -2549,12 +2517,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "unicode-bidi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" -dependencies = [ - "matches", -] +checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085" [[package]] name = "unicode-normalization" @@ -2573,9 +2538,9 @@ checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" @@ -2599,7 +2564,7 @@ dependencies = [ "idna", "matches", "percent-encoding", - "serde 1.0.127", + "serde 1.0.130", ] [[package]] @@ -2615,7 +2580,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ "getrandom 0.2.3", - "serde 1.0.127", + "serde 1.0.130", ] [[package]] @@ -2644,9 +2609,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "wasm-bindgen" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2654,9 +2619,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -2669,9 +2634,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2679,9 +2644,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -2692,15 +2657,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "web-sys" -version = "0.3.51" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -2741,15 +2706,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2803,32 +2759,3 @@ dependencies = [ "syn", "synstructure", ] - -[[package]] -name = "zstd" -version = "0.7.0+zstd.1.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9428752481d8372e15b1bf779ea518a179ad6c771cca2d2c60e4fbff3cc2cd52" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "3.1.0+zstd.1.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa1926623ad7fe406e090555387daf73db555b948134b4d73eac5eb08fb666d" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "1.5.0+zstd.1.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" -dependencies = [ - "cc", - "libc", -] diff --git a/Cargo.toml b/Cargo.toml index af797a5..8aad65b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,26 +15,22 @@ build = "src/build.rs" [dependencies] anyhow = "1.0" actix-rt = "2.0.2" -actix-web = { version = "4.0.0-beta.7", default-features = false, features = ["compress-brotli", "compress-gzip", "compress-zstd"] } +actix-web = { version = "4.0.0-beta.7", default-features = false } actix-webfinger = "0.4.0-beta.3" activitystreams = "0.7.0-alpha.10" activitystreams-ext = "0.1.0-alpha.2" ammonia = "3.1.0" async-mutex = "1.0.1" async-rwlock = "1.3.0" -awc = { version = "3.0.0-beta.6", default-features = false, features = ["compress-brotli", "compress-gzip", "compress-zstd", "rustls"] } -background-jobs = "0.9.0" +awc = { version = "3.0.0-beta.6", default-features = false, features = ["rustls"] } base64 = "0.13" chrono = "0.4.19" config = "0.11.0" dotenv = "0.15.0" -env_logger = "0.9.0" -futures = "0.3.12" -http-signature-normalization-actix = { version = "0.5.0-beta.6", default-features = false, features = ["sha-2"] } -log = "0.4" +futures-util = "0.3.17" +http-signature-normalization-actix = { version = "0.5.0-beta.7", default-features = false, features = ["sha-2"], git = "https://git.asonix.dog/asonix/http-signature-normalization" } lru = "0.6.0" mime = "0.3.16" -pretty_env_logger = "0.4.0" rand = "0.8" rsa = "0.5" rsa-magic-public-key = "0.4.0" @@ -44,8 +40,24 @@ sha2 = "0.9" sled = "0.34.6" structopt = "0.3.12" thiserror = "1.0" +tracing = "0.1" +tracing-actix-web = { version = "0.4.0-beta.12", git = "https://github.com/asonix/tracing-actix-web", branch = "asonix/tracing-error-work-around" } +tracing-error = "0.1" +tracing-futures = "0.2" +tracing-log = "0.1" +tracing-subscriber = { version = "0.2", features = ["ansi", "fmt"] } uuid = { version = "0.8", features = ["v4", "serde"] } +[dependencies.background-jobs] +version = "0.10.0" +git = "https://git.asonix.dog/asonix/background-jobs" +default-features = false +features = [ + "background-jobs-actix", + "error-logging" +] + + [build-dependencies] anyhow = "1.0" dotenv = "0.15.0" diff --git a/src/config.rs b/src/config.rs index d5d5f87..fe91f43 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,6 @@ use crate::{ data::{ActorCache, State}, - error::MyError, + error::Error, middleware::MyVerify, requests::Requests, }; @@ -20,7 +20,6 @@ pub(crate) struct ParsedConfig { restricted_mode: bool, validate_signatures: bool, https: bool, - pretty_log: bool, publish_blocks: bool, sled_path: PathBuf, source_repo: Url, @@ -34,7 +33,6 @@ pub struct Config { debug: bool, restricted_mode: bool, validate_signatures: bool, - pretty_log: bool, publish_blocks: bool, base_uri: Url, sled_path: PathBuf, @@ -55,7 +53,7 @@ pub enum UrlKind { } impl Config { - pub(crate) fn build() -> Result { + pub(crate) fn build() -> Result { let mut config = config::Config::new(); config .set_default("hostname", "localhost:8080")? @@ -65,7 +63,6 @@ impl Config { .set_default("restricted_mode", false)? .set_default("validate_signatures", false)? .set_default("https", false)? - .set_default("pretty_log", true)? .set_default("publish_blocks", false)? .set_default("sled_path", "./sled/db-0-34")? .set_default("source_repo", "https://git.asonix.dog/asonix/relay")? @@ -83,7 +80,6 @@ impl Config { debug: config.debug, restricted_mode: config.restricted_mode, validate_signatures: config.validate_signatures, - pretty_log: config.pretty_log, publish_blocks: config.publish_blocks, base_uri, sled_path: config.sled_path, @@ -95,10 +91,6 @@ impl Config { &self.sled_path } - pub(crate) fn pretty_log(&self) -> bool { - self.pretty_log - } - pub(crate) fn validate_signatures(&self) -> bool { self.validate_signatures } diff --git a/src/data/actor.rs b/src/data/actor.rs index 31cb927..9d32af7 100644 --- a/src/data/actor.rs +++ b/src/data/actor.rs @@ -1,7 +1,7 @@ use crate::{ apub::AcceptedActors, db::{Actor, Db}, - error::MyError, + error::{Error, ErrorKind}, requests::Requests, }; use activitystreams::{prelude::*, url::Url}; @@ -30,7 +30,7 @@ impl MaybeCached { } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct ActorCache { db: Db, } @@ -40,11 +40,12 @@ impl ActorCache { ActorCache { db } } + #[tracing::instrument(name = "Get Actor", skip(requests))] pub(crate) async fn get( &self, id: &Url, requests: &Requests, - ) -> Result, MyError> { + ) -> Result, Error> { if let Some(actor) = self.db.actor(id.clone()).await? { if actor.saved_at + REFETCH_DURATION > SystemTime::now() { return Ok(MaybeCached::Cached(actor)); @@ -56,26 +57,25 @@ impl ActorCache { .map(MaybeCached::Fetched) } - pub(crate) async fn add_connection(&self, actor: Actor) -> Result<(), MyError> { + #[tracing::instrument(name = "Add Connection")] + pub(crate) async fn add_connection(&self, actor: Actor) -> Result<(), Error> { self.db.add_connection(actor.id.clone()).await?; self.db.save_actor(actor).await } - pub(crate) async fn remove_connection(&self, actor: &Actor) -> Result<(), MyError> { + #[tracing::instrument(name = "Remove Connection")] + pub(crate) async fn remove_connection(&self, actor: &Actor) -> Result<(), Error> { self.db.remove_connection(actor.id.clone()).await } - pub(crate) async fn get_no_cache( - &self, - id: &Url, - requests: &Requests, - ) -> Result { + #[tracing::instrument(name = "Fetch remote actor", skip(requests))] + pub(crate) async fn get_no_cache(&self, id: &Url, requests: &Requests) -> Result { let accepted_actor = requests.fetch::(id.as_str()).await?; - let input_domain = id.domain().ok_or(MyError::MissingDomain)?; + let input_domain = id.domain().ok_or(ErrorKind::MissingDomain)?; let accepted_actor_id = accepted_actor .id(&input_domain)? - .ok_or(MyError::MissingId)?; + .ok_or(ErrorKind::MissingId)?; let inbox = get_inbox(&accepted_actor)?.clone(); @@ -93,7 +93,7 @@ impl ActorCache { } } -fn get_inbox(actor: &AcceptedActors) -> Result<&Url, MyError> { +fn get_inbox(actor: &AcceptedActors) -> Result<&Url, Error> { Ok(actor .endpoints()? .and_then(|e| e.shared_inbox) diff --git a/src/data/media.rs b/src/data/media.rs index 66377e2..aa15c19 100644 --- a/src/data/media.rs +++ b/src/data/media.rs @@ -1,6 +1,6 @@ use crate::{ db::{Db, MediaMeta}, - error::MyError, + error::Error, }; use activitystreams::url::Url; use actix_web::web::Bytes; @@ -9,7 +9,7 @@ use uuid::Uuid; static MEDIA_DURATION: Duration = Duration::from_secs(60 * 60 * 24 * 2); -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct MediaCache { db: Db, } @@ -19,15 +19,18 @@ impl MediaCache { MediaCache { db } } - pub(crate) async fn get_uuid(&self, url: Url) -> Result, MyError> { + #[tracing::instrument(name = "Get media uuid")] + pub(crate) async fn get_uuid(&self, url: Url) -> Result, Error> { self.db.media_id(url).await } - pub(crate) async fn get_url(&self, uuid: Uuid) -> Result, MyError> { + #[tracing::instrument(name = "Get media url")] + pub(crate) async fn get_url(&self, uuid: Uuid) -> Result, Error> { self.db.media_url(uuid).await } - pub(crate) async fn is_outdated(&self, uuid: Uuid) -> Result { + #[tracing::instrument(name = "Is media outdated")] + pub(crate) async fn is_outdated(&self, uuid: Uuid) -> Result { if let Some(meta) = self.db.media_meta(uuid).await? { if meta.saved_at + MEDIA_DURATION > SystemTime::now() { return Ok(false); @@ -37,7 +40,8 @@ impl MediaCache { Ok(true) } - pub(crate) async fn get_bytes(&self, uuid: Uuid) -> Result, MyError> { + #[tracing::instrument(name = "Get media bytes")] + pub(crate) async fn get_bytes(&self, uuid: Uuid) -> Result, Error> { if let Some(meta) = self.db.media_meta(uuid).await? { if meta.saved_at + MEDIA_DURATION > SystemTime::now() { return self @@ -51,7 +55,8 @@ impl MediaCache { Ok(None) } - pub(crate) async fn store_url(&self, url: Url) -> Result { + #[tracing::instrument(name = "Store media url")] + pub(crate) async fn store_url(&self, url: Url) -> Result { let uuid = Uuid::new_v4(); self.db.save_url(url, uuid).await?; @@ -59,12 +64,13 @@ impl MediaCache { Ok(uuid) } + #[tracing::instrument(name = "store media bytes", skip(bytes))] pub(crate) async fn store_bytes( &self, uuid: Uuid, media_type: String, bytes: Bytes, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { self.db .save_bytes( uuid, diff --git a/src/data/node.rs b/src/data/node.rs index c9da438..f32434b 100644 --- a/src/data/node.rs +++ b/src/data/node.rs @@ -1,11 +1,11 @@ use crate::{ db::{Contact, Db, Info, Instance}, - error::MyError, + error::Error, }; use activitystreams::url::Url; use std::time::{Duration, SystemTime}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct NodeCache { db: Db, } @@ -23,7 +23,8 @@ impl NodeCache { NodeCache { db } } - pub(crate) async fn nodes(&self) -> Result, MyError> { + #[tracing::instrument(name = "Get nodes")] + pub(crate) async fn nodes(&self) -> Result, Error> { let infos = self.db.connected_info().await?; let instances = self.db.connected_instance().await?; let contacts = self.db.connected_contact().await?; @@ -48,6 +49,7 @@ impl NodeCache { Ok(vec) } + #[tracing::instrument(name = "Is NodeInfo Outdated")] pub(crate) async fn is_nodeinfo_outdated(&self, actor_id: Url) -> bool { self.db .info(actor_id) @@ -56,6 +58,7 @@ impl NodeCache { .unwrap_or(true) } + #[tracing::instrument(name = "Is Contact Outdated")] pub(crate) async fn is_contact_outdated(&self, actor_id: Url) -> bool { self.db .contact(actor_id) @@ -64,6 +67,7 @@ impl NodeCache { .unwrap_or(true) } + #[tracing::instrument(name = "Is Instance Outdated")] pub(crate) async fn is_instance_outdated(&self, actor_id: Url) -> bool { self.db .instance(actor_id) @@ -72,13 +76,14 @@ impl NodeCache { .unwrap_or(true) } + #[tracing::instrument(name = "Save node info")] pub(crate) async fn set_info( &self, actor_id: Url, software: String, version: String, reg: bool, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { self.db .save_info( actor_id, @@ -92,6 +97,7 @@ impl NodeCache { .await } + #[tracing::instrument(name = "Save instance info")] pub(crate) async fn set_instance( &self, actor_id: Url, @@ -100,7 +106,7 @@ impl NodeCache { version: String, reg: bool, requires_approval: bool, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { self.db .save_instance( actor_id, @@ -116,6 +122,7 @@ impl NodeCache { .await } + #[tracing::instrument(name = "Save contact info")] pub(crate) async fn set_contact( &self, actor_id: Url, @@ -123,7 +130,7 @@ impl NodeCache { display_name: String, url: Url, avatar: Url, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { self.db .save_contact( actor_id, diff --git a/src/data/state.rs b/src/data/state.rs index 6a8a4f6..d3c1d5b 100644 --- a/src/data/state.rs +++ b/src/data/state.rs @@ -2,17 +2,17 @@ use crate::{ config::{Config, UrlKind}, data::NodeCache, db::Db, - error::MyError, + error::Error, requests::{Breakers, Requests}, }; use activitystreams::url::Url; use actix_web::web; use async_rwlock::RwLock; -use log::info; use lru::LruCache; use rand::thread_rng; use rsa::{RsaPrivateKey, RsaPublicKey}; use std::sync::Arc; +use tracing::info; #[derive(Clone)] pub struct State { @@ -25,6 +25,20 @@ pub struct State { pub(crate) db: Db, } +impl std::fmt::Debug for State { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("State") + .field("public_key", &"PublicKey") + .field("private_key", &"[redacted]") + .field("config", &self.config) + .field("object_cache", &"Object Cache") + .field("node_cache", &self.node_cache) + .field("breakers", &self.breakers) + .field("db", &self.db) + .finish() + } +} + impl State { pub(crate) fn node_cache(&self) -> NodeCache { self.node_cache.clone() @@ -44,11 +58,12 @@ impl State { ) } + #[tracing::instrument(name = "Get inboxes for other domains")] pub(crate) async fn inboxes_without( &self, existing_inbox: &Url, domain: &str, - ) -> Result, MyError> { + ) -> Result, Error> { Ok(self .db .inboxes() @@ -74,8 +89,10 @@ impl State { self.object_cache.write().await.put(object_id, actor_id); } - pub(crate) async fn build(config: Config, db: Db) -> Result { + #[tracing::instrument(name = "Building state")] + pub(crate) async fn build(config: Config, db: Db) -> Result { let private_key = if let Ok(Some(key)) = db.private_key().await { + info!("Using existing key"); key } else { info!("Generating new keys"); diff --git a/src/db.rs b/src/db.rs index 41f6c3c..8836926 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,4 +1,4 @@ -use crate::{config::Config, error::MyError}; +use crate::{config::Config, error::Error}; use activitystreams::url::Url; use actix_web::web::Bytes; use rsa::{ @@ -9,7 +9,7 @@ use sled::Tree; use std::{collections::HashMap, sync::Arc, time::SystemTime}; use uuid::Uuid; -#[derive(Clone)] +#[derive(Clone, Debug)] pub(crate) struct Db { inner: Arc, } @@ -31,6 +31,14 @@ struct Inner { restricted_mode: bool, } +impl std::fmt::Debug for Inner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Inner") + .field("restricted_mode", &self.restricted_mode) + .finish() + } +} + #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct Actor { pub(crate) id: Url, @@ -194,12 +202,12 @@ impl Inner { } impl Db { - pub(crate) fn build(config: &Config) -> Result { + pub(crate) fn build(config: &Config) -> Result { let db = sled::open(config.sled_path())?; Self::build_inner(config.restricted_mode(), db) } - fn build_inner(restricted_mode: bool, db: sled::Db) -> Result { + fn build_inner(restricted_mode: bool, db: sled::Db) -> Result { Ok(Db { inner: Arc::new(Inner { actor_id_actor: db.open_tree("actor-id-actor")?, @@ -222,8 +230,8 @@ impl Db { async fn unblock( &self, - f: impl Fn(&Inner) -> Result + Send + 'static, - ) -> Result + f: impl Fn(&Inner) -> Result + Send + 'static, + ) -> Result where T: Send + 'static, { @@ -234,11 +242,11 @@ impl Db { Ok(t) } - pub(crate) async fn connected_ids(&self) -> Result, MyError> { + pub(crate) async fn connected_ids(&self) -> Result, Error> { self.unblock(|inner| Ok(inner.connected().collect())).await } - pub(crate) async fn save_info(&self, actor_id: Url, info: Info) -> Result<(), MyError> { + pub(crate) async fn save_info(&self, actor_id: Url, info: Info) -> Result<(), Error> { self.unblock(move |inner| { let vec = serde_json::to_vec(&info)?; @@ -251,7 +259,7 @@ impl Db { .await } - pub(crate) async fn info(&self, actor_id: Url) -> Result, MyError> { + pub(crate) async fn info(&self, actor_id: Url) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.actor_id_info.get(actor_id.as_str().as_bytes())? { let info = serde_json::from_slice(&ivec)?; @@ -263,7 +271,7 @@ impl Db { .await } - pub(crate) async fn connected_info(&self) -> Result, MyError> { + pub(crate) async fn connected_info(&self) -> Result, Error> { self.unblock(|inner| Ok(inner.connected_info().collect())) .await } @@ -272,7 +280,7 @@ impl Db { &self, actor_id: Url, instance: Instance, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { self.unblock(move |inner| { let vec = serde_json::to_vec(&instance)?; @@ -285,7 +293,7 @@ impl Db { .await } - pub(crate) async fn instance(&self, actor_id: Url) -> Result, MyError> { + pub(crate) async fn instance(&self, actor_id: Url) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.actor_id_instance.get(actor_id.as_str().as_bytes())? { let instance = serde_json::from_slice(&ivec)?; @@ -297,16 +305,12 @@ impl Db { .await } - pub(crate) async fn connected_instance(&self) -> Result, MyError> { + pub(crate) async fn connected_instance(&self) -> Result, Error> { self.unblock(|inner| Ok(inner.connected_instance().collect())) .await } - pub(crate) async fn save_contact( - &self, - actor_id: Url, - contact: Contact, - ) -> Result<(), MyError> { + pub(crate) async fn save_contact(&self, actor_id: Url, contact: Contact) -> Result<(), Error> { self.unblock(move |inner| { let vec = serde_json::to_vec(&contact)?; @@ -319,7 +323,7 @@ impl Db { .await } - pub(crate) async fn contact(&self, actor_id: Url) -> Result, MyError> { + pub(crate) async fn contact(&self, actor_id: Url) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.actor_id_contact.get(actor_id.as_str().as_bytes())? { let contact = serde_json::from_slice(&ivec)?; @@ -331,12 +335,12 @@ impl Db { .await } - pub(crate) async fn connected_contact(&self) -> Result, MyError> { + pub(crate) async fn connected_contact(&self) -> Result, Error> { self.unblock(|inner| Ok(inner.connected_contact().collect())) .await } - pub(crate) async fn save_url(&self, url: Url, id: Uuid) -> Result<(), MyError> { + pub(crate) async fn save_url(&self, url: Url, id: Uuid) -> Result<(), Error> { self.unblock(move |inner| { inner .media_id_media_url @@ -354,7 +358,7 @@ impl Db { id: Uuid, meta: MediaMeta, bytes: Bytes, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { self.unblock(move |inner| { let vec = serde_json::to_vec(&meta)?; @@ -368,7 +372,7 @@ impl Db { .await } - pub(crate) async fn media_id(&self, url: Url) -> Result, MyError> { + pub(crate) async fn media_id(&self, url: Url) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.media_url_media_id.get(url.as_str().as_bytes())? { Ok(uuid_from_ivec(ivec)) @@ -379,7 +383,7 @@ impl Db { .await } - pub(crate) async fn media_url(&self, id: Uuid) -> Result, MyError> { + pub(crate) async fn media_url(&self, id: Uuid) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.media_id_media_url.get(id.as_bytes())? { Ok(url_from_ivec(ivec)) @@ -390,7 +394,7 @@ impl Db { .await } - pub(crate) async fn media_bytes(&self, id: Uuid) -> Result, MyError> { + pub(crate) async fn media_bytes(&self, id: Uuid) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.media_id_media_bytes.get(id.as_bytes())? { Ok(Some(Bytes::copy_from_slice(&ivec))) @@ -401,7 +405,7 @@ impl Db { .await } - pub(crate) async fn media_meta(&self, id: Uuid) -> Result, MyError> { + pub(crate) async fn media_meta(&self, id: Uuid) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.media_id_media_meta.get(id.as_bytes())? { let meta = serde_json::from_slice(&ivec)?; @@ -413,16 +417,16 @@ impl Db { .await } - pub(crate) async fn blocks(&self) -> Result, MyError> { + pub(crate) async fn blocks(&self) -> Result, Error> { self.unblock(|inner| Ok(inner.blocks().collect())).await } - pub(crate) async fn inboxes(&self) -> Result, MyError> { + pub(crate) async fn inboxes(&self) -> Result, Error> { self.unblock(|inner| Ok(inner.connected_actors().map(|actor| actor.inbox).collect())) .await } - pub(crate) async fn is_connected(&self, mut id: Url) -> Result { + pub(crate) async fn is_connected(&self, mut id: Url) -> Result { id.set_path(""); id.set_query(None); id.set_fragment(None); @@ -444,7 +448,7 @@ impl Db { pub(crate) async fn actor_id_from_public_key_id( &self, public_key_id: Url, - ) -> Result, MyError> { + ) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner .public_key_id_actor_id @@ -458,7 +462,7 @@ impl Db { .await } - pub(crate) async fn actor(&self, actor_id: Url) -> Result, MyError> { + pub(crate) async fn actor(&self, actor_id: Url) -> Result, Error> { self.unblock(move |inner| { if let Some(ivec) = inner.actor_id_actor.get(actor_id.as_str().as_bytes())? { let actor = serde_json::from_slice(&ivec)?; @@ -470,7 +474,7 @@ impl Db { .await } - pub(crate) async fn save_actor(&self, actor: Actor) -> Result<(), MyError> { + pub(crate) async fn save_actor(&self, actor: Actor) -> Result<(), Error> { self.unblock(move |inner| { let vec = serde_json::to_vec(&actor)?; @@ -486,8 +490,8 @@ impl Db { .await } - pub(crate) async fn remove_connection(&self, actor_id: Url) -> Result<(), MyError> { - log::debug!("Removing Connection: {}", actor_id); + pub(crate) async fn remove_connection(&self, actor_id: Url) -> Result<(), Error> { + tracing::debug!("Removing Connection: {}", actor_id); self.unblock(move |inner| { inner .connected_actor_ids @@ -498,8 +502,8 @@ impl Db { .await } - pub(crate) async fn add_connection(&self, actor_id: Url) -> Result<(), MyError> { - log::debug!("Adding Connection: {}", actor_id); + pub(crate) async fn add_connection(&self, actor_id: Url) -> Result<(), Error> { + tracing::debug!("Adding Connection: {}", actor_id); self.unblock(move |inner| { inner .connected_actor_ids @@ -510,7 +514,7 @@ impl Db { .await } - pub(crate) async fn add_blocks(&self, domains: Vec) -> Result<(), MyError> { + pub(crate) async fn add_blocks(&self, domains: Vec) -> Result<(), Error> { self.unblock(move |inner| { for connected in inner.connected_by_domain(&domains) { inner @@ -530,7 +534,7 @@ impl Db { .await } - pub(crate) async fn remove_blocks(&self, domains: Vec) -> Result<(), MyError> { + pub(crate) async fn remove_blocks(&self, domains: Vec) -> Result<(), Error> { self.unblock(move |inner| { for domain in &domains { inner.blocked_domains.remove(domain_key(domain))?; @@ -541,7 +545,7 @@ impl Db { .await } - pub(crate) async fn add_allows(&self, domains: Vec) -> Result<(), MyError> { + pub(crate) async fn add_allows(&self, domains: Vec) -> Result<(), Error> { self.unblock(move |inner| { for domain in &domains { inner @@ -554,7 +558,7 @@ impl Db { .await } - pub(crate) async fn remove_allows(&self, domains: Vec) -> Result<(), MyError> { + pub(crate) async fn remove_allows(&self, domains: Vec) -> Result<(), Error> { self.unblock(move |inner| { if inner.restricted_mode { for connected in inner.connected_by_domain(&domains) { @@ -573,7 +577,7 @@ impl Db { .await } - pub(crate) async fn is_allowed(&self, url: Url) -> Result { + pub(crate) async fn is_allowed(&self, url: Url) -> Result { self.unblock(move |inner| { if let Some(domain) = url.domain() { Ok(inner.is_allowed(domain)) @@ -584,7 +588,7 @@ impl Db { .await } - pub(crate) async fn private_key(&self) -> Result, MyError> { + pub(crate) async fn private_key(&self) -> Result, Error> { self.unblock(|inner| { if let Some(ivec) = inner.settings.get("private-key")? { let key_str = String::from_utf8_lossy(&ivec); @@ -601,7 +605,7 @@ impl Db { pub(crate) async fn update_private_key( &self, private_key: &RsaPrivateKey, - ) -> Result<(), MyError> { + ) -> Result<(), Error> { let pem_pkcs8 = private_key.to_pkcs8_pem()?; self.unblock(move |inner| { diff --git a/src/error.rs b/src/error.rs index e13f682..580004b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,11 +5,43 @@ use actix_web::{ HttpResponse, }; use http_signature_normalization_actix::PrepareSignError; -use log::error; -use std::{convert::Infallible, fmt::Debug, io::Error}; +use std::{convert::Infallible, fmt::Debug, io}; +use tracing::error; +use tracing_error::SpanTrace; + +#[derive(Debug)] +pub(crate) struct Error { + context: SpanTrace, + kind: ErrorKind, +} + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.kind)?; + std::fmt::Display::fmt(&self.context, f) + } +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.kind.source() + } +} + +impl From for Error +where + ErrorKind: From, +{ + fn from(error: T) -> Self { + Error { + context: SpanTrace::capture(), + kind: error.into(), + } + } +} #[derive(Debug, thiserror::Error)] -pub(crate) enum MyError { +pub(crate) enum ErrorKind { #[error("Error queueing job, {0}")] Queue(anyhow::Error), @@ -23,7 +55,7 @@ pub(crate) enum MyError { Uri(#[from] ParseError), #[error("Couldn't perform IO, {0}")] - Io(#[from] Error), + Io(#[from] io::Error), #[error("Couldn't sign string, {0}")] Rsa(rsa::errors::Error), @@ -111,19 +143,23 @@ pub(crate) enum MyError { #[error("Not trying request due to failed breaker")] Breaker, + + #[error("Failed to extract fields from {0}")] + Extract(&'static str) } -impl ResponseError for MyError { +impl ResponseError for Error { fn status_code(&self) -> StatusCode { - match self { - MyError::NotAllowed(_) | MyError::WrongActor(_) | MyError::BadActor(_, _) => { + match self.kind { + ErrorKind::NotAllowed(_) | ErrorKind::WrongActor(_) | ErrorKind::BadActor(_, _) => { StatusCode::FORBIDDEN } - MyError::NotSubscribed(_) => StatusCode::UNAUTHORIZED, - MyError::Duplicate => StatusCode::ACCEPTED, - MyError::Kind(_) | MyError::MissingKind | MyError::MissingId | MyError::ObjectCount => { - StatusCode::BAD_REQUEST - } + ErrorKind::NotSubscribed(_) => StatusCode::UNAUTHORIZED, + ErrorKind::Duplicate => StatusCode::ACCEPTED, + ErrorKind::Kind(_) + | ErrorKind::MissingKind + | ErrorKind::MissingId + | ErrorKind::ObjectCount => StatusCode::BAD_REQUEST, _ => StatusCode::INTERNAL_SERVER_ERROR, } } @@ -133,27 +169,27 @@ impl ResponseError for MyError { .insert_header(("Content-Type", "application/activity+json")) .body( serde_json::to_string(&serde_json::json!({ - "error": self.to_string(), + "error": self.kind.to_string(), })) .unwrap_or("{}".to_string()), ) } } -impl From for MyError { +impl From for ErrorKind { fn from(_: BlockingError) -> Self { - MyError::Canceled + ErrorKind::Canceled } } -impl From for MyError { +impl From for ErrorKind { fn from(i: Infallible) -> Self { match i {} } } -impl From for MyError { +impl From for ErrorKind { fn from(e: rsa::errors::Error) -> Self { - MyError::Rsa(e) + ErrorKind::Rsa(e) } } diff --git a/src/jobs/apub/announce.rs b/src/jobs/apub/announce.rs index 3005ea4..f1cafd8 100644 --- a/src/jobs/apub/announce.rs +++ b/src/jobs/apub/announce.rs @@ -1,7 +1,7 @@ use crate::{ config::{Config, UrlKind}, db::Actor, - error::MyError, + error::Error, jobs::{ apub::{get_inboxes, prepare_activity}, DeliverMany, JobState, @@ -22,7 +22,8 @@ impl Announce { Announce { object_id, actor } } - async fn perform(self, state: JobState) -> Result<(), anyhow::Error> { + #[tracing::instrument(name = "Announce")] + async fn perform(self, state: JobState) -> Result<(), Error> { let activity_id = state.config.generate_url(UrlKind::Activity); let announce = generate_announce(&state.config, &activity_id, &self.object_id)?; @@ -41,7 +42,7 @@ fn generate_announce( config: &Config, activity_id: &Url, object_id: &Url, -) -> Result { +) -> Result { let announce = AsAnnounce::new(config.generate_url(UrlKind::Actor), object_id.clone()); prepare_activity( @@ -58,6 +59,6 @@ impl ActixJob for Announce { const NAME: &'static str = "relay::jobs::apub::Announce"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/apub/follow.rs b/src/jobs/apub/follow.rs index 38bb748..315f0d5 100644 --- a/src/jobs/apub/follow.rs +++ b/src/jobs/apub/follow.rs @@ -2,7 +2,7 @@ use crate::{ apub::AcceptedActivities, config::{Config, UrlKind}, db::Actor, - error::MyError, + error::{Error, ErrorKind}, jobs::{apub::prepare_activity, Deliver, JobState, QueryInstance, QueryNodeinfo}, }; use activitystreams::{ @@ -24,7 +24,8 @@ impl Follow { Follow { input, actor } } - async fn perform(self, state: JobState) -> Result<(), anyhow::Error> { + #[tracing::instrument(name = "Follow")] + async fn perform(self, state: JobState) -> Result<(), Error> { let my_id = state.config.generate_url(UrlKind::Actor); // if following relay directly, not just following 'public', followback @@ -42,7 +43,7 @@ impl Follow { let accept = generate_accept_follow( &state.config, &self.actor.id, - self.input.id_unchecked().ok_or(MyError::MissingId)?, + self.input.id_unchecked().ok_or(ErrorKind::MissingId)?, &my_id, )?; @@ -61,7 +62,7 @@ impl Follow { } // Generate a type that says "I want to follow you" -fn generate_follow(config: &Config, actor_id: &Url, my_id: &Url) -> Result { +fn generate_follow(config: &Config, actor_id: &Url, my_id: &Url) -> Result { let follow = AsFollow::new(my_id.clone(), actor_id.clone()); prepare_activity( @@ -77,7 +78,7 @@ fn generate_accept_follow( actor_id: &Url, input_id: &Url, my_id: &Url, -) -> Result { +) -> Result { let mut follow = AsFollow::new(actor_id.clone(), my_id.clone()); follow.set_id(input_id.clone()); @@ -98,6 +99,6 @@ impl ActixJob for Follow { const NAME: &'static str = "relay::jobs::apub::Follow"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/apub/forward.rs b/src/jobs/apub/forward.rs index 8014673..ba086c7 100644 --- a/src/jobs/apub/forward.rs +++ b/src/jobs/apub/forward.rs @@ -1,7 +1,7 @@ use crate::{ apub::AcceptedActivities, db::Actor, - error::MyError, + error::{Error, ErrorKind}, jobs::{apub::get_inboxes, DeliverMany, JobState}, }; use activitystreams::prelude::*; @@ -19,12 +19,13 @@ impl Forward { Forward { input, actor } } - async fn perform(self, state: JobState) -> Result<(), anyhow::Error> { + #[tracing::instrument(name = "Forward")] + async fn perform(self, state: JobState) -> Result<(), Error> { let object_id = self .input .object() .as_single_id() - .ok_or(MyError::MissingId)?; + .ok_or(ErrorKind::MissingId)?; let inboxes = get_inboxes(&state.state, &self.actor, object_id).await?; @@ -43,6 +44,6 @@ impl ActixJob for Forward { const NAME: &'static str = "relay::jobs::apub::Forward"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/apub/mod.rs b/src/jobs/apub/mod.rs index 9c6825b..b2900fb 100644 --- a/src/jobs/apub/mod.rs +++ b/src/jobs/apub/mod.rs @@ -2,7 +2,7 @@ use crate::{ config::{Config, UrlKind}, data::State, db::Actor, - error::MyError, + error::{Error, ErrorKind}, }; use activitystreams::{ activity::{Follow as AsFollow, Undo as AsUndo}, @@ -23,8 +23,8 @@ pub(crate) use self::{ announce::Announce, follow::Follow, forward::Forward, reject::Reject, undo::Undo, }; -async fn get_inboxes(state: &State, actor: &Actor, object_id: &Url) -> Result, MyError> { - let domain = object_id.host().ok_or(MyError::Domain)?.to_string(); +async fn get_inboxes(state: &State, actor: &Actor, object_id: &Url) -> Result, Error> { + let domain = object_id.host().ok_or(ErrorKind::Domain)?.to_string(); state.inboxes_without(&actor.inbox, &domain).await } @@ -33,10 +33,10 @@ fn prepare_activity( mut t: T, id: impl TryInto, to: impl TryInto, -) -> Result +) -> Result where T: ObjectExt + BaseExt, - MyError: From + From, + Error: From + From, { t.set_id(id.try_into()?) .set_many_tos(vec![to.try_into()?]) @@ -45,7 +45,7 @@ where } // Generate a type that says "I want to stop following you" -fn generate_undo_follow(config: &Config, actor_id: &Url, my_id: &Url) -> Result { +fn generate_undo_follow(config: &Config, actor_id: &Url, my_id: &Url) -> Result { let mut follow = AsFollow::new(my_id.clone(), actor_id.clone()); follow.set_id(config.generate_url(UrlKind::Activity)); diff --git a/src/jobs/apub/reject.rs b/src/jobs/apub/reject.rs index 070ce11..c2e6199 100644 --- a/src/jobs/apub/reject.rs +++ b/src/jobs/apub/reject.rs @@ -1,6 +1,7 @@ use crate::{ config::UrlKind, db::Actor, + error::Error, jobs::{apub::generate_undo_follow, Deliver, JobState}, }; use background_jobs::ActixJob; @@ -10,7 +11,8 @@ use std::{future::Future, pin::Pin}; pub(crate) struct Reject(pub(crate) Actor); impl Reject { - async fn perform(self, state: JobState) -> Result<(), anyhow::Error> { + #[tracing::instrument(name = "Reject")] + async fn perform(self, state: JobState) -> Result<(), Error> { state.actors.remove_connection(&self.0).await?; let my_id = state.config.generate_url(UrlKind::Actor); @@ -29,6 +31,6 @@ impl ActixJob for Reject { const NAME: &'static str = "relay::jobs::apub::Reject"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/apub/undo.rs b/src/jobs/apub/undo.rs index c965837..f12a19f 100644 --- a/src/jobs/apub/undo.rs +++ b/src/jobs/apub/undo.rs @@ -2,6 +2,7 @@ use crate::{ apub::AcceptedActivities, config::UrlKind, db::Actor, + error::Error, jobs::{apub::generate_undo_follow, Deliver, JobState}, }; use background_jobs::ActixJob; @@ -18,7 +19,8 @@ impl Undo { Undo { input, actor } } - async fn perform(self, state: JobState) -> Result<(), anyhow::Error> { + #[tracing::instrument(name = "Undo")] + async fn perform(self, state: JobState) -> Result<(), Error> { let was_following = state.state.db.is_connected(self.actor.id.clone()).await?; state.actors.remove_connection(&self.actor).await?; @@ -42,6 +44,6 @@ impl ActixJob for Undo { const NAME: &'static str = "relay::jobs::apub::Undo"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/cache_media.rs b/src/jobs/cache_media.rs index f12ab89..640cfca 100644 --- a/src/jobs/cache_media.rs +++ b/src/jobs/cache_media.rs @@ -1,5 +1,4 @@ -use crate::jobs::JobState; -use anyhow::Error; +use crate::{error::Error, jobs::JobState}; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; use uuid::Uuid; @@ -14,6 +13,7 @@ impl CacheMedia { CacheMedia { uuid } } + #[tracing::instrument(name = "Cache media")] async fn perform(self, state: JobState) -> Result<(), Error> { if !state.media.is_outdated(self.uuid).await? { return Ok(()); @@ -34,11 +34,11 @@ impl CacheMedia { impl ActixJob for CacheMedia { type State = JobState; - type Future = Pin>>>; + type Future = Pin>>>; const NAME: &'static str = "relay::jobs::CacheMedia"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/contact.rs b/src/jobs/contact.rs index e60fe22..49afcab 100644 --- a/src/jobs/contact.rs +++ b/src/jobs/contact.rs @@ -1,6 +1,9 @@ -use crate::{apub::AcceptedActors, jobs::JobState}; +use crate::{ + apub::AcceptedActors, + error::{Error, ErrorKind}, + jobs::JobState, +}; use activitystreams::{object::Image, prelude::*, url::Url}; -use anyhow::Error; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; @@ -33,8 +36,8 @@ impl QueryContact { .fetch::(self.contact_id.as_str()) .await?; - let (username, display_name, url, avatar) = to_contact(contact) - .ok_or_else(|| anyhow::anyhow!("Failed to extract fields from contact"))?; + let (username, display_name, url, avatar) = + to_contact(contact).ok_or_else(|| ErrorKind::Extract("contact"))?; state .node_cache @@ -63,12 +66,12 @@ fn to_contact(contact: AcceptedActors) -> Option<(String, String, Url, Url)> { impl ActixJob for QueryContact { type State = JobState; - type Future = Pin>>>; + type Future = Pin>>>; const NAME: &'static str = "relay::jobs::QueryContact"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/deliver.rs b/src/jobs/deliver.rs index 5db691f..0789981 100644 --- a/src/jobs/deliver.rs +++ b/src/jobs/deliver.rs @@ -1,6 +1,5 @@ -use crate::{error::MyError, jobs::JobState}; +use crate::{error::Error, jobs::JobState}; use activitystreams::url::Url; -use anyhow::Error; use background_jobs::{ActixJob, Backoff}; use std::{future::Future, pin::Pin}; @@ -11,7 +10,7 @@ pub(crate) struct Deliver { } impl Deliver { - pub(crate) fn new(to: Url, data: T) -> Result + pub(crate) fn new(to: Url, data: T) -> Result where T: serde::ser::Serialize, { @@ -20,20 +19,22 @@ impl Deliver { data: serde_json::to_value(data)?, }) } + + #[tracing::instrument(name = "Deliver")] + async fn permform(self, state: JobState) -> Result<(), Error> { + state.requests.deliver(self.to, &self.data).await?; + Ok(()) + } } impl ActixJob for Deliver { type State = JobState; - type Future = Pin>>>; + type Future = Pin>>>; const NAME: &'static str = "relay::jobs::Deliver"; const BACKOFF: Backoff = Backoff::Exponential(8); fn run(self, state: Self::State) -> Self::Future { - Box::pin(async move { - state.requests.deliver(self.to, &self.data).await?; - - Ok(()) - }) + Box::pin(async move { self.permform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/deliver_many.rs b/src/jobs/deliver_many.rs index 39cbb30..2ff8c83 100644 --- a/src/jobs/deliver_many.rs +++ b/src/jobs/deliver_many.rs @@ -1,11 +1,10 @@ use crate::{ - error::MyError, + error::Error, jobs::{Deliver, JobState}, }; use activitystreams::url::Url; -use anyhow::Error; use background_jobs::ActixJob; -use futures::future::{ready, Ready}; +use std::future::{ready, Ready}; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub(crate) struct DeliverMany { @@ -14,7 +13,7 @@ pub(crate) struct DeliverMany { } impl DeliverMany { - pub(crate) fn new(to: Vec, data: T) -> Result + pub(crate) fn new(to: Vec, data: T) -> Result where T: serde::ser::Serialize, { @@ -24,6 +23,7 @@ impl DeliverMany { }) } + #[tracing::instrument(name = "Deliver many")] fn perform(self, state: JobState) -> Result<(), Error> { for inbox in self.to { state @@ -37,11 +37,11 @@ impl DeliverMany { impl ActixJob for DeliverMany { type State = JobState; - type Future = Ready>; + type Future = Ready>; const NAME: &'static str = "relay::jobs::DeliverMany"; fn run(self, state: Self::State) -> Self::Future { - ready(self.perform(state)) + ready(self.perform(state).map_err(Into::into)) } } diff --git a/src/jobs/instance.rs b/src/jobs/instance.rs index 398293d..6cc8984 100644 --- a/src/jobs/instance.rs +++ b/src/jobs/instance.rs @@ -1,9 +1,9 @@ use crate::{ config::UrlKind, + error::Error, jobs::{cache_media::CacheMedia, JobState}, }; use activitystreams::url::Url; -use anyhow::Error; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; @@ -17,6 +17,7 @@ impl QueryInstance { QueryInstance { actor_id } } + #[tracing::instrument(name = "Query instance")] async fn perform(self, state: JobState) -> Result<(), Error> { let contact_outdated = state .node_cache @@ -91,12 +92,12 @@ impl QueryInstance { impl ActixJob for QueryInstance { type State = JobState; - type Future = Pin>>>; + type Future = Pin>>>; const NAME: &'static str = "relay::jobs::QueryInstance"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/mod.rs b/src/jobs/mod.rs index 99aecd3..7c3e775 100644 --- a/src/jobs/mod.rs +++ b/src/jobs/mod.rs @@ -16,7 +16,7 @@ use crate::{ config::Config, data::{ActorCache, MediaCache, NodeCache, State}, db::Db, - error::MyError, + error::{Error, ErrorKind}, jobs::process_listeners::Listeners, requests::Requests, }; @@ -67,7 +67,7 @@ pub(crate) fn create_workers( .start(remote_handle); } -#[derive(Clone)] +#[derive(Clone, Debug)] pub(crate) struct JobState { db: Db, requests: Requests, @@ -84,6 +84,14 @@ pub(crate) struct JobServer { remote: QueueHandle, } +impl std::fmt::Debug for JobServer { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("JobServer") + .field("queue_handle", &"QueueHandle") + .finish() + } +} + impl JobState { fn new( db: Db, @@ -113,10 +121,13 @@ impl JobServer { } } - pub(crate) fn queue(&self, job: J) -> Result<(), MyError> + pub(crate) fn queue(&self, job: J) -> Result<(), Error> where J: Job, { - self.remote.queue(job).map_err(MyError::Queue) + self.remote + .queue(job) + .map_err(ErrorKind::Queue) + .map_err(Into::into) } } diff --git a/src/jobs/nodeinfo.rs b/src/jobs/nodeinfo.rs index cf9e43a..c4eed56 100644 --- a/src/jobs/nodeinfo.rs +++ b/src/jobs/nodeinfo.rs @@ -1,6 +1,8 @@ -use crate::jobs::{JobState, QueryContact}; +use crate::{ + error::Error, + jobs::{JobState, QueryContact}, +}; use activitystreams::url::Url; -use anyhow::Error; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; @@ -14,6 +16,7 @@ impl QueryNodeinfo { QueryNodeinfo { actor_id } } + #[tracing::instrument(name = "Query node info")] async fn perform(self, state: JobState) -> Result<(), Error> { if !state .node_cache @@ -65,12 +68,12 @@ impl QueryNodeinfo { impl ActixJob for QueryNodeinfo { type State = JobState; - type Future = Pin>>>; + type Future = Pin>>>; const NAME: &'static str = "relay::jobs::QueryNodeinfo"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/jobs/process_listeners.rs b/src/jobs/process_listeners.rs index 2827578..df81d30 100644 --- a/src/jobs/process_listeners.rs +++ b/src/jobs/process_listeners.rs @@ -1,5 +1,7 @@ -use crate::jobs::{instance::QueryInstance, nodeinfo::QueryNodeinfo, JobState}; -use anyhow::Error; +use crate::{ + error::Error, + jobs::{instance::QueryInstance, nodeinfo::QueryNodeinfo, JobState}, +}; use background_jobs::ActixJob; use std::{future::Future, pin::Pin}; @@ -7,6 +9,7 @@ use std::{future::Future, pin::Pin}; pub(crate) struct Listeners; impl Listeners { + #[tracing::instrument(name = "Spawn query instances")] async fn perform(self, state: JobState) -> Result<(), Error> { for actor_id in state.state.db.connected_ids().await? { state @@ -21,11 +24,11 @@ impl Listeners { impl ActixJob for Listeners { type State = JobState; - type Future = Pin>>>; + type Future = Pin>>>; const NAME: &'static str = "relay::jobs::Listeners"; fn run(self, state: Self::State) -> Self::Future { - Box::pin(self.perform(state)) + Box::pin(async move { self.perform(state).await.map_err(Into::into) }) } } diff --git a/src/main.rs b/src/main.rs index 1933cd4..7b5fd3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ -use actix_web::{ - middleware::{Compress, Logger}, - web, App, HttpServer, -}; +use actix_web::{web, App, HttpServer}; +use tracing_actix_web::TracingLogger; +use tracing_error::ErrorLayer; +use tracing_log::LogTracer; +use tracing_subscriber::{fmt::format::FmtSpan, layer::SubscriberExt, EnvFilter}; mod apub; mod args; @@ -28,23 +29,23 @@ use self::{ async fn main() -> Result<(), anyhow::Error> { dotenv::dotenv().ok(); + LogTracer::init()?; + + let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); + + let format_layer = tracing_subscriber::fmt::layer() + .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) + .pretty(); + + let subscriber = tracing_subscriber::Registry::default() + .with(env_filter) + .with(ErrorLayer::default()) + .with(format_layer); + + tracing::subscriber::set_global_default(subscriber)?; + let config = Config::build()?; - if config.debug() { - std::env::set_var( - "RUST_LOG", - "debug,h2=info,trust_dns_resolver=info,trust_dns_proto=info,rustls=info,html5ever=info", - ) - } else { - std::env::set_var("RUST_LOG", "info") - } - - if config.pretty_log() { - pretty_env_logger::init(); - } else { - env_logger::init(); - } - let db = Db::build(&config)?; let args = Args::new(); @@ -77,8 +78,7 @@ async fn main() -> Result<(), anyhow::Error> { let bind_address = config.bind_address(); HttpServer::new(move || { App::new() - .wrap(Compress::default()) - .wrap(Logger::default()) + .wrap(TracingLogger::default()) .app_data(web::Data::new(db.clone())) .app_data(web::Data::new(state.clone())) .app_data(web::Data::new(state.requests())) diff --git a/src/middleware/payload.rs b/src/middleware/payload.rs index 7db9ddb..1f591bb 100644 --- a/src/middleware/payload.rs +++ b/src/middleware/payload.rs @@ -1,15 +1,18 @@ use actix_web::{ dev::{Payload, Service, ServiceRequest, Transform}, - http::{Method, StatusCode}, + http::Method, web::BytesMut, - HttpMessage, HttpResponse, ResponseError, + HttpMessage, }; -use futures::{ - future::{ok, LocalBoxFuture, Ready, TryFutureExt}, +use futures_util::{ + future::{LocalBoxFuture, TryFutureExt}, stream::{once, TryStreamExt}, }; -use log::{error, info}; -use std::task::{Context, Poll}; +use std::{ + future::{ready, Ready}, + task::{Context, Poll}, +}; +use tracing::info; #[derive(Clone, Debug)] pub(crate) struct DebugPayload(pub bool); @@ -18,20 +21,6 @@ pub(crate) struct DebugPayload(pub bool); #[derive(Clone, Debug)] pub(crate) struct DebugPayloadMiddleware(bool, S); -#[derive(Clone, Debug, thiserror::Error)] -#[error("Failed to read payload")] -pub(crate) struct DebugError; - -impl ResponseError for DebugError { - fn status_code(&self) -> StatusCode { - StatusCode::BAD_REQUEST - } - - fn error_response(&self) -> HttpResponse { - HttpResponse::new(self.status_code()) - } -} - impl Transform for DebugPayload where S: Service, @@ -45,7 +34,7 @@ where type Future = Ready>; fn new_transform(&self, service: S) -> Self::Future { - ok(DebugPayloadMiddleware(self.0, service)) + ready(Ok(DebugPayloadMiddleware(self.0, service))) } } diff --git a/src/middleware/verifier.rs b/src/middleware/verifier.rs index 6d7fd1e..ccc388b 100644 --- a/src/middleware/verifier.rs +++ b/src/middleware/verifier.rs @@ -1,28 +1,28 @@ use crate::{ apub::AcceptedActors, data::{ActorCache, State}, - error::MyError, + error::{Error, ErrorKind}, requests::Requests, }; use activitystreams::{base::BaseExt, uri, url::Url}; use actix_web::web; use http_signature_normalization_actix::{prelude::*, verify::DeprecatedAlgorithm}; -use log::error; use rsa::{hash::Hash, padding::PaddingScheme, pkcs8::FromPublicKey, PublicKey, RsaPublicKey}; use sha2::{Digest, Sha256}; use std::{future::Future, pin::Pin}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub(crate) struct MyVerify(pub Requests, pub ActorCache, pub State); impl MyVerify { + #[tracing::instrument("Verify signature")] async fn verify( &self, algorithm: Option, key_id: String, signature: String, signing_string: String, - ) -> Result { + ) -> Result { let public_key_id = uri!(key_id); let actor_id = if let Some(mut actor_id) = self @@ -32,7 +32,7 @@ impl MyVerify { .await? { if !self.2.db.is_allowed(actor_id.clone()).await? { - return Err(MyError::NotAllowed(key_id)); + return Err(ErrorKind::NotAllowed(key_id).into()); } actor_id.set_fragment(None); @@ -44,7 +44,7 @@ impl MyVerify { Some(Algorithm::Hs2019) => (), Some(Algorithm::Deprecated(DeprecatedAlgorithm::RsaSha256)) => (), Some(other) => { - return Err(MyError::Algorithm(other.to_string())); + return Err(ErrorKind::Algorithm(other.to_string()).into()); } None => (), }; @@ -65,7 +65,7 @@ impl MyVerify { .fetch::(public_key_id.as_str()) .await? .actor_id() - .ok_or_else(|| MyError::MissingId)? + .ok_or_else(|| ErrorKind::MissingId)? }; // Previously we verified the sig from an actor's local cache @@ -106,7 +106,7 @@ async fn do_verify( public_key: &str, signature: String, signing_string: String, -) -> Result<(), MyError> { +) -> Result<(), Error> { let public_key = RsaPublicKey::from_public_key_pem(public_key)?; web::block(move || { @@ -121,7 +121,7 @@ async fn do_verify( &decoded, )?; - Ok(()) as Result<(), MyError> + Ok(()) as Result<(), Error> }) .await??; @@ -129,7 +129,7 @@ async fn do_verify( } impl SignatureVerify for MyVerify { - type Error = MyError; + type Error = Error; type Future = Pin>>>; fn signature_verify( @@ -144,10 +144,6 @@ impl SignatureVerify for MyVerify { Box::pin(async move { this.verify(algorithm, key_id, signature, signing_string) .await - .map_err(|e| { - error!("Failed to verify, {}", e); - e - }) }) } } diff --git a/src/middleware/webfinger.rs b/src/middleware/webfinger.rs index b947a12..1ed8056 100644 --- a/src/middleware/webfinger.rs +++ b/src/middleware/webfinger.rs @@ -4,8 +4,8 @@ use crate::{ }; use actix_web::web::Data; use actix_webfinger::{Resolver, Webfinger}; +use futures_util::future::LocalBoxFuture; use rsa_magic_public_key::AsMagicPublicKey; -use std::{future::Future, pin::Pin}; pub(crate) struct RelayResolver; @@ -13,8 +13,6 @@ pub(crate) struct RelayResolver; #[error("Error resolving webfinger data")] pub(crate) struct RelayError; -type FutResult = dyn Future>; - impl Resolver for RelayResolver { type State = (Data, Data); type Error = RelayError; @@ -23,7 +21,7 @@ impl Resolver for RelayResolver { account: &str, domain: &str, (state, config): Self::State, - ) -> Pin, Self::Error>>> { + ) -> LocalBoxFuture<'static, Result, Self::Error>> { let domain = domain.to_owned(); let account = account.to_owned(); diff --git a/src/requests.rs b/src/requests.rs index bc7ccdd..bf8a638 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -1,4 +1,4 @@ -use crate::error::MyError; +use crate::error::{Error, ErrorKind}; use activitystreams::url::Url; use actix_web::{http::header::Date, web::Bytes}; use async_mutex::Mutex; @@ -6,7 +6,6 @@ use async_rwlock::RwLock; use awc::Client; use chrono::{DateTime, Utc}; use http_signature_normalization_actix::prelude::*; -use log::{debug, info, warn}; use rsa::{hash::Hash, padding::PaddingScheme, RsaPrivateKey}; use sha2::{Digest, Sha256}; use std::{ @@ -19,12 +18,19 @@ use std::{ }, time::SystemTime, }; +use tracing::{debug, info, warn}; #[derive(Clone)] pub(crate) struct Breakers { inner: Arc>>>>, } +impl std::fmt::Debug for Breakers { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Breakers").finish() + } +} + impl Breakers { async fn should_try(&self, url: &Url) -> bool { if let Some(domain) = url.domain() { @@ -97,6 +103,7 @@ impl Default for Breakers { } } +#[derive(Debug)] struct Breaker { failures: usize, last_attempt: DateTime, @@ -153,6 +160,21 @@ pub(crate) struct Requests { breakers: Breakers, } +impl std::fmt::Debug for Requests { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Requests") + .field("client", &"Client") + .field("consecutive_errors", &"AtomicUsize") + .field("error_limit", &self.error_limit) + .field("key_id", &self.key_id) + .field("user_agent", &self.user_agent) + .field("private_key", &"[redacted]") + .field("config", &self.config) + .field("breakers", &self.breakers) + .finish() + } +} + impl Requests { pub(crate) fn new( key_id: String, @@ -191,28 +213,28 @@ impl Requests { self.consecutive_errors.swap(0, Ordering::Relaxed); } - pub(crate) async fn fetch_json(&self, url: &str) -> Result + pub(crate) async fn fetch_json(&self, url: &str) -> Result where T: serde::de::DeserializeOwned, { self.do_fetch(url, "application/json").await } - pub(crate) async fn fetch(&self, url: &str) -> Result + pub(crate) async fn fetch(&self, url: &str) -> Result where T: serde::de::DeserializeOwned, { self.do_fetch(url, "application/activity+json").await } - async fn do_fetch(&self, url: &str, accept: &str) -> Result + async fn do_fetch(&self, url: &str, accept: &str) -> Result where T: serde::de::DeserializeOwned, { let parsed_url = url.parse::()?; if !self.breakers.should_try(&parsed_url).await { - return Err(MyError::Breaker); + return Err(ErrorKind::Breaker.into()); } let signer = self.signer(); @@ -236,7 +258,7 @@ impl Requests { self.breakers.fail(&parsed_url).await; } - let mut res = res.map_err(|e| MyError::SendRequest(url.to_string(), e.to_string()))?; + let mut res = res.map_err(|e| ErrorKind::SendRequest(url.to_string(), e.to_string()))?; self.reset_err(); @@ -251,7 +273,7 @@ impl Requests { self.breakers.fail(&parsed_url).await; - return Err(MyError::Status(url.to_string(), res.status())); + return Err(ErrorKind::Status(url.to_string(), res.status()).into()); } self.breakers.succeed(&parsed_url).await; @@ -259,16 +281,16 @@ impl Requests { let body = res .body() .await - .map_err(|e| MyError::ReceiveResponse(url.to_string(), e.to_string()))?; + .map_err(|e| ErrorKind::ReceiveResponse(url.to_string(), e.to_string()))?; Ok(serde_json::from_slice(body.as_ref())?) } - pub(crate) async fn fetch_bytes(&self, url: &str) -> Result<(String, Bytes), MyError> { + pub(crate) async fn fetch_bytes(&self, url: &str) -> Result<(String, Bytes), Error> { let parsed_url = url.parse::()?; if !self.breakers.should_try(&parsed_url).await { - return Err(MyError::Breaker); + return Err(ErrorKind::Breaker.into()); } info!("Fetching bytes for {}", url); @@ -293,7 +315,7 @@ impl Requests { self.count_err(); } - let mut res = res.map_err(|e| MyError::SendRequest(url.to_string(), e.to_string()))?; + let mut res = res.map_err(|e| ErrorKind::SendRequest(url.to_string(), e.to_string()))?; self.reset_err(); @@ -301,10 +323,10 @@ impl Requests { if let Ok(s) = content_type.to_str() { s.to_owned() } else { - return Err(MyError::ContentType); + return Err(ErrorKind::ContentType.into()); } } else { - return Err(MyError::ContentType); + return Err(ErrorKind::ContentType.into()); }; if !res.status().is_success() { @@ -318,14 +340,14 @@ impl Requests { self.breakers.fail(&parsed_url).await; - return Err(MyError::Status(url.to_string(), res.status())); + return Err(ErrorKind::Status(url.to_string(), res.status()).into()); } self.breakers.succeed(&parsed_url).await; let bytes = match res.body().limit(1024 * 1024 * 4).await { Err(e) => { - return Err(MyError::ReceiveResponse(url.to_string(), e.to_string())); + return Err(ErrorKind::ReceiveResponse(url.to_string(), e.to_string()).into()); } Ok(bytes) => bytes, }; @@ -333,12 +355,12 @@ impl Requests { Ok((content_type, bytes)) } - pub(crate) async fn deliver(&self, inbox: Url, item: &T) -> Result<(), MyError> + pub(crate) async fn deliver(&self, inbox: Url, item: &T) -> Result<(), Error> where T: serde::ser::Serialize, { if !self.breakers.should_try(&inbox).await { - return Err(MyError::Breaker); + return Err(ErrorKind::Breaker.into()); } let signer = self.signer(); @@ -366,7 +388,7 @@ impl Requests { self.breakers.fail(&inbox).await; } - let mut res = res.map_err(|e| MyError::SendRequest(inbox.to_string(), e.to_string()))?; + let mut res = res.map_err(|e| ErrorKind::SendRequest(inbox.to_string(), e.to_string()))?; self.reset_err(); @@ -380,7 +402,7 @@ impl Requests { } self.breakers.fail(&inbox).await; - return Err(MyError::Status(inbox.to_string(), res.status())); + return Err(ErrorKind::Status(inbox.to_string(), res.status()).into()); } self.breakers.succeed(&inbox).await; @@ -400,7 +422,7 @@ struct Signer { } impl Signer { - fn sign(&self, signing_string: &str) -> Result { + fn sign(&self, signing_string: &str) -> Result { let hashed = Sha256::digest(signing_string.as_bytes()); let bytes = self.private_key.sign( PaddingScheme::PKCS1v15Sign { diff --git a/src/routes/actor.rs b/src/routes/actor.rs index a7e503c..3f895b7 100644 --- a/src/routes/actor.rs +++ b/src/routes/actor.rs @@ -2,7 +2,7 @@ use crate::{ apub::{PublicKey, PublicKeyInner}, config::{Config, UrlKind}, data::State, - error::MyError, + error::Error, routes::ok, }; use activitystreams::{ @@ -15,10 +15,11 @@ use activitystreams_ext::Ext1; use actix_web::{web, Responder}; use rsa::pkcs8::ToPublicKey; +#[tracing::instrument(name = "Actor")] pub(crate) async fn route( state: web::Data, config: web::Data, -) -> Result { +) -> Result { let mut application = Ext1::new( ApActor::new(config.generate_url(UrlKind::Inbox), Application::new()), PublicKey { diff --git a/src/routes/inbox.rs b/src/routes/inbox.rs index 8ec2645..e193179 100644 --- a/src/routes/inbox.rs +++ b/src/routes/inbox.rs @@ -3,7 +3,7 @@ use crate::{ config::{Config, UrlKind}, data::{ActorCache, State}, db::Actor, - error::MyError, + error::{Error, ErrorKind}, jobs::apub::{Announce, Follow, Forward, Reject, Undo}, jobs::JobServer, requests::Requests, @@ -14,8 +14,9 @@ use activitystreams::{ }; use actix_web::{web, HttpResponse}; use http_signature_normalization_actix::prelude::{DigestVerified, SignatureVerified}; -use log::error; +use tracing::error; +#[tracing::instrument(name = "Inbox")] pub(crate) async fn route( state: web::Data, actors: web::Data, @@ -24,12 +25,12 @@ pub(crate) async fn route( jobs: web::Data, input: web::Json, verified: Option<(SignatureVerified, DigestVerified)>, -) -> Result { +) -> Result { let input = input.into_inner(); let actor = actors .get( - input.actor()?.as_single_id().ok_or(MyError::MissingId)?, + input.actor()?.as_single_id().ok_or(ErrorKind::MissingId)?, &client, ) .await? @@ -39,28 +40,29 @@ pub(crate) async fn route( let is_connected = state.db.is_connected(actor.id.clone()).await?; if !is_allowed { - return Err(MyError::NotAllowed(actor.id.to_string())); + return Err(ErrorKind::NotAllowed(actor.id.to_string()).into()); } if !is_connected && !valid_without_listener(&input)? { - return Err(MyError::NotSubscribed(actor.id.to_string())); + return Err(ErrorKind::NotSubscribed(actor.id.to_string()).into()); } if config.validate_signatures() && verified.is_none() { - return Err(MyError::NoSignature(actor.public_key_id.to_string())); + return Err(ErrorKind::NoSignature(actor.public_key_id.to_string()).into()); } else if config.validate_signatures() { if let Some((verified, _)) = verified { if actor.public_key_id.as_str() != verified.key_id() { error!("Bad actor, more info: {:?}", input); - return Err(MyError::BadActor( + return Err(ErrorKind::BadActor( actor.public_key_id.to_string(), verified.key_id().to_owned(), - )); + ) + .into()); } } } - match input.kind().ok_or(MyError::MissingKind)? { + match input.kind().ok_or(ErrorKind::MissingKind)? { ValidTypes::Accept => handle_accept(&config, input).await?, ValidTypes::Reject => handle_reject(&config, &jobs, input, actor).await?, ValidTypes::Announce | ValidTypes::Create => { @@ -74,7 +76,7 @@ pub(crate) async fn route( Ok(accepted(serde_json::json!({}))) } -fn valid_without_listener(input: &AcceptedActivities) -> Result { +fn valid_without_listener(input: &AcceptedActivities) -> Result { match input.kind() { Some(ValidTypes::Follow) => Ok(true), Some(ValidTypes::Undo) => Ok(single_object(input.object())?.is_kind("Follow")), @@ -82,32 +84,32 @@ fn valid_without_listener(input: &AcceptedActivities) -> Result { } } -fn kind_str(base: &AnyBase) -> Result<&str, MyError> { - base.kind_str().ok_or(MyError::MissingKind) +fn kind_str(base: &AnyBase) -> Result<&str, Error> { + base.kind_str() + .ok_or(ErrorKind::MissingKind) + .map_err(Into::into) } -fn id_string(id: Option<&Url>) -> Result { - id.map(|s| s.to_string()).ok_or(MyError::MissingId) +fn id_string(id: Option<&Url>) -> Result { + id.map(|s| s.to_string()) + .ok_or(ErrorKind::MissingId) + .map_err(Into::into) } -fn single_object(o: &OneOrMany) -> Result<&AnyBase, MyError> { - o.as_one().ok_or(MyError::ObjectCount) +fn single_object(o: &OneOrMany) -> Result<&AnyBase, Error> { + o.as_one().ok_or(ErrorKind::ObjectCount).map_err(Into::into) } -async fn handle_accept(config: &Config, input: AcceptedActivities) -> Result<(), MyError> { +async fn handle_accept(config: &Config, input: AcceptedActivities) -> Result<(), Error> { let base = single_object(input.object())?.clone(); let follow = if let Some(follow) = activity::Follow::from_any_base(base)? { follow } else { - return Err(MyError::Kind( - kind_str(single_object(input.object())?)?.to_owned(), - )); + return Err(ErrorKind::Kind(kind_str(single_object(input.object())?)?.to_owned()).into()); }; if !follow.actor_is(&config.generate_url(UrlKind::Actor)) { - return Err(MyError::WrongActor(id_string( - follow.actor()?.as_single_id(), - )?)); + return Err(ErrorKind::WrongActor(id_string(follow.actor()?.as_single_id())?).into()); } Ok(()) @@ -118,20 +120,16 @@ async fn handle_reject( jobs: &JobServer, input: AcceptedActivities, actor: Actor, -) -> Result<(), MyError> { +) -> Result<(), Error> { let base = single_object(input.object())?.clone(); let follow = if let Some(follow) = activity::Follow::from_any_base(base)? { follow } else { - return Err(MyError::Kind( - kind_str(single_object(input.object())?)?.to_owned(), - )); + return Err(ErrorKind::Kind(kind_str(single_object(input.object())?)?.to_owned()).into()); }; if !follow.actor_is(&config.generate_url(UrlKind::Actor)) { - return Err(MyError::WrongActor(id_string( - follow.actor()?.as_single_id(), - )?)); + return Err(ErrorKind::WrongActor(id_string(follow.actor()?.as_single_id())?).into()); } jobs.queue(Reject(actor))?; @@ -145,26 +143,26 @@ async fn handle_undo( input: AcceptedActivities, actor: Actor, is_listener: bool, -) -> Result<(), MyError> { +) -> Result<(), Error> { let any_base = single_object(input.object())?.clone(); let undone_object = - AcceptedUndoObjects::from_any_base(any_base)?.ok_or(MyError::ObjectFormat)?; + AcceptedUndoObjects::from_any_base(any_base)?.ok_or(ErrorKind::ObjectFormat)?; if !undone_object.is_kind(&UndoTypes::Follow) { if is_listener { jobs.queue(Forward::new(input, actor))?; return Ok(()); } else { - return Err(MyError::NotSubscribed(actor.id.to_string())); + return Err(ErrorKind::NotSubscribed(actor.id.to_string()).into()); } } let my_id: Url = config.generate_url(UrlKind::Actor); if !undone_object.object_is(&my_id) && !undone_object.object_is(&public()) { - return Err(MyError::WrongActor(id_string( - undone_object.object().as_single_id(), - )?)); + return Err( + ErrorKind::WrongActor(id_string(undone_object.object().as_single_id())?).into(), + ); } if !is_listener { @@ -179,7 +177,7 @@ async fn handle_forward( jobs: &JobServer, input: AcceptedActivities, actor: Actor, -) -> Result<(), MyError> { +) -> Result<(), Error> { jobs.queue(Forward::new(input, actor))?; Ok(()) @@ -190,11 +188,11 @@ async fn handle_announce( jobs: &JobServer, input: AcceptedActivities, actor: Actor, -) -> Result<(), MyError> { - let object_id = input.object().as_single_id().ok_or(MyError::MissingId)?; +) -> Result<(), Error> { + let object_id = input.object().as_single_id().ok_or(ErrorKind::MissingId)?; if state.is_cached(object_id).await { - return Err(MyError::Duplicate); + return Err(ErrorKind::Duplicate.into()); } jobs.queue(Announce::new(object_id.to_owned(), actor))?; @@ -207,13 +205,11 @@ async fn handle_follow( jobs: &JobServer, input: AcceptedActivities, actor: Actor, -) -> Result<(), MyError> { +) -> Result<(), Error> { let my_id: Url = config.generate_url(UrlKind::Actor); if !input.object_is(&my_id) && !input.object_is(&public()) { - return Err(MyError::WrongActor(id_string( - input.object().as_single_id(), - )?)); + return Err(ErrorKind::WrongActor(id_string(input.object().as_single_id())?).into()); } jobs.queue(Follow::new(input, actor))?; diff --git a/src/routes/index.rs b/src/routes/index.rs index 6f597d8..4064086 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -1,13 +1,18 @@ -use crate::{config::Config, data::State, error::MyError}; +use crate::{ + config::Config, + data::State, + error::{Error, ErrorKind}, +}; use actix_web::{web, HttpResponse}; -use log::error; use rand::{seq::SliceRandom, thread_rng}; use std::io::BufWriter; +use tracing::error; +#[tracing::instrument(name = "Index")] pub(crate) async fn route( state: web::Data, config: web::Data, -) -> Result { +) -> Result { let mut nodes = state.node_cache().nodes().await?; nodes.shuffle(&mut thread_rng()); let mut buf = BufWriter::new(Vec::new()); @@ -15,7 +20,7 @@ pub(crate) async fn route( crate::templates::index(&mut buf, &nodes, &config)?; let buf = buf.into_inner().map_err(|e| { error!("Error rendering template, {}", e.error()); - MyError::FlushBuffer + ErrorKind::FlushBuffer })?; Ok(HttpResponse::Ok().content_type("text/html").body(buf)) diff --git a/src/routes/media.rs b/src/routes/media.rs index b8041af..5867ce9 100644 --- a/src/routes/media.rs +++ b/src/routes/media.rs @@ -1,15 +1,16 @@ -use crate::{data::MediaCache, error::MyError, requests::Requests}; +use crate::{data::MediaCache, error::Error, requests::Requests}; use actix_web::{ http::header::{CacheControl, CacheDirective}, web, HttpResponse, }; use uuid::Uuid; +#[tracing::instrument(name = "Media")] pub(crate) async fn route( media: web::Data, requests: web::Data, uuid: web::Path, -) -> Result { +) -> Result { let uuid = uuid.into_inner(); if let Some((content_type, bytes)) = media.get_bytes(uuid).await? { diff --git a/src/routes/nodeinfo.rs b/src/routes/nodeinfo.rs index 181f3f3..89c4621 100644 --- a/src/routes/nodeinfo.rs +++ b/src/routes/nodeinfo.rs @@ -5,6 +5,7 @@ use crate::{ use actix_web::{web, Responder}; use actix_webfinger::Link; +#[tracing::instrument(name = "Well Known NodeInfo")] pub(crate) async fn well_known(config: web::Data) -> impl Responder { web::Json(Links { links: vec![Link { @@ -22,6 +23,7 @@ struct Links { links: Vec, } +#[tracing::instrument(name = "NodeInfo")] pub(crate) async fn route( config: web::Data, state: web::Data, diff --git a/src/routes/statics.rs b/src/routes/statics.rs index 1ca595f..d79bb12 100644 --- a/src/routes/statics.rs +++ b/src/routes/statics.rs @@ -4,6 +4,7 @@ use actix_web::{ web, HttpResponse, }; +#[tracing::instrument(name = "Statistics")] pub(crate) async fn route(filename: web::Path) -> HttpResponse { if let Some(data) = StaticFile::get(&filename.into_inner()) { HttpResponse::Ok()