From: Jonas Smedegaard Date: Sat, 20 Jul 2024 11:35:28 +0000 (+0200) Subject: Import safe-vdash_0.17.9.orig.tar.gz X-Git-Tag: archive/raspbian/0.17.9-4+rpi1~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=426da739810b3693fea6cff64fef7a6de8d71452;p=safe-vdash.git Import safe-vdash_0.17.9.orig.tar.gz [dgit import orig safe-vdash_0.17.9.orig.tar.gz] --- 426da739810b3693fea6cff64fef7a6de8d71452 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c7ef87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/target +/heaptrack +src/main-tui.rs +jotter.txt +test.log +terminalizer/ +junk*/ +api*/ + diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..70cf5f2 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2477 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72832d73be48bac96a5d7944568f305d829ed55b0ce3b483647089dfaf6cf704" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +dependencies = [ + "serde", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "borsh" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.38", + "syn_derive", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byte-unit" +version = "5.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ac19bdf0b2665407c39d82dbc937e951e7e2001609f0fb32edd0af45a2d63e" +dependencies = [ + "rust_decimal", + "serde", + "utf8-width", +] + +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.48.5", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossterm" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +dependencies = [ + "bitflags 2.4.1", + "crossterm_winapi", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 2.0.38", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "deranged" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "filetime" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "windows-sys 0.48.0", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "h2" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.1.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.7", +] + +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +dependencies = [ + "ahash 0.8.4", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.2", + "serde", +] + +[[package]] +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + +[[package]] +name = "inotify" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +dependencies = [ + "bitflags 1.3.2", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kqueue" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" + +[[package]] +name = "linemux" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb035c7806bd7982a317d8d66815021e91f7ab14a5fbedee22b06f608f11b43" +dependencies = [ + "futures-util", + "notify", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "lru" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" +dependencies = [ + "hashbrown 0.14.2", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "notify" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" +dependencies = [ + "bitflags 1.3.2", + "crossbeam-channel", + "filetime", + "inotify", + "kqueue", + "libc", + "mio", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.3", + "libc", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "ratatui" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb" +dependencies = [ + "bitflags 2.4.1", + "cassowary", + "crossterm", + "indoc", + "itertools", + "lru", + "paste", + "serde", + "stability", + "strum", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rend" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "reqwest" +version = "0.11.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-rustls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "ring" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.48.0", +] + +[[package]] +name = "rkyv" +version = "0.7.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.33.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "serde" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.1.0", + "serde", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "stability" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd1b177894da2a2d9120208c3386066af06a488255caabc5de8ddca22dbc3ce" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "strfmt" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8348af2d9fc3258c8733b8d9d8db2e56f54b2363a4b5b81585c7875ed65e65" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.38", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "time" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" + +[[package]] +name = "vdash" +version = "0.17.9" +dependencies = [ + "bincode", + "byte-unit", + "chrono", + "crossterm", + "env_logger", + "fs2", + "futures", + "glob", + "lazy_static", + "linemux", + "log", + "rand", + "ratatui", + "regex", + "reqwest", + "serde", + "serde_json", + "serde_with", + "strfmt", + "structopt", + "tempfile", + "time", + "tokio", + "tokio-macros", + "tokio-stream", +] + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.38", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9738626 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,46 @@ +[package] +name = "vdash" +description = "Safe Network safenode Dashboard" +version = "0.17.9" +authors = ["Mark "] +license = "GPL-3.0" +homepage = "https://github.com/happybeing/vdash" +repository = "https://github.com/happybeing/vdash" +readme = "README.md" +exclude = [".github"] +keywords = ["utility", "logfile", "monitor", "cli", "safenetwork"] +categories = ["command-line-utilities"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tokio = { version = "1.15.0", features = ["sync", "macros", "rt-multi-thread"] } +tokio-stream = "0.1.8" +tokio-macros = "2.1.0" +linemux = "0.3.0" +structopt = "~0.3.15" +futures = "0.3.19" +ratatui = { version = "0.25.0", features = ["serde"] } +crossterm = { version = "0.27.0" } +regex = "1.3.9" +tempfile = "3.1.0" +time = "0.3.29" +lazy_static = "1.4.0" +chrono = { version = "0.4.31", features = ["serde"] } +bincode = "1.3.1" +byte-unit = "5.1.4" +fs2 = "0.4.3" +rand = "0.8.5" +log = "0.4.11" +env_logger = "0.11.1" +strfmt = "0.2.4" +glob = "0.3.1" +serde = {version = "1.0.192", features = ["derive"] } +serde_json = "1.0.108" +serde_with = { version = "3.4.0", features = ["chrono_0_4"] } +reqwest = { version = "0.11.23", default_features = false, features = ["rustls-tls"] } + +[[bin]] +name = "vdash" +path = "src/bin/vdash.rs" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5f8e1e --- /dev/null +++ b/README.md @@ -0,0 +1,267 @@ +# Autononomi node Dashboard + +`vdash` is a terminal based dashboard for monitoring Autononomi nodes. It is written in +Rust, the terminal GUI is implemented using [ratatui](https://github.com/ratatui-org/ratatui) and it monitors one or more node logfiles using [linemux](https://github.com/jmagnuson/linemux). + +**Status:** working on Windows, MacOS and Linux with public and local test networks. + +`vdash` can monitor multiple logfiles on the local machine, showing multiple metrics for each node including number of PUTS (chunks stored), current price being charged for storage, and node earnings. Many metrics appear both as numeric values and can be viewed in real-time graphical charts over time. + +## Discussion and Bug Reports +A Autononomi forum topic is the main forum for discussion: [Vdash - Node dashboard for Autonomi nodes](https://forum.autonomi.community/t/vdash-dashboard-for-autonomi-nodes/32630?u=happybeing) + +Bug reports and feature requests can be made in [github issues](https://github.com/happybeing/vdash/issues). + +## Remote Monitoring +Remote logfiles could be monitored by using `rsyslog` to mirror them to the machine running `vdash`. This would allow multiple remote machines to be monitored from one machine. + I have not tried using `rsylog` but have monitored nodes on a remote machine by using `tail` over `ssh` to mirror a remote logfile to the machine running `vdash`. + +Here's an early `vdash` (v0.2.0) working with a local testnet node: +screenshot of vdash v0.2.0 + +## Features +`vdash` will load historic metrics from one or more Safe node +logfiles and display these with live updates in the terminal (see above). A list of keyboard commands is available by pressing '?', some of which are described below for the *Summary* and *Node Status* screens. + +### Summary of Monitored Nodes +**'arrow keys':** The up and down arrows select a row, containing data for one particular node. The left and right arrows select a column heading and sorts rows by the values in the selected column. + +**'space':** Pressing the space bar toggles sort of the selected column between ascending and descending. + +**'enter':** Switches the display to show *Node Status* of the node of the highlighted row. + +**'q':** Press 'q' to quit. + +**'?':** Shows help. + +### Node Status +**'enter'** Switches the display back to the *Summary of Monitored Nodes*. + +**'arrow keys':** The left and right arrows shift the single node display between different nodes. + +**'i' and 'o':** Zoom the timeline scale in/out using 'i' and 'o' (or '+' and '-'). + +**'t' and 'T':** If some timelines are not displayed due to lack of vertical space you can cycle +through the timelines to bring them into view by pressing 't' (forward) and 'T' +(backward). + +**'m' or 'M':** The Storage Cost timeline displays minimum, mean and maximum +values in each time-slot. To cycle through the min, mean and max displays +press 'm' or 'M'. + +**'q':** Press 'q' to quit. + +**'?':** Shows help. + +## Operating Systems +- **Linux:** works on Linux (tested on Ubuntu). +- **Windows:** works on Windows 10. Not tested recently. +- **MacOS:** works on MacOS. Not tested recently. + +## Install using Linux package manager + +`vdash` has been packaged for debian thanks to the generous efforts of Jonas Smedegaard. From 2024 it will begin to be available in many downstream Linux distributions, but due to the pace of updates the packaged version is likely to be behind the version published at crates.io which is always up to date. + +You can check the status of package `safe-vdash` in your distribution and choose whether to install from there or get the most recent version as explained below. + +## Install from crates.io + +1 Install **Rust** via https://doc.rust-lang.org/cargo/getting-started/installation.html + +2a. **Linux (Ubuntu)** + + sudo apt-get install build-essential + +2b. **Linux/MacOS** install **vdash:** + + cargo install vdash + vdash --help + +2c. **Windows** install **vdash:** + +Windows has not been tested recently so you may like to try using `cargo insall vdash` first to see if that now works. If not, you will need to build using Rust Nightly. + +Until the 'itarget' feature becomes part of 'stable', build manually and use the Rust Nightly compiler first install Rust Nightly +using `rustup`: + + rustup toolchain install nightly + +To build `vdash` on Windows, clone vdash, build with `+nightly` and use the binary it creates under `./taget/release`: + + git clone https://github.com/happybeing/vdash + cd vdash + cargo +nightly build -Z features=itarget --bin vdash --release --no-default-features + + ./target/release/vdash --help + +## Using vdash - a Autononomi node Dashboard +`vdash` provides a terminal based graphical dashboard of Autononomi node activity on the local machine. It parses input from one or more node logfiles to gather live node metrics which are displayed using terminal graphics. + + +## Get Autononomi pre-requisites +1. **Get Rust:** see: https://doc.rust-lang.org/cargo/getting-started/installation.html + +2. **Get the Autonomi Node Applications:** There are two options for running nodes at the launch of the beta on 5th June 2024. The `node-launchpad` is a simple terminal based UI (TUI) and the `safenode-manager` is command line program for 'power users', although the community can help you use either. See https://autonomi.com for details of how to obtain these apps and join the beta. + +3. **Start your Autonomi Nodes:** See https://docs.autonomi.com for documentation and join the [forum](https://forum.autonomi.community) if you need help. + +You are now ready to install `vdash` and can test it by running a local test network. + +## Usage + +For help: + + vdash --help + +Typically you can just pass the paths of one or more node logfiles you want to monitor. For example, to run `vdash` first start your Autononomi node(s) with on of the Autonomi Node Applications (see above). + +Then, start `vdash`. You can give a path to one or more logfiles. You can also use `-g` to specify a glob path. When you provide a glob path you can press 'r' to re-scan the path for logfiles after starting more nodes. + +The path to logfiles vary depending on which Autonomi Node Application you are using, and also on your operating system. The following are just examples so you will need to provide paths for your particular setup. + +**Linux:** + + vdash -g "/home//.local/share/safe/node/safenode*/logs/safenode.log" + +**Mac:** + + vdash "/Users//Library/Application Support/safe/node/*/logs/safenode.log" + +**Windows:** + + vdash C:\Users\\AppData\Roaming\safe\node\*\logs\safenode.log + +Keyboard commands for `vdash` are summarised in the introduction above. + +### vdash and 'glob' paths + +`vdash` accepts one or more file paths, but you can also specify one or more 'glob' paths which can scan a directory tree for matching files. This enables you to pick up new nodes added after `vdash` starts, either using the 'r' (re-scan) keyboard command, or automatically by giving a re-scanning period using the `--glob-scan` option on the command line. + +`vdash` scans all 'glob' paths provided on start-up and again whenever you press 'r'. + +Note that unlike a file path you must use quotation marks around a 'glob' path to prevent the shell from trying to expand it. In the examples you will need to replace `` with the appropriate home directory name for your account. + +Example for Linux: + + vdash --glob-path "$HOME/.local/share/safe/node/safenode*/logs/safenode.log" + +Using double rather than single quotes enables you to use '$HOME' in the path instead of giving the home directory explicitly. + +The path to logfiles vary depending on which Autonomi Node Application you are using, and also on your operating system. The following are just examples so you will need to provide paths for your particular setup. + +### Display of Token values +`vdash` shows node earnings and storage cost in terms of Autononomi tokens as 'nanos' or billionths of a token. It can though +be made to display token values in a local currency (e.g. U.S. dollar, British pound etc). For this it needs +a way to obtain the conversion rate for the currency and be told what symbol to use in the +display (e.g. "$", "£" etc.). + +You can do this by passing fixed values on the command line, or have +`vdash` obtain live values using one of the supported web APIs. + +### Currency on the Command Line +Two options allow you to specify the conversion rate and symbol for your chosen currency. + +For example, for a token value of 1.23 U.S. dollars you would use the following command line options: + +``` +--currency-symbol "$" --currency-token-rate 1.23 +``` + +You can use the above to provide a default conversion and have live prices override this when available. + +For more type `vdash --help`. + +### Live Prices via Web API +`vdash` can obtain the Autononomi token price in a specified currency from the +Coingecko.com or Coinmarketcap.com web APIs provided you have an access key for the corresponding API. At this time, both offer both paid and free/demo API +keys which you obtain by signing up for an account with those websites. + +If you have keys for one or both of these services you must pass them to `vdash` on the command line as shown below. + +In both cases a default polling interval is set by `vdash` that will not exceed the advertised number of API requests for a free API key, although this polling interval can be shortened by specifying the polling interval on the command line. + +For more type `vdash --help`. + +#### Coingecko.com +To have `vdash` obtain the token rate from Coingecko.com include the following on the command line and replace `YOUR-API-KEY` with the API key you obtained from the service. + +```sh +--currency-apiname "GBP" --currency-symbol "£" --coingecko-key "YOUR-API-KEY" +``` + +#### Coinmarketcap.com +To have `vdash` obtain the token rate from Coinmarketcap.com include the following on the command line and replace `YOUR-API-KEY` with the API key you obtained from the service. + +```sh +--currency-apiname "GBP" --currency-symbol "£" --coinmarketcap-key "YOUR-API-KEY" +``` + +### Using vdash + +Start your nodes using an Autonomi Node Application. + +When your node or nodes have started, run `vdash`, typically in a different terminal: +```sh +vdash --glob-path "$HOME/.local/share/safe/node/*/safenode.log" +``` +Modify the above example for your setup, and include any additional command line options as required. + +For example, to enable display of earnings and storage costs using local currency: +```sh +vdash --currency-apiname "USD" --currency-symbol "$" --glob-path "$HOME/.local/share/safe/node/*/logs/safenode.log" +``` + +### Using vdash With a Local Test Network + +First clone the Autononomi repository and change directory into the cloned copy and checkout branch `stable`: + +```sh +git clone https://github.com/maidsafe/safe_network +cd safe_network +git checkout stable +``` + +Then start a local test network using the instructions [here](https://github.com/maidsafe/safe_network/#run-your-maidsafe-local-test-network-in-4-easy-steps). + +You can then start `vdash` to display the status of the nodes in that network as follows: + +```sh +vdash --currency-apiname "USD" --currency-symbol "$" --glob-path "$HOME/.local/share/safe/node/*/logs/safenode.log" +``` + +If you return to the instructions [here](https://github.com/maidsafe/safe_network/#run-your-maidsafe-local-test-network-in-4-easy-steps) you can obtain some tokens to pay for your file uploads, and try uploading some files again using the instructions at that link, and monitor the activity of your test network nodes using `vdash`. + +## Build (for Developers Only) + +See [Get Autononomi Pre-requisites](#get-autonomi-pre-requisites). + +### Get code +``` +git clone https://github.com/happybeing/vdash +cd vdash +``` + +### Build - Linux / MacOS / Windows 10 +Note: MacOS and Windows are untested but may 'just work' - please report success or failure in an issue. +``` +cargo build --release +``` +If built for target 'musl' `vdash` uses considerably less memory: + +```sh +rustup target add x86_64-unknown-linux-musl +cargo build --release --target x86_64-unknown-linux-musl +``` +Comparing memory use (using `htop` on Linux): +```sh +VIRT RES SHR +803M 9372 4716 x13 threads (release) +32768 6848 2440 x13 threads (release/musl) +``` +Note: the above figures are out of date but illustrate the point. + +## LICENSE + +Everything is GPL3.0 unless otherwise stated. Any contributions are accepted on the condition they conform to this license. + +See also [./LICENSE](./LICENSE) \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..76fd9a5 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +edition = "2018" +hard_tabs = true +tab_spaces = 2 \ No newline at end of file diff --git a/screenshots/vdash v0.2.0.png b/screenshots/vdash v0.2.0.png new file mode 100644 index 0000000..87f02a7 Binary files /dev/null and b/screenshots/vdash v0.2.0.png differ diff --git a/screenshots/vdash-v.0.2.4.gif b/screenshots/vdash-v.0.2.4.gif new file mode 100644 index 0000000..a4d49c1 Binary files /dev/null and b/screenshots/vdash-v.0.2.4.gif differ diff --git a/src/bin/vdash.rs b/src/bin/vdash.rs new file mode 100644 index 0000000..eea7135 --- /dev/null +++ b/src/bin/vdash.rs @@ -0,0 +1,240 @@ +//! This app monitors logfiles and displays status in the terminal +//! +//! It is based on logtail-dash, which is a basic logfile dashboard +//! and also a framework for similar apps with customised dashboard +//! displays. +//! +//! Custom apps based on logtail can be created by creating a +//! fork of logtail-dash and modifying the files in src/custom +//! +//! See README for more information. + +#![recursion_limit = "1024"] // Prevent select! macro blowing up + +#[path = "../custom/mod.rs"] +pub mod custom; +use self::custom::app::{OPT, App, DashViewMain}; +use self::custom::ui::draw_dashboard; + +#[macro_use] +extern crate log; +extern crate env_logger; + +///! logtail and its forks share code in src/ +#[path = "../mod.rs"] +pub mod shared; + +use crossterm::{ + event::{self, DisableMouseCapture, EnableMouseCapture, Event as CEvent}, + execute, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, +}; + +use std::{ + error::Error, + io::stdout, + thread, + time::{Duration, Instant,SystemTime, UNIX_EPOCH}, +}; + +use chrono::Utc; + +use ratatui::{backend::CrosstermBackend, Terminal}; + +use futures::{ + future::FutureExt, // for `.fuse()` + pin_mut, + select, +}; + +pub enum Event { + Input(I), + Tick, +} + +use tokio_stream::StreamExt; +use tokio::sync::mpsc; + +#[tokio::main] +pub async fn main() -> Result<(), Box> { + let (opt_tick_rate, checkpoint_interval, opt_debug_window, + coingecho_api_key, coinmarketcap_api_key, currency_apiname) = { + let opt = OPT.lock().unwrap(); + (opt.tick_rate, opt.checkpoint_interval, opt.debug_window, + opt.coingecko_key.clone(), opt.coinmarketcap_key.clone(), opt.currency_apiname.clone()) + }; + + env_logger::init(); + info!("Started"); + + let mut app = match App::new().await { + Ok(app) => app, + Err(_e) => return Ok(()), + }; + + let mut web_apis = crate::custom::web_requests::WebPriceAPIs::new(coingecho_api_key, coinmarketcap_api_key, ¤cy_apiname); + + // Terminal initialization + enable_raw_mode()?; + + let mut stdout = stdout(); + execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; + let backend = CrosstermBackend::new(stdout); + let mut terminal = Terminal::new(backend)?; + let mut rx = initialise_events(opt_tick_rate); + terminal.clear()?; + + // Use futures of async functions to handle events + // concurrently with logfile changes. + + let start = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Time went backwards"); + let mut next_update = start - Duration::from_secs(2); + loop { + if next_update < SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Time went backwards") { + terminal.draw(|f| draw_dashboard(f, &mut app))?; + next_update += Duration::from_secs(1); + match web_apis.handle_web_requests().await { + Ok(Some(currency_per_token)) => { + app.dash_state.currency_per_token = Some(currency_per_token); + app.update_summary_window(); + }, + Ok(None) => {}, + Err(e) => { + _ = reset_terminal(&mut terminal); + eprintln!("Web API error, {}", e); + return Ok(()); + }, + }; + let prices = custom::app::WEB_PRICES.lock().unwrap(); + if prices.snt_rate.is_some() { + app.dash_state.currency_per_token = prices.snt_rate; + } + } + + let logfiles_future = app.logfiles_manager.linemux_files.next().fuse(); + let events_future = rx.recv().fuse(); + + pin_mut!(logfiles_future, events_future); + + select! { + e = events_future => { + match e { + Some(Event::Input(event)) => { + if !self::custom::ui_keyboard::handle_keyboard_event(&mut app, &event, opt_debug_window).await { + return reset_terminal(&mut terminal); + } + terminal.draw(|f| draw_dashboard(f, &mut app)).unwrap(); + } + + Some(Event::Tick) => { + app.update_timelines(&Utc::now()); + app.scan_glob_paths(true, true).await; + terminal.draw(|f| draw_dashboard(f, &mut app)).unwrap(); + // draw_dashboard(&mut f, &dash_state, &mut monitors).unwrap(); + // draw_dashboard(f, &dash_state, &mut monitors)?; + } + + None => {}, + } + }, + line = logfiles_future => { + match line { + Some(Ok(line)) => { + trace!("logfiles_future line"); + let source_str = line.source().to_str().unwrap(); + let source = String::from(source_str); + // app.dash_state._debug_window(format!("{}: {}", source, line.line()).as_str()); + + let mut checkpoint_result: Result = Ok("".to_string()); + match app.get_monitor_for_file_path(&source) { + Some(monitor) => { + checkpoint_result = monitor.append_to_content(line.line(), checkpoint_interval); + if monitor.is_debug_dashboard_log { + app.dash_state._debug_window(line.line()); + } else if app.dash_state.main_view == DashViewMain::DashSummary { + app.update_summary_window(); + } + }, + None => { + app.dash_state._debug_window(format!("NO MONITOR FOR: {}", source).as_str()); + }, + } + match checkpoint_result { + Ok(message) => { + if message.len() > 0 { + app.dash_state.vdash_status.message(&message, None); + } + }, + Err(e) => { + app.dash_state.vdash_status.message(&e.to_string(), None); + } + } + }, + Some(Err(e)) => { + app.dash_state._debug_window(format!("logfile error: {:#?}", e).as_str()); + panic!("{}", e) + } + None => { + app.dash_state._debug_window(format!("logfile error: None").as_str()); + () + } + } + }, + } + } +} + +fn reset_terminal(terminal: &mut Terminal::>) -> Result<(), Box> { + disable_raw_mode()?; + execute!( + terminal.backend_mut(), + LeaveAlternateScreen, + DisableMouseCapture + )?; + terminal.show_cursor()?; + Ok(()) +} + +type Rx = tokio::sync::mpsc::UnboundedReceiver>; + +fn initialise_events(tick_rate: u64) -> Rx { + let tick_rate = Duration::from_millis(tick_rate); + let (tx, rx) = mpsc::unbounded_channel(); // Setup input handling + + thread::spawn(move || { + let mut last_tick = Instant::now(); + loop { + // poll for tick rate duration, if no events, sent tick event. + if event::poll(tick_rate - last_tick.elapsed()).unwrap() { + if let CEvent::Key(key) = event::read().unwrap() { + match tx.send(Event::Input(key)) { + Ok(()) => {}, + Err(e) => eprintln!("send error: {}", e), + + } + } + } + if last_tick.elapsed() >= tick_rate { + match tx.send(Event::Tick) { + Ok(()) => last_tick = Instant::now(), + Err(e) => eprintln!("send error: {}", e), + + } + } + + // TODO remove duplicate code! + if last_tick.elapsed() >= tick_rate { + match tx.send(Event::Tick) { + Ok(()) => last_tick = Instant::now(), + Err(e) => eprintln!("send error: {}", e), + } + } + } + }); + rx +} + diff --git a/src/custom/app.rs b/src/custom/app.rs new file mode 100644 index 0000000..3202e7e --- /dev/null +++ b/src/custom/app.rs @@ -0,0 +1,1829 @@ +///! Application logic +// +// TODO consider colouring logfiles using regex's from https://github.com/bensadeh/tailspin +use std::collections::HashMap; +use std::fs::File; +use std::io::{Error, ErrorKind, Write}; +use std::path::Path; + +use chrono::{DateTime, Duration, Utc}; +use serde::{Deserialize, Serialize}; +use structopt::StructOpt; +use tempfile::NamedTempFile; + +use crate::shared::util::StatefulList; + +use super::app_timelines::{AppTimelines, APP_TIMELINES, TIMESCALES}; +use super::app_timelines::{ + CONNECTIONS_TIMELINE_KEY, EARNINGS_TIMELINE_KEY, ERRORS_TIMELINE_KEY, GETS_TIMELINE_KEY, + PUTS_TIMELINE_KEY, RAM_TIMELINE_KEY, STORAGE_COST_TIMELINE_KEY, +}; +use super::logfile_checkpoints::save_checkpoint; +use super::logfiles_manager::LogfilesManager; +use super::opt::{Opt, MIN_TIMELINE_STEPS}; +use super::timelines::{get_duration_text, MinMeanMax}; + +pub const SAFENODE_BINARY_NAME: &str = "safenode"; +pub static SUMMARY_WINDOW_NAME: &str = "Summary of Monitored Nodes"; +pub static HELP_WINDOW_NAME: &str = "Help"; +pub static DEBUG_WINDOW_NAME: &str = "Debug Window"; + +use std::sync::Mutex; +lazy_static::lazy_static! { + pub static ref DEBUG_LOGFILE: Mutex> = + Mutex::>::new(None); +} + +#[macro_export] +macro_rules! debug_log { + ($message:expr) => { + unsafe { + debug_log($message); + } + }; +} +pub use crate::debug_log; + +pub unsafe fn debug_log(message: &str) { + // --debug-window - prints parser results for a single logfile + // to a temp logfile which is displayed in the adjacent window. + match &(*DEBUG_LOGFILE.lock().unwrap()) { + Some(f) => { + use std::io::Seek; + if let Ok(mut file) = f.reopen() { + file.seek(std::io::SeekFrom::End(0)).unwrap(); + writeln!(file, "{}", message).unwrap(); + } + } + None => (), + }; +} + +lazy_static::lazy_static! { + pub static ref OPT: Mutex = + Mutex::::new(Opt::from_args()); +} + +lazy_static::lazy_static! { + pub static ref WEB_PRICES: Mutex = + Mutex::::new(super::web_requests::WebPrices::new()); +} + +pub struct App { + pub dash_state: DashState, + pub monitors: HashMap, + pub logfile_with_focus: String, + + pub logfiles_manager: LogfilesManager, + pub next_glob_scan: Option>, +} + +impl App { + pub async fn new() -> Result { + let ( + opt_files, + opt_globpaths, + opt_debug_window, + opt_timeline_steps, + opt_currency_token_rate, + opt_currency_symbol, + opt_currency_apiname, + ) = { + let opt = OPT.lock().unwrap(); + ( + opt.files.clone(), + opt.glob_paths.clone(), + opt.debug_window, + opt.timeline_steps, + opt.currency_token_rate, + opt.currency_symbol.clone(), + opt.currency_apiname.clone(), + ) + }; + + let mut app = App { + dash_state: DashState::new(), + monitors: HashMap::new(), + logfile_with_focus: String::new(), + + logfiles_manager: LogfilesManager::new(opt_globpaths.clone()), + next_glob_scan: None, + }; + + app.dash_state.currency_symbol = opt_currency_symbol.clone(); + if opt_currency_token_rate > 0.0 { + app.dash_state.currency_per_token = Some(opt_currency_token_rate); + app.dash_state.ui_uses_currency = true; + } + + let mut web_prices = WEB_PRICES.lock().unwrap(); + web_prices.currency_symbol = opt_currency_symbol; + web_prices.currency_apiname = opt_currency_apiname; + + if opt_files.is_empty() && opt_globpaths.is_empty() { + eprintln!( + "{}: no logfile(s) or 'glob' paths provided.", + Opt::clap().get_name() + ); + return exit_with_usage("missing logfiles"); + } + + if opt_timeline_steps < MIN_TIMELINE_STEPS { + eprintln!( + "Timeline steps number is too small, minimum is {}", + MIN_TIMELINE_STEPS + ); + return exit_with_usage("invalid parameter"); + } + + let mut dash_state = DashState::new(); + dash_state.debug_window = opt_debug_window; + if opt_debug_window { + dash_state.main_view = DashViewMain::DashDebug; + } + + let mut files_to_load = opt_files.clone(); + + if opt_debug_window { + if opt_files.len() == 0 { + eprint!("For debugging with --debug-window you must specify a logfile path."); + return exit_with_usage("missing logfile"); + } + + // For debug: only use first logfile, plus one for debug messages + files_to_load = opt_files[0..1].to_vec(); + let debug_file = NamedTempFile::new()?; + let path = debug_file.path(); + let path_str = path + .to_str() + .ok_or_else(|| Error::new(ErrorKind::Other, "invalid path"))?; + files_to_load.push(String::from(path_str)); + *DEBUG_LOGFILE.lock().unwrap() = Some(debug_file); + } + + if files_to_load.len() > 0 { + app + .logfiles_manager + .monitor_multi_paths(files_to_load, &mut app.monitors, &mut app.dash_state, false) + .await; + } + + app.scan_glob_paths(false, false).await; + + if app.logfiles_manager.logfiles_added.len() > 0 { + app.logfile_with_focus = app.logfiles_manager.logfiles_added[0].clone(); // Save to give focus + } else { + app.dash_state.vdash_status.message( + &"No files to monitor, please start a node and try again.".to_string(), + None, + ); + return exit_with_usage("no files to monitor."); + } + + app.update_timelines(&Utc::now()); + app.update_summary_window(); + + if !app.logfile_with_focus.is_empty() { + app.dash_state.dash_node_focus = app.logfile_with_focus.clone(); + } + + app.set_logfile_with_focus(app.logfile_with_focus.clone()); + app.dash_state.vdash_status.disable_to_console(); + Ok(app) + } + + pub async fn scan_glob_paths(&mut self, timed: bool, disable_status: bool) { + if self.logfiles_manager.globpaths.len() == 0 { + return; + } + let opt_globs_scan = OPT.lock().unwrap().glob_scan; + + let mut do_scan = !timed; + if timed && opt_globs_scan > 0 { + let current_time = Utc::now(); + if let Some(next_glob_scan) = self.next_glob_scan { + if current_time > next_glob_scan { + self.next_glob_scan = Some(current_time + Duration::seconds(opt_globs_scan)); + do_scan = true; + } + } else { + self.next_glob_scan = Some(current_time + Duration::seconds(opt_globs_scan)); + do_scan = true; + } + } + + if do_scan { + let opt_glob_paths = OPT.lock().unwrap().glob_paths.clone(); + self + .logfiles_manager + .scan_multi_globpaths( + opt_glob_paths, + &mut self.monitors, + &mut self.dash_state, + disable_status, + ) + .await; + } + } + + pub fn update_timelines(&mut self, now: &DateTime) { + for (_monitor_file, monitor) in self.monitors.iter_mut() { + monitor.metrics.update_timelines(now); + } + } + + pub fn get_monitor_for_file_path(&mut self, logfile: &String) -> Option<&mut LogMonitor> { + let mut monitor_for_path = None; + for (monitor_file, monitor) in self.monitors.iter_mut() { + if monitor_file.eq(logfile) { + monitor_for_path = Some(monitor); + break; + } + use std::env::current_dir; + if let Ok(current_dir) = current_dir() { + let logfile_path = Path::new(logfile.as_str()); + if current_dir.join(monitor_file).eq(&logfile_path) { + monitor_for_path = Some(monitor); + break; + } + } + } + return monitor_for_path; + } + + pub fn get_debug_dashboard_logfile(&mut self) -> Option { + for (_logfile, monitor) in self.monitors.iter_mut() { + if monitor.is_debug_dashboard_log { + return Some(monitor.logfile.clone()); + } + } + None + } + + pub fn get_logfile_with_focus(&mut self) -> Option { + match (&mut self.monitors).get_mut(&self.logfile_with_focus) { + Some(monitor) => Some(monitor.logfile.clone()), + None => None, + } + } + + pub fn get_monitor_with_focus(&mut self) -> Option<&mut LogMonitor> { + match (&mut self.monitors).get_mut(&self.logfile_with_focus) { + Some(monitor) => Some(monitor), + None => None, + } + } + + pub fn set_logfile_with_focus(&mut self, logfile_name: String) { + if logfile_name.len() == 0 { + return; + } + + match self.get_monitor_with_focus() { + Some(fading_monitor) => { + fading_monitor.has_focus = false; + self.logfile_with_focus = String::new(); + } + None => (), + } + + if logfile_name == DEBUG_WINDOW_NAME { + self.dash_state.debug_window_has_focus = true; + self.logfile_with_focus = logfile_name.clone(); + return; + } else { + self.dash_state.debug_window_has_focus = false; + } + + if let Some(focus_monitor) = (&mut self.monitors).get_mut(&logfile_name) { + focus_monitor.has_focus = true; + self.logfile_with_focus = logfile_name.clone(); + } else { + error!("Unable to focus UI on: {}", logfile_name); + }; + } + + pub fn change_focus_next(&mut self) { + if self.logfiles_manager.logfiles_added.len() == 0 { + return; + } + + let opt_debug_window = { + let opt = OPT.lock().unwrap(); + opt.debug_window + }; + + if self.dash_state.main_view == DashViewMain::DashDebug { + return; + } + + if self.dash_state.main_view == DashViewMain::DashSummary { + if self.dash_state.summary_window_heading_selected + < self.dash_state.summary_window_headings.items.len() - 1 + { + self.dash_state.summary_window_heading_selected += 1; + self.update_summary_window(); + } + } + + let mut next_i = 0; + for (i, name) in self.logfiles_manager.logfiles_added.iter().enumerate() { + if name == &self.logfile_with_focus { + if i < self.logfiles_manager.logfiles_added.len() - 1 { + next_i = i + 1; + } + break; + } + } + + if next_i == 0 && opt_debug_window && self.logfile_with_focus != DEBUG_WINDOW_NAME { + self.set_logfile_with_focus(DEBUG_WINDOW_NAME.to_string()); + return; + } + + let logfile = self.logfiles_manager.logfiles_added[next_i].to_string(); + self.set_logfile_with_focus(logfile.clone()); + + if let Some(debug_logfile) = self.get_debug_dashboard_logfile() { + if logfile.eq(&debug_logfile) { + self.change_focus_next(); + } + } + } + + pub fn change_focus_previous(&mut self) { + if self.logfiles_manager.logfiles_added.len() == 0 { + return; + } + + let opt_debug_window = { + let opt = OPT.lock().unwrap(); + opt.debug_window + }; + + if self.dash_state.main_view == DashViewMain::DashDebug { + return; + } + + if self.dash_state.main_view == DashViewMain::DashSummary { + if self.dash_state.summary_window_heading_selected > 0 { + self.dash_state.summary_window_heading_selected -= 1; + self.update_summary_window(); + } + } + + let len = self.logfiles_manager.logfiles_added.len(); + let mut previous_i = len - 1; + for (i, name) in self.logfiles_manager.logfiles_added.iter().enumerate() { + if name == &self.logfile_with_focus { + if i > 0 { + previous_i = i - 1; + } + break; + } + } + + if opt_debug_window && previous_i == len - 1 && self.logfile_with_focus != DEBUG_WINDOW_NAME { + self.set_logfile_with_focus(DEBUG_WINDOW_NAME.to_string()); + return; + } + + let logfile = self.logfiles_manager.logfiles_added[previous_i].to_string(); + self.set_logfile_with_focus(logfile.clone()); + + if let Some(debug_logfile) = self.get_debug_dashboard_logfile() { + if logfile.eq(&debug_logfile) { + self.change_focus_previous(); + } + } + } + + pub fn change_focus_to(&mut self, logfile_index: usize) { + if logfile_index < self.logfiles_manager.logfiles_added.len() { + self.set_logfile_with_focus(self.logfiles_manager.logfiles_added[logfile_index].clone()); + self.dash_state.main_view = DashViewMain::DashNode; + } + } + + pub fn handle_arrow_up(&mut self) { + self.handle_arrow(false); + } + + pub fn handle_arrow_down(&mut self) { + self.handle_arrow(true); + } + + pub fn handle_arrow(&mut self, is_down: bool) { + if self.logfiles_manager.logfiles_added.len() == 0 { + return; + } + + let opt_debug_window = { + let opt = OPT.lock().unwrap(); + opt.debug_window + }; + + let list = match self.dash_state.main_view { + DashViewMain::DashSummary => Some(&mut self.dash_state.summary_window_rows), + DashViewMain::DashNode => { + if let Some(monitor) = self.get_monitor_with_focus() { + Some(&mut monitor.content) + } else if opt_debug_window { + Some(&mut self.dash_state.debug_window_list) + } else { + None + } + } + DashViewMain::DashHelp => None, + DashViewMain::DashDebug => { + if opt_debug_window { + Some(&mut self.dash_state.debug_window_list) + } else { + None + } + } + }; + + if let Some(list) = list { + do_bracketed_next_previous(list, is_down); + } + } + + pub fn preserve_node_selection(&mut self) { + if self.logfiles_manager.logfiles_added.len() == 0 { + return; + } + + if self.dash_state.main_view == DashViewMain::DashSummary { + if let Some(selected_index) = self.dash_state.summary_window_rows.state.selected() { + let selected_logfile = &self.dash_state.logfile_names_sorted[selected_index]; + if let Some(node_index) = self + .logfiles_manager + .logfiles_added + .iter() + .position(|s| s == selected_logfile.as_str()) + { + self.change_focus_to(node_index); + } + } + } else if self.dash_state.main_view == DashViewMain::DashNode { + for index in 0..self.dash_state.logfile_names_sorted.len() { + if self.dash_state.logfile_names_sorted[index] == self.logfile_with_focus { + self + .dash_state + .summary_window_rows + .state + .select(Some(index)); + break; + } + } + + if let Some(monitor) = self.get_monitor_with_focus() { + let selected_logfile = monitor.logfile.clone(); + if let Some(node_index) = self + .dash_state + .logfile_names_sorted + .iter() + .position(|s| s == selected_logfile.as_str()) + { + self + .dash_state + .summary_window_rows + .state + .select(Some(node_index)); + } + } + } + } + + // TODO this regenerates every line. May be worth just updating the line for the updated node/monitor + // Needs to be on the app to manage focus for DashSummary and DashNode through sorting of summary table + pub fn update_summary_window(&mut self) { + let current_selection = self.dash_state.summary_window_rows.state.selected(); + + self.dash_state.summary_window_rows = StatefulList::new(); + + // TODO could avoid this repeated copy by ensuring both are modified at the same time + self.dash_state.logfile_names_sorted = self + .logfiles_manager + .logfiles_added + .iter() + .map(|f| f.clone()) + .collect(); + + super::ui_summary_table::sort_nodes_by_column(&mut self.dash_state, &mut self.monitors); + + for i in 0..self.dash_state.logfile_names_sorted.len() { + let filepath = self.dash_state.logfile_names_sorted[i].clone(); + if let Some(monitor) = self.monitors.get_mut(&filepath) { + if !monitor.is_debug_dashboard_log { + monitor.metrics.update_node_status_string(); + let node_summary = super::ui_summary_table::format_table_row(&self.dash_state, monitor); + self.append_to_summary_window(&node_summary); + } + } + } + + self + .dash_state + .summary_window_rows + .state + .select(current_selection); + } + + fn append_to_summary_window(&mut self, text: &str) { + self + .dash_state + .summary_window_rows + .items + .push(text.to_string()); + + let len = self.dash_state.summary_window_rows.items.len(); + + if len > self.dash_state.max_summary_window { + self.dash_state.summary_window_rows.items = self + .dash_state + .summary_window_rows + .items + .split_off(len - self.dash_state.max_summary_window); + } else { + self + .dash_state + .summary_window_rows + .state + .select(Some(len - 1)); + } + } + + pub fn toggle_logfile_area(&mut self) { + self.dash_state.node_logfile_visible = !self.dash_state.node_logfile_visible; + } + + pub fn scale_timeline_up(&mut self) { + if self.dash_state.active_timescale == 0 { + return; + } + self.dash_state.active_timescale -= 1; + } + + pub fn scale_timeline_down(&mut self) { + if self.dash_state.active_timescale == TIMESCALES.len() - 1 { + return; + } + self.dash_state.active_timescale += 1; + } + + pub fn top_timeline_next(&mut self) { + if self.dash_state.top_timeline < APP_TIMELINES.len() { + self.dash_state.top_timeline += 1; + } else { + self.dash_state.top_timeline = 0; + } + } + + pub fn top_timeline_previous(&mut self) { + if self.dash_state.top_timeline > 0 { + self.dash_state.top_timeline -= 1; + } else { + self.dash_state.top_timeline = APP_TIMELINES.len() - 1; + } + } + + // Rotate UI display state through Min, Mean, Max values + pub fn bump_mmm_ui_mode(&mut self) { + self.dash_state.bump_mmm_ui_mode(); + } + + pub fn mmm_ui_mode(&mut self) -> &MinMeanMax { + return self.dash_state.mmm_ui_mode(); + } +} + +/// Move selection forward or back without wrapping at start or end +fn do_bracketed_next_previous(list: &mut StatefulList, next: bool) { + if next { + if let Some(selected) = list.state.selected() { + if selected != list.items.len() - 1 { + list.next(); + } + } else { + list.previous(); + } + } else { + if let Some(selected) = list.state.selected() { + if selected != 0 { + list.previous(); + } + } else { + list.previous(); + } + } +} + +fn exit_with_usage(reason: &str) -> Result { + eprintln!( + "Try '{} --help' for more information.", + Opt::clap().get_name() + ); + return Err(Error::new(ErrorKind::Other, reason)); +} + +const NODE_INACTIVITY_TIMEOUT_S: i64 = 20; // Seconds with no log message before node becomes 'inactive' + +pub struct LogMonitor { + pub index: usize, + pub content: StatefulList, + max_content: usize, // Limit number of lines in content + pub has_focus: bool, + pub logfile: String, + pub metrics: NodeMetrics, + pub metrics_status: StatefulList, + pub is_debug_dashboard_log: bool, + pub latest_checkpoint_time: Option>, +} + +use std::sync::atomic::{AtomicUsize, Ordering}; +static NEXT_MONITOR: AtomicUsize = AtomicUsize::new(0); + +fn next_unused_index(monitors: &mut HashMap) -> usize { + let mut next_index = 0; + + let mut index_unused = false; + while !index_unused { + next_index = NEXT_MONITOR.fetch_add(1, Ordering::Relaxed); + + index_unused = true; + for (_logfile, monitor) in monitors.iter() { + if next_index == monitor.index { + index_unused = false; + } + } + } + + next_index +} + +use super::logfile_checkpoints::LogfileCheckpoint; + +impl LogMonitor { + pub fn new(logfile_path: String) -> LogMonitor { + let mut is_debug_dashboard_log = false; + if let Some(debug_logfile) = &*DEBUG_LOGFILE.lock().unwrap() { + if let Some(debug_logfile_path) = debug_logfile.path().to_str() { + is_debug_dashboard_log = logfile_path.eq(debug_logfile_path); + } + } + + let opt_lines_max = { OPT.lock().unwrap().lines_max }; + LogMonitor { + index: 0, + logfile: logfile_path, + max_content: opt_lines_max, + metrics: NodeMetrics::new(), + content: StatefulList::with_items(vec![]), + has_focus: false, + metrics_status: StatefulList::with_items(vec![]), + is_debug_dashboard_log, + latest_checkpoint_time: None, + } + } + + /// Resolve any clash between self.index and index of other monitors which may happen + /// when mixing creation of new monitors with initialisation by restoring a checkpoint. + /// + /// For a restored checkpoint the metrics should be set, so if one has metrics and the other + /// doesn't, the former is treated as older and given the lower index. + pub fn canonicalise_monitor_index(&mut self, monitors: &mut HashMap) { + if self.index == 0 { + self.index = NEXT_MONITOR.fetch_add(1, Ordering::Relaxed); + } + + let existing_index = NEXT_MONITOR.fetch_add(0, Ordering::Relaxed); + let next_index = next_unused_index(monitors); + + let mut clash_monitor = None; + for (other_logfile, other) in monitors.iter_mut() { + if self.index == other.index && &self.logfile != other_logfile { + clash_monitor = Some(other); + } + } + + if let Some(other) = clash_monitor { + let mut lower_index = self.index; + let mut higher_index = next_index; + if lower_index > higher_index { + lower_index = next_index; + higher_index = self.index; + } + + // Default + self.index = higher_index; + other.index = lower_index; + + // If we know the earlier of the two metrics, use that to order the index in self and other + if let Some(self_start_time) = self.metrics.node_started { + let flip = if let Some(other_start_time) = other.metrics.node_started { + self_start_time < other_start_time + } else { + true + }; + if flip { + self.index = lower_index; + other.index = higher_index; + } + } + } else { + // next_index not used so restore state to avoid unnecessary increments + NEXT_MONITOR.store(existing_index, Ordering::Relaxed); + } + } + + pub fn is_node(&self) -> bool { + return !self.is_debug_dashboard_log; + } + + pub fn from_checkpoint(&mut self, checkpoint: &LogfileCheckpoint) { + self.index = checkpoint.monitor_index; + self.latest_checkpoint_time = checkpoint.latest_entry_time; + self.metrics = checkpoint.monitor_metrics.clone(); + } + + pub fn to_checkpoint(&mut self, checkpoint: &mut LogfileCheckpoint) { + checkpoint.latest_entry_time = self.latest_checkpoint_time; + checkpoint.monitor_index = self.index; + checkpoint.monitor_metrics = self.metrics.clone(); + } + + // TODO if speed is an issue look at speeding up: + // TODO - LogEntry::decode_metadata() + // TODO - finding first log entry to decode using a bisection search + pub fn load_logfile_from_time( + &mut self, + dash_state: &mut DashState, + after_time: Option>, + ) -> std::io::Result<()> { + if let Some(after_time) = after_time { + dash_state.vdash_status.message( + &format!("loading logfile after time: {}", after_time).to_string(), + None, + ); + } + + use std::io::{BufRead, BufReader}; + + let f = File::open(self.logfile.to_string()); + let f = match f { + Ok(file) => file, + Err(_e) => return Ok(()), // It's ok for a logfile not to exist yet + }; + + let f = BufReader::new(f); + + for line in f.lines() { + let line = line.expect("Unable to read line"); + self.append_to_content_from_time(dash_state, &line, after_time)?; + if self.is_debug_dashboard_log { + dash_state._debug_window(&line); + } + } + + if self.content.items.len() > 0 { + self + .content + .state + .select(Some(self.content.items.len() - 1)); + } + + Ok(()) + } + + pub fn append_to_content( + &mut self, + line: &str, + checkpoint_interval: u64, + ) -> Result { + self.metrics.parser_output = format!("LogMeta::decode_metadata() failed on: {}", line); // For debugging + // debug_log!(&self.parser_output.clone()); + + self.metrics.entry_metadata = LogEntry::decode_metadata(line); + + if self.metrics.entry_metadata.is_none() { + // debug_log!("gather_metrics() - skipping bec. metadata missing"); + return Ok("".to_string()); // Skip until start of first log message + } + + self._append_to_content(line)?; // Show in TUI + if self.is_debug_dashboard_log { + return Ok("".to_string()); + } + + self.metrics.gather_metrics(&line)?; + + if checkpoint_interval > 0 { + // Checkpoints disabled by zero interval + return self.update_checkpoint(checkpoint_interval); + } + + Ok("".to_string()) + } + + pub fn update_checkpoint(&mut self, checkpoint_interval: u64) -> Result { + if let Some(metadata) = &self.metrics.entry_metadata { + if self.latest_checkpoint_time.is_none() { + return save_checkpoint(self); + } else { + if let Some(latest_checkpoint_time) = self.latest_checkpoint_time { + if latest_checkpoint_time + Duration::seconds(checkpoint_interval as i64) + < metadata.message_time + { + return save_checkpoint(self); + } + } + } + } + + Ok("".to_string()) + } + + pub fn append_to_content_from_time( + &mut self, + _dash_state: &mut DashState, + line: &str, + after_time: Option>, + ) -> Result<(), std::io::Error> { + self.metrics.parser_output = format!("LogMeta::decode_metadata() failed on: {}", line); // For debugging + // debug_log!(&self.parser_output.clone()); + + if let Some(entry_metadata) = LogEntry::decode_metadata(line) { + if let Some(after_time) = after_time { + if !entry_metadata.message_time.gt(&after_time) { + return Ok(()); + } + } + + self.metrics.entry_metadata = Some(entry_metadata); + } else { + // debug_log!("gather_metrics() - skipping bec. metadata missing"); + if after_time.is_some() { + return Ok(()); + } + } + + self._append_to_content(line)?; // Show in TUI + if self.is_debug_dashboard_log { + return Ok(()); + } + + self.metrics.gather_metrics(&line)?; + + Ok(()) + } + + pub fn _append_to_content(&mut self, text: &str) -> Result<(), std::io::Error> { + self.content.items.push(text.to_string()); + let len = self.content.items.len(); + if len > self.max_content { + self.content.items = self.content.items.split_off(len - self.max_content); + } else { + self.content.state.select(Some(len - 1)); + } + Ok(()) + } +} + +use regex::Regex; +lazy_static::lazy_static! { + static ref LOG_LINE_PATTERN: Regex = + Regex::new(r"\[(?P[^ ]{27}) (?P[A-Z]{4,6}) (?P[^\]]*)\] (?P.*)").expect("The regex failed to compile. This is a bug."); +} + +#[derive(PartialEq, Clone, Default, Debug, Serialize, Deserialize)] +pub enum NodeStatus { + Started, + Connected, + #[default] + Stopped, + Shunned, +} + +pub fn node_status_as_string(node_status: &NodeStatus) -> String { + match node_status { + NodeStatus::Connected => "Connected".to_string(), + NodeStatus::Stopped => "Stopped".to_string(), + NodeStatus::Started => "Started".to_string(), + NodeStatus::Shunned => "SHUNNED".to_string(), + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct MmmStat { + sample_count: u64, + + pub most_recent: u64, + pub total: u64, + pub min: u64, + pub mean: u64, + pub max: u64, +} + +impl MmmStat { + pub fn new() -> MmmStat { + MmmStat { + sample_count: 0, + most_recent: 0, + total: 0, + min: u64::MAX, + mean: 0, + max: 0, + } + } + + pub fn add_sample(&mut self, value: u64) { + self.most_recent = value; + self.sample_count += 1; + self.total += value; + self.mean = self.total / self.sample_count; + + if self.min > value || self.min == u64::MAX { + self.min = value; + } + if self.max < value { + self.max = value; + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct NodeMetrics { + pub node_started: Option>, + pub running_message: Option, + pub running_version: Option, + pub node_process_id: Option, + pub node_peer_id: Option, + pub category_count: HashMap, + + pub app_timelines: AppTimelines, + + pub entry_metadata: Option, + pub node_status: NodeStatus, + pub node_bad_behaviour: String, + pub node_status_string: String, + pub node_inactive: bool, + + pub activity_gets: MmmStat, + pub activity_puts: MmmStat, + pub activity_errors: MmmStat, + pub nanos_earned: MmmStat, + pub storage_cost: MmmStat, + pub peers_connected: MmmStat, + pub memory_used_mb: MmmStat, + + pub wallet_balance: u64, + pub latest_earning: u64, + + pub records_stored: u64, + pub records_max: u64, + + pub shun_notifications: u64, + + pub system_cpu: f32, + pub system_memory: f32, + pub system_memory_used_mb: f32, + pub system_memory_usage_percent: f32, + + pub interface_name: String, + pub bytes_received: u64, + pub bytes_transmitted: u64, + pub total_mb_received: f32, + pub total_mb_transmitted: f32, + + pub cpu_usage_percent: f32, + pub cpu_usage_percent_max: f32, + pub bytes_read: u64, + pub bytes_written: u64, + pub total_mb_read: f32, + pub total_mb_written: f32, + + pub parser_output: String, +} + +impl NodeMetrics { + pub fn new() -> NodeMetrics { + let mut metrics = NodeMetrics { + // Start + node_started: None, + running_message: None, + running_version: None, + node_process_id: None, + node_peer_id: None, + + // Logfile entries + entry_metadata: None, + + // A predefined set of Timelines (Sparklines) + app_timelines: AppTimelines::new(), + + // Counts + category_count: HashMap::new(), + activity_gets: MmmStat::new(), + activity_puts: MmmStat::new(), + activity_errors: MmmStat::new(), + + // Storage Payments + nanos_earned: MmmStat::new(), + storage_cost: MmmStat::new(), + peers_connected: MmmStat::new(), + + // State (node) + node_status: NodeStatus::Stopped, + node_bad_behaviour: String::from(""), + node_status_string: String::from(""), + node_inactive: false, + + // State (network) + + // Wallet event: + wallet_balance: 0, + latest_earning: 0, + + // Storage use: + records_stored: 0, + records_max: 0, + + shun_notifications: 0, + + system_cpu: 0.0, + system_memory: 0.0, + system_memory_used_mb: 0.0, + system_memory_usage_percent: 0.0, + + interface_name: String::from("unknown"), + bytes_received: 0, + bytes_transmitted: 0, + total_mb_received: 0.0, + total_mb_transmitted: 0.0, + + memory_used_mb: MmmStat::new(), + cpu_usage_percent: 0.0, + cpu_usage_percent_max: 0.0, + bytes_read: 0, + bytes_written: 0, + total_mb_read: 0.0, + total_mb_written: 0.0, + + // Debug + parser_output: String::from("-"), + }; + metrics.update_timelines(&Utc::now()); + metrics + } + + pub fn is_node_active(&self) -> bool { + return !self.node_inactive; + } + + pub fn update_node_status_string(&mut self) { + let node_inactive_timeout = Duration::seconds(NODE_INACTIVITY_TIMEOUT_S); + + let mut node_status_string = node_status_as_string(&self.node_status); + + if self.node_status == NodeStatus::Shunned { + node_status_string = format!( + "Shunned x{} ({})", + self.shun_notifications, self.node_bad_behaviour + ); + } else if let Some(metadata) = &self.entry_metadata { + let idle_time = Utc::now() - metadata.system_time; + if idle_time > node_inactive_timeout { + self.node_inactive = true; + node_status_string = format!("INACTIVE ({})", get_duration_text(idle_time)); + } else { + self.node_inactive = false; + } + } + + self.node_status_string = node_status_string; + } + + fn reset_metrics(&mut self) { + self.node_status = NodeStatus::Started; + self.activity_gets = MmmStat::new(); + self.activity_puts = MmmStat::new(); + self.activity_errors = MmmStat::new(); + self.storage_cost = MmmStat::new(); + self.peers_connected = MmmStat::new(); + self.memory_used_mb = MmmStat::new(); + } + + ///! Process a line from a SAFE Node logfile. + ///! Use a created LogMeta to update metrics. + pub fn gather_metrics(&mut self, line: &str) -> Result<(), std::io::Error> { + let entry = LogEntry { + logstring: String::from(line), + }; + let entry_metadata = self.entry_metadata.as_ref().unwrap().clone(); + let entry_time = entry_metadata.message_time; + + debug_log!(format!("gather_metrics() entry_time: {:?}", entry_time).as_str()); + + self.update_timelines(&entry_time); + self.parser_output = entry_metadata.parser_output.clone(); + self.process_logfile_entry(&entry.logstring, &entry_metadata); // May overwrite self.parser_output + + // --debug-dashboard - prints parser results for a single logfile + // to a temp logfile which is displayed in the adjacent window. + debug_log!(&self.parser_output.clone()); + + Ok(()) + } + + pub fn update_timelines(&mut self, now: &DateTime) { + self.app_timelines.update_timelines(now); + } + + ///! Return a LogMeta and capture metadata for logfile node start: + ///! 'Running safenode v0.98.32' + pub fn parse_start(&mut self, line: &String, entry_metadata: &LogMeta) -> bool { + let running_prefix = String::from("Running safenode "); + + if line.starts_with(&running_prefix) { + self.set_node_status(NodeStatus::Started); + let message = line.to_string(); + let version = String::from(line[running_prefix.len()..].to_string()); + self.node_started = Some(entry_metadata.message_time); + self.parser_output = format!( + "START node {} at {}", + String::from(version.clone()), + self + .node_started + .map_or(String::from("None"), |m| format!("{}", m)) + ); + + self.running_message = Some(message); + self.running_version = Some(version); + self.reset_metrics(); + return true; + } + + let process_id_prefix = "Node (PID: "; + if line.contains(&process_id_prefix) { + self.node_process_id = self.parse_u64(process_id_prefix, line); + let process_id = match &self.node_process_id { + Some(process_id) => process_id.to_string(), + None => String::from("unknown"), + }; + + if let Some(peer_id) = self.parse_string("PeerId: ", line) { + self.parser_output = format!( + "Node pid: {} peer_id: {}", + String::from(process_id.clone()), + peer_id + ); + self.node_peer_id = Some(peer_id); + } + return true; + } + + false + } + + ///! Process a logfile entry + ///! Returns true if node is being shunned, or the line has been processed and can be discarded + pub fn process_logfile_entry(&mut self, line: &String, entry_metadata: &LogMeta) -> bool { + return self.parse_timed_data(&line, &entry_metadata.message_time) + || self.parse_states(&line, &entry_metadata) + || self.parse_start(&line, &entry_metadata); + } + + fn parse_timed_data(&mut self, line: &String, entry_time: &DateTime) -> bool { + if line.contains("Retrieved record from disk") { + self.count_get(&entry_time); + self.set_node_status(NodeStatus::Connected); + return true; + } else if line.contains("Wrote record") || line.contains("ValidSpendRecordPutFromNetwork") { + self.count_put(&entry_time); + self.set_node_status(NodeStatus::Connected); + return true; + } else if line.contains("Editing Register success") { + // TODO: no longer present, find new log message + self.count_put(&entry_time); + self.set_node_status(NodeStatus::Connected); + return true; + } else if line.contains("Cost is now") { + if let Some(storage_cost) = self.parse_u64("Cost is now ", line) { + // Ignore storage cost of zero as that means the record is already paid for + if storage_cost > 0 { + self.count_storage_cost(entry_time, storage_cost); + self.parser_output = format!("Storage cost: {}", storage_cost); + } + }; + return false; // Continue processing for records stored (parse_states()) + } else if line.contains("after earning ") { + if let Some(nanos_earned) = self.parse_u64("after earning ", line) { + self.count_nanos_earned(entry_time, nanos_earned); + self.parser_output = format!("Payment received: {}", nanos_earned); + return true; + }; + } else if line.contains("PeersInRoutingTable") { + let mut parser_output = String::from("connected peers:"); + if let Some(peers_connected) = self.parse_u64("PeersInRoutingTable(", line) { + self.count_peers_connected(entry_time, peers_connected); + parser_output = format!("{} {}", &parser_output, peers_connected); + }; + self.parser_output = parser_output; + return true; + } else if line.contains("consider us as BAD") { + let mut parser_output = String::from("Node being SHUNNED"); + self.set_node_status(NodeStatus::Shunned); + self.shun_notifications = self.shun_notifications + 1; + if let Some(bad_behaviour) = self.parse_string("due to \"", line) { + self.node_bad_behaviour = bad_behaviour.clone(); + parser_output = format!("Shunned due to '{}'", bad_behaviour); + }; + self.parser_output = parser_output; + return true; + } + return false; + } + + // Set status unless currently shunned + fn set_node_status(&mut self, new_status: NodeStatus) { + if self.node_status != NodeStatus::Shunned { + self.node_status = new_status; + } + } + + ///! Update data metrics from a handler response logfile entry + ///! Returns true if the line has been processed and can be discarded + fn parse_string(&mut self, prefix: &str, line: &String) -> Option { + let mut string = ""; + if let Some(mut string_start) = line.find(prefix) { + string_start += prefix.len(); + + if let Some(string_end) = line[string_start..].find("\"") { + string = line.as_str()[string_start..string_start + string_end].as_ref() + } else { + string = line.as_str()[string_start..].as_ref() + } + if string.is_empty() { + self.parser_output = format!("failed to parse string after {} in: {}", prefix, line); + } + }; + + if string.len() > 0 { + Some(String::from(string)) + } else { + None + } + } + + ///! Capture state updates from a logfile entry + ///! Returns true if the line has been processed and can be discarded + fn parse_states(&mut self, line: &String, entry_metadata: &LogMeta) -> bool { + if entry_metadata.category.eq("ERROR") { + self.count_error(&entry_metadata.message_time); + } + + let &content = &line.as_str(); + + // Node Status + if content.contains("Node events channel closed") { + self.set_node_status(NodeStatus::Stopped); + self.parser_output = String::from("Node status: Disconnected"); + return true; + } + + if content.contains("Cost is now") { + if let Some(records_stored) = self.parse_u64("records_stored: ", line) { + self.records_stored = records_stored; + self.parser_output = format!("Records stored: {}", records_stored); + }; + if let Some(records_max) = self.parse_u64("max_records: ", line) { + self.records_max = records_max; + self.parser_output = format!("{}, Max records: {}", self.parser_output, records_max); + }; + return true; + } + + // if content.contains("Skipping ") { + // let mut parser_output = String::from("Connected ({} lag)"); + // if let Some(events_skipped) = self.parse_usize("Skipping ", content) { + // parser_output = format!("{} ({})", &parser_output, events_skipped); + // }; + // self.parser_output = parser_output; + // return true; + // } + + // Metrics + if content.contains("sn_logging::metrics") { + // System + let mut parser_output = String::from("system_cpu_usage_percent:"); + if let Some(system_cpu) = self.parse_float32("system_cpu_usage_percent\":", content) { + self.system_cpu = system_cpu; + parser_output = format!("{} gl_cpu: {}", &parser_output, system_cpu); + }; + if let Some(system_memory) = self.parse_float32("system_total_memory_mb\":", content) { + self.system_memory = system_memory; + parser_output = format!("{} , System Memory: {}", &parser_output, system_memory); + }; + if let Some(system_memory_used_mb) = self.parse_float32("system_memory_used_mb\":", content) { + self.system_memory_used_mb = system_memory_used_mb; + parser_output = format!( + "{} , System Memory Use (MB): {}", + &parser_output, system_memory_used_mb + ); + }; + if let Some(system_memory_usage_percent) = + self.parse_float32("system_memory_usage_percent\":", content) + { + self.system_memory_usage_percent = system_memory_usage_percent; + parser_output = format!( + "{} , System Memory Use (%): {}", + &parser_output, system_memory_usage_percent + ); + }; + + // Networking + if let Some(interface_name) = self.parse_word("interface_name\":", content) { + self.interface_name = String::from(interface_name.clone()); + parser_output = format!("{} , interface_name: {}", &parser_output, interface_name); + }; + if let Some(bytes_received) = self.parse_u64("bytes_received\":", content) { + self.bytes_received = bytes_received; + parser_output = format!("{} , bytes_received: {}", &parser_output, bytes_received); + }; + if let Some(bytes_transmitted) = self.parse_u64("bytes_transmitted\":", content) { + self.bytes_transmitted = bytes_transmitted; + parser_output = format!( + "{} , bytes_transmitted: {}", + &parser_output, bytes_transmitted + ); + }; + if let Some(total_mb_received) = self.parse_float32("total_mb_received\":", content) { + self.total_mb_received = total_mb_received; + parser_output = format!( + "{} , total_mb_received: {}", + &parser_output, total_mb_received + ); + }; + if let Some(total_mb_transmitted) = self.parse_float32("total_mb_transmitted\":", content) { + self.total_mb_transmitted = total_mb_transmitted; + parser_output = format!( + "{} , total_mb_transmitted: {}", + &parser_output, total_mb_transmitted + ); + }; + + // Node Resources + if let Some(cpu_usage_percent) = self.parse_float32("\"cpu_usage_percent\":", content) { + self.cpu_usage_percent = cpu_usage_percent; + if cpu_usage_percent > self.cpu_usage_percent_max { + self.cpu_usage_percent_max = cpu_usage_percent; + } + parser_output = format!( + "{} cpu: {}, cpu_max {}", + &parser_output, cpu_usage_percent, self.cpu_usage_percent_max + ); + }; + if let Some(memory_used_mb) = self.parse_float32("\"memory_used_mb\":", content) { + self.count_memory_used_mb(&entry_metadata.message_time, memory_used_mb as u64); + parser_output = format!("{} , memory: {}", &parser_output, memory_used_mb); + }; + if let Some(bytes_read) = self.parse_u64("bytes_read\":", content) { + self.bytes_read = bytes_read; + parser_output = format!("{} , bytes_read: {}", &parser_output, bytes_read); + }; + if let Some(bytes_written) = self.parse_u64("bytes_written\":", content) { + self.bytes_written = bytes_written; + parser_output = format!("{} , bytes_written: {}", &parser_output, bytes_written); + }; + if let Some(total_mb_read) = self.parse_float32("total_mb_read\":", content) { + self.total_mb_read = total_mb_read; + parser_output = format!("{} , total_mb_read: {}", &parser_output, total_mb_read); + }; + if let Some(total_mb_written) = self.parse_float32("total_mb_written\":", content) { + self.total_mb_written = total_mb_written; + parser_output = format!( + "{} , total_mb_written: {}", + &parser_output, total_mb_written + ); + }; + + self.parser_output = parser_output; + return true; + } + + // Misc stats + if content.contains("The new wallet balance is") { + let mut parser_output = String::from(""); + + if let Some(wallet_balance) = self.parse_u64("wallet balance is ", content) { + self.wallet_balance = wallet_balance; + parser_output = format!("{} , wallet_balance: {}", &parser_output, wallet_balance); + }; + if let Some(latest_earning) = self.parse_u64("after earning ", content) { + self.latest_earning = latest_earning; + parser_output = format!("{} , latest_earning: {}", &parser_output, latest_earning); + }; + self.parser_output = parser_output; + return true; + } + false + } + + // fn parse_usize(&mut self, prefix: &str, content: &str) -> Option { + // if let Some(position) = content.find(prefix) { + // let word: Vec<&str> = content[position + prefix.len()..] + // .trim() + // .splitn(2, |c| c == ' ' || c == ',' || c== '}') + // .collect(); + // if word.len() > 0 { + // match word[0].parse::() { + // Ok(value) => return Some(value), + // Err(_e) => self.parser_output = format!("failed to parse '{}' as usize from: '{}'", word[0], &content[position + prefix.len()..]), + // } + // } + // } + // None + // } + + fn parse_u64(&mut self, prefix: &str, content: &str) -> Option { + if let Some(position) = content.find(prefix) { + let word: Vec<&str> = content[position + prefix.len()..] + .trim() + .splitn(2, |c| c == ' ' || c == ',' || c == '}' || c == ')') + .collect(); + if word.len() > 0 { + match word[0].parse::() { + Ok(value) => return Some(value), + Err(_e) => { + self.parser_output = format!( + "failed to parse '{}' as u64 from: '{}'", + word[0], + &content[position + prefix.len()..] + ) + } + } + } + } + None + } + + fn parse_float32(&mut self, prefix: &str, content: &str) -> Option { + if let Some(position) = content.find(prefix) { + let word: Vec<&str> = content[position + prefix.len()..] + .trim() + .splitn(2, |c| c == ' ' || c == ',' || c == '}') + .collect(); + if word.len() > 0 { + match word[0].parse::() { + Ok(value) => return Some(value), + Err(_e) => { + self.parser_output = format!( + "failed to parse '{}' as float from: '{}'", + word[0], + &content[position + prefix.len()..] + ) + } + } + } + } + None + } + + fn parse_word(&mut self, prefix: &str, content: &str) -> Option { + if let Some(start) = content.find(prefix) { + let word: Vec<&str> = content[start + prefix.len()..] + .trim_start() + .splitn(2, |c| c == ' ' || c == ',' || c == '}') + .collect(); + if word.len() > 0 { + return Some(word[0].to_string()); + } else { + self.parser_output = format!("failed to parse word at: '{}'", &content[start..]); + } + } + None + } + + fn count_get(&mut self, time: &DateTime) { + self.activity_gets.add_sample(1); + self.apply_timeline_sample(GETS_TIMELINE_KEY, time, 1); + } + + fn count_put(&mut self, time: &DateTime) { + self.activity_puts.add_sample(1); + self.apply_timeline_sample(PUTS_TIMELINE_KEY, time, 1); + } + + fn count_error(&mut self, time: &DateTime) { + self.activity_errors.add_sample(1); + self.apply_timeline_sample(ERRORS_TIMELINE_KEY, time, 1); + } + + fn count_nanos_earned(&mut self, time: &DateTime, nanos_earned: u64) { + self.nanos_earned.add_sample(nanos_earned); + self.apply_timeline_sample(EARNINGS_TIMELINE_KEY, time, nanos_earned); + } + + fn count_storage_cost(&mut self, time: &DateTime, storage_cost: u64) { + self.storage_cost.add_sample(storage_cost); + self.apply_timeline_sample(STORAGE_COST_TIMELINE_KEY, time, storage_cost); + } + + fn count_peers_connected(&mut self, time: &DateTime, connections: u64) { + self.peers_connected.add_sample(connections); + self.apply_timeline_sample(CONNECTIONS_TIMELINE_KEY, time, connections); + } + + fn count_memory_used_mb(&mut self, time: &DateTime, memory_used_mb: u64) { + self.memory_used_mb.add_sample(memory_used_mb); + self.apply_timeline_sample(RAM_TIMELINE_KEY, time, memory_used_mb); + } + + fn apply_timeline_sample(&mut self, timeline_key: &str, time: &DateTime, value: u64) { + if let Some(timeline) = self.app_timelines.get_timeline_by_key(timeline_key) { + timeline.update_value(time, value); + } + } +} + +///! Metadata for a logfile line +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct LogMeta { + pub category: String, // First word ('INFO', 'WARN' etc.) + pub message_time: DateTime, + pub system_time: DateTime, + pub source: String, + pub message: String, + + pub parser_output: String, +} + +impl LogMeta { + pub fn clone(&self) -> LogMeta { + LogMeta { + category: self.category.clone(), + message_time: self.message_time, + system_time: self.system_time, + source: self.source.clone(), + message: self.message.clone(), + parser_output: self.parser_output.clone(), + } + } +} + +///! Used to build a history of what is in the log, one LogMeta per line +pub struct LogEntry { + pub logstring: String, // One line of raw text from the logfile +} + +impl LogEntry { + ///! Decode metadata from logfile line when present. Example input lines: + ///! " INFO 2022-01-15T20:21:02.659471Z [sn/src/node/routing/core/mod.rs:L211]:" + ///! " ➤ Writing our latest PrefixMap to disk" + ///! " ERROR 2022-01-15T20:21:07.643598Z [sn/src/node/routing/api/dispatcher.rs:L450]:" + fn decode_metadata(line: &str) -> Option { + if line.is_empty() { + return None; + } + + if let Some(captures) = LOG_LINE_PATTERN.captures(line) { + let category = captures.name("category").map_or("", |m| m.as_str()); + let time_string = captures.name("time_string").map_or("", |m| m.as_str()); + let source = captures.name("source").map_or("", |m| m.as_str()); + let message = captures.name("message").map_or("", |m| m.as_str()); + let time_str: String; + + let time_utc: DateTime; + + match DateTime::parse_from_str(time_string, "%+") { + Ok(time) => { + time_utc = time.with_timezone(&Utc); + time_str = format!("{}", time); + } + Err(e) => { + debug_log!(format!("ERROR parsing logfile time: {}", e).as_str()); + return None; + } + }; + let parser_output = format!( + "c: {}, t: {}, s: {}, m: {}", + category, time_str, source, message + ); + + return Some(LogMeta { + category: String::from(category), + message_time: time_utc, + system_time: Utc::now(), + source: String::from(source), + message: String::from(message), + parser_output, + }); + } + None + } +} + +///! Active UI at top level +#[derive(PartialEq, Clone, Copy)] +pub enum DashViewMain { + DashSummary, + DashNode, + DashHelp, + DashDebug, +} + +pub struct DashState { + pub vdash_status: StatusMessage, + pub main_view: DashViewMain, + pub previous_main_view: DashViewMain, + pub logfile_names_sorted: Vec, + pub logfile_names_sorted_ascending: bool, + + pub currency_symbol: String, + pub currency_per_token: Option, + pub ui_uses_currency: bool, + + pub active_timescale: usize, + pub node_logfile_visible: bool, + pub dash_node_focus: String, + pub mmm_ui_mode: MinMeanMax, + pub top_timeline: usize, // Timeline to show at top of UI + + pub summary_window_heading: String, // TODO delete in favour of... + pub summary_window_headings: StatefulList, + pub summary_window_heading_selected: usize, + pub summary_window_rows: StatefulList, + max_summary_window: usize, + + pub help_status: StatefulList, + + // For --debug-window option + pub debug_window_list: StatefulList, + pub debug_window: bool, + pub debug_window_has_focus: bool, + max_debug_window: usize, +} + +const UI_STATUS_DEFAULT_MESSAGE: &str = "Press '?' for Help"; +const UI_STATUS_DEFAULT_DURATION_S: i64 = 5; +use super::ui_status::StatusMessage; + +impl DashState { + pub fn new() -> DashState { + let mut new_dash = DashState { + vdash_status: StatusMessage::new( + &String::from(UI_STATUS_DEFAULT_MESSAGE), + &Duration::seconds(UI_STATUS_DEFAULT_DURATION_S), + ), + + main_view: DashViewMain::DashSummary, + previous_main_view: DashViewMain::DashSummary, + logfile_names_sorted: Vec::::new(), // Sorted by column + logfile_names_sorted_ascending: true, + + currency_symbol: String::from(""), + currency_per_token: None, + ui_uses_currency: false, + + active_timescale: 0, + node_logfile_visible: true, + dash_node_focus: String::new(), + mmm_ui_mode: MinMeanMax::Mean, + top_timeline: 0, + + summary_window_heading: String::from(""), + summary_window_headings: StatefulList::new(), + summary_window_heading_selected: 0, + summary_window_rows: StatefulList::new(), + max_summary_window: 1000, + + help_status: StatefulList::with_items(vec![]), + + debug_window: false, + debug_window_has_focus: false, + debug_window_list: StatefulList::new(), + max_debug_window: 100, + }; + super::ui_summary_table::initialise_summary_headings(&mut new_dash); + new_dash + } + + pub fn _debug_window(&mut self, text: &str) { + self.debug_window_list.items.push(text.to_string()); + let len = self.debug_window_list.items.len(); + + if len > self.max_debug_window { + self.debug_window_list.items = self + .debug_window_list + .items + .split_off(len - self.max_debug_window); + } else { + self.debug_window_list.state.select(Some(len - 1)); + } + } + + pub fn get_active_timescale_name(&self) -> Option<&'static str> { + return match TIMESCALES.get(self.active_timescale) { + None => { + // debug_log!("ERROR getting active timescale name"); + return None; + } + Some((name, _)) => Some(name), + }; + } + + // Rotate UI display state through Min, Mean, Max values + pub fn bump_mmm_ui_mode(&mut self) { + match &self.mmm_ui_mode { + MinMeanMax::Min => self.mmm_ui_mode = MinMeanMax::Mean, + MinMeanMax::Mean => self.mmm_ui_mode = MinMeanMax::Max, + MinMeanMax::Max => self.mmm_ui_mode = MinMeanMax::Min, + } + } + + pub fn top_timeline_index(&self) -> usize { + return self.top_timeline; + } + pub fn mmm_ui_mode(&self) -> &MinMeanMax { + &self.mmm_ui_mode + } +} + +pub struct DashVertical { + _active_view: usize, +} + +impl DashVertical { + pub fn new() -> Self { + DashVertical { _active_view: 0 } + } +} + +pub fn set_main_view(view: DashViewMain, app: &mut App) { + if app.dash_state.main_view == view { + return; + } + + app.dash_state.previous_main_view = app.dash_state.main_view; + save_focus(app); + app.dash_state.main_view = view; + restore_focus(app); +} + +pub fn save_focus(app: &mut App) { + match app.dash_state.main_view { + DashViewMain::DashHelp => {} + + DashViewMain::DashSummary | DashViewMain::DashNode => { + if let Some(focus) = app.get_logfile_with_focus() { + app.dash_state.dash_node_focus = focus; + } + } + DashViewMain::DashDebug => {} + } +} + +pub fn restore_focus(app: &mut App) { + match app.dash_state.main_view { + DashViewMain::DashHelp => {} + + DashViewMain::DashSummary | DashViewMain::DashNode => { + app.set_logfile_with_focus(app.dash_state.dash_node_focus.clone()) + } + DashViewMain::DashDebug => { + if let Some(debug_logfile) = app.get_debug_dashboard_logfile() { + app.set_logfile_with_focus(debug_logfile); + } + } + } +} +#[cfg(test)] +mod tests { + + mod log_parsing { + use std::str::FromStr; + + use chrono::{DateTime, Utc}; + + use crate::custom::app::LogEntry; + + #[test] + fn it_parses() { + let message_time = "2024-03-23T19:38:32.350118Z"; + let source = "sn_networking::event"; + let category = "WARN"; + let message = "MsgReceivedError: InternalMsgChannelDropped"; + let line = format!("[{} {} {}] {}", message_time, category, source, message); + let metadata = LogEntry::decode_metadata(&line).unwrap(); + + let message_time: DateTime = DateTime::from_str(message_time).unwrap(); + + assert_eq!(metadata.category, category); + assert_eq!(metadata.message_time, message_time); + assert_eq!(metadata.source, source); + assert_eq!(metadata.message, message); + } + } +} diff --git a/src/custom/app_timelines.rs b/src/custom/app_timelines.rs new file mode 100644 index 0000000..24b2dfe --- /dev/null +++ b/src/custom/app_timelines.rs @@ -0,0 +1,100 @@ +use std::collections::HashMap; + +use serde::{Serialize, Deserialize}; +use chrono::{DateTime, Duration, Utc}; +use ratatui::style::Color; + +use super::app::OPT; +use super::timelines::{Timeline, Buckets}; + +lazy_static::lazy_static! { + pub static ref TIMESCALES: std::vec::Vec<(&'static str, Duration)> = vec!( + ("1 second columns", Duration::seconds(1)), + ("1 minute columns", Duration::minutes(1)), + ("1 hour columns", Duration::hours(1)), + ("1 day columns", Duration::days(1)), + ("1 week columns", Duration::days(7)), + ("1 year columns", Duration::days(365)), + ); +} + +pub const EARNINGS_UNITS_TEXT: &str = "nanos"; +pub const STORAGE_COST_UNITS_TEXT: &str = "nanos/MB"; + +/// keys (used to access timelines) +pub const EARNINGS_TIMELINE_KEY: &str = "earnings"; +pub const STORAGE_COST_TIMELINE_KEY: &str = "storage"; +pub const PUTS_TIMELINE_KEY: &str = "puts"; +pub const GETS_TIMELINE_KEY: &str = "gets"; +pub const CONNECTIONS_TIMELINE_KEY: &str = "connections"; +pub const RAM_TIMELINE_KEY: &str = "ram"; +pub const ERRORS_TIMELINE_KEY: &str = "errors"; + +/// Defines the Timelines available for display +pub const APP_TIMELINES: [(&str, &str, &str, bool, bool, Color); 7] = [ +// (key, UI name, units_text, is_mmm, is_cumulative, colour) + (EARNINGS_TIMELINE_KEY, "Earnings", EARNINGS_UNITS_TEXT, false, true, Color::LightCyan), + (STORAGE_COST_TIMELINE_KEY, "Storage Cost", STORAGE_COST_UNITS_TEXT, true, false, Color::LightBlue), + (PUTS_TIMELINE_KEY, "PUTS", "",false, true, Color::Yellow), + (GETS_TIMELINE_KEY, "GETS", "", false, true, Color::Green), + (CONNECTIONS_TIMELINE_KEY, "Connections", "", true, false, Color::Blue), + (RAM_TIMELINE_KEY, "RAM", "MB", true, false, Color::Magenta), + (ERRORS_TIMELINE_KEY, "ERRORS", "", false, true, Color::Red), +]; + +/// Holds the Timeline structs for a node, as used by this app +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +pub struct AppTimelines { + timelines: HashMap, +} + +impl AppTimelines { + + pub fn new() -> AppTimelines { + let opt_timeline_steps = { let opt = OPT.lock().unwrap(); opt.timeline_steps }; + + let mut app_timelines = AppTimelines { + timelines: HashMap::::new(), + }; + + for (key, name, units_text, is_mmm, is_cumulative, colour) in APP_TIMELINES { + app_timelines.timelines.insert(key.to_string(), Timeline::new(name.to_string(), units_text.to_string(), is_mmm, is_cumulative, colour)); + } + + for (_, timeline) in app_timelines.timelines.iter_mut() { + for i in 0..TIMESCALES.len() { + if let Some(spec) = TIMESCALES.get(i) { + timeline.add_bucket_set(spec.0, spec.1, opt_timeline_steps); + } + } + } + + return app_timelines; + } + + pub fn update_timelines(&mut self, now: &DateTime) { + for (_, timeline) in self.timelines.iter_mut() { + timeline.update_current_time(&now); + } + } + + pub fn get_timeline_by_key(&mut self, key: &str) -> Option<&mut Timeline> { + return self.timelines.get_mut(key); + } + + pub fn get_timeline_by_index(&self, index: usize) -> Option<&Timeline> { + let (key, _, _, _, _, _) = APP_TIMELINES[index]; + return self.timelines.get(key); + } + + // Gets the set of buckets for the index'th Timeline, selecting with Min, Mean, Max if appropriate + pub fn get_timeline_buckets(&mut self, index: usize, timescale_name: &str) -> Option<&Buckets> { + let (key, _, _, _, _, _) = APP_TIMELINES[index]; + if let Some(timeline) = self.timelines.get_mut(key) { + return timeline.get_bucket_set(timescale_name); + } + return None; + } + + pub fn get_num_timelines(self: &AppTimelines) -> usize { return APP_TIMELINES.len(); } +} \ No newline at end of file diff --git a/src/custom/logfile_checkpoints.rs b/src/custom/logfile_checkpoints.rs new file mode 100644 index 0000000..472de53 --- /dev/null +++ b/src/custom/logfile_checkpoints.rs @@ -0,0 +1,89 @@ + +use std::fs::{self}; +use std::io::{Error, ErrorKind}; +use std::path::PathBuf; + +use serde::{Serialize, Deserialize}; +use serde_json; +use chrono::{DateTime, Utc}; + +use super::app::{LogMonitor, NodeMetrics}; + +const CHECKPOINT_EXT: &str = "vdash"; +const CHECKPOINT_TMP_EXT: &str = "vdash-tmp"; + +pub fn save_checkpoint(monitor: &mut LogMonitor) -> Result { + let mut checkpoint_tmp_path = PathBuf::from(&monitor.logfile); + if !checkpoint_tmp_path.set_extension(CHECKPOINT_TMP_EXT) { + return Err(Error::new(ErrorKind::Other, "checkpoint set_extension() failed")); + } + + let last_entry_time = if let Some(metadata) = &monitor.metrics.entry_metadata { + Some(metadata.message_time) + } else { + None + }; + + let mut checkpoint = LogfileCheckpoint::new(); + monitor.to_checkpoint(&mut checkpoint); + checkpoint.latest_entry_time = last_entry_time; + + let checkpoint_string = serde_json::to_string(&checkpoint).unwrap(); + match fs::write(checkpoint_tmp_path.clone(), checkpoint_string) { + Ok(_) => { + let mut checkpoint_path = PathBuf::from(&monitor.logfile); + if checkpoint_path.set_extension(CHECKPOINT_EXT) && fs::rename(checkpoint_tmp_path, checkpoint_path.clone()).is_ok() { + monitor.latest_checkpoint_time = last_entry_time; + return Ok("Checkpoint updated".to_string()); + } else { + return Err(Error::new(ErrorKind::Other, format!("FAILED to rename checkpoint to '{:?}'", checkpoint_path.as_os_str()).as_str())); + } + }, + Err(e) => return Err(e), + }; +} + +/// Look for and attempt to update metrics from a checkpoint +/// Returns Ok() if the checkpoint was found and restored +pub fn restore_checkpoint(monitor: &mut LogMonitor) -> Result { + let mut checkpoint_path = PathBuf::from(&monitor.logfile); + if !checkpoint_path.set_extension(CHECKPOINT_EXT) { + return Err(Error::new(ErrorKind::Other, "checkpoint set_extension() failed")); + } + + let mut checkpoint = LogfileCheckpoint::new(); + monitor.to_checkpoint(&mut checkpoint); + + match fs::read_to_string(&checkpoint_path) { + Ok(checkpoint_string) => { + match serde_json::from_str(checkpoint_string.as_str()) { + Ok(checkpoint) => monitor.from_checkpoint(&checkpoint), + + // TODO could be versioning issue (e.g. any change in serialized structs) + // TODO maybe report so user can delete invalid checkpoint file + Err(e) => return Err(Error::new(ErrorKind::Other, e.to_string())), + }; + }, + // Suppress console error message when checkpoint file is not found + Err(_e) => return Err(Error::new(ErrorKind::Other, "")), // No checkpoint file found + } + + Ok(format!("checkpoint restored from: {:?}", checkpoint_path.as_os_str())) +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct LogfileCheckpoint { + pub latest_entry_time: Option>, + pub monitor_index: usize, + pub monitor_metrics: NodeMetrics, +} + +impl LogfileCheckpoint { + pub fn new() -> LogfileCheckpoint { + LogfileCheckpoint { + latest_entry_time: None, + monitor_index: 0, + monitor_metrics: NodeMetrics::new(), + } + } +} diff --git a/src/custom/logfiles_manager.rs b/src/custom/logfiles_manager.rs new file mode 100644 index 0000000..e9b4ab3 --- /dev/null +++ b/src/custom/logfiles_manager.rs @@ -0,0 +1,130 @@ +use linemux::MuxedLines; +use std::collections::HashMap; +use glob::glob; + +use crate::custom::app::{LogMonitor, DashState}; + +pub struct LogfilesManager { + pub logfiles_added: Vec, + pub globpaths: Vec, + + pub logfiles_monitored: Vec, // Paths to all logfiles being monitored + pub logfiles_failed: Vec, // Paths to any files which failed to begin monitoring + + pub linemux_files: MuxedLines, +} + +// TODO maybe add UI for display of lists (paths/globpaths/failed paths) +// TODO maybe add UI for adding paths/globpaths interactively +impl LogfilesManager { + pub fn new(globpaths: Vec) -> LogfilesManager { + match MuxedLines::new() { + Ok(linemux) => return LogfilesManager { + logfiles_added: Vec::new(), + globpaths: globpaths, + + logfiles_monitored: Vec::new(), + logfiles_failed: Vec::new(), + + linemux_files: linemux, + }, + + Err(e) => panic!("Initialisation failed at MuxedLines::new(): {}", e) + } + } + + pub async fn monitor_multi_paths(&mut self, filepaths: Vec, monitors: &mut HashMap, dash_state: &mut DashState, disable_status: bool) { + if !disable_status { dash_state.vdash_status.message(&format!("Loading {} files...", filepaths.len()), None); } + for f in &filepaths { + self.monitor_path(&f.to_string(), monitors, dash_state, disable_status).await; + } + } + + pub async fn scan_multi_globpaths(&mut self, globpaths: Vec, monitors: &mut HashMap, dash_state: &mut DashState, disable_status: bool) { + if !disable_status { dash_state.vdash_status.message(&format!("Scanning {} globpaths...", globpaths.len()), None); } + for f in &globpaths { + self.scan_globpath(f.to_string(), monitors, dash_state, disable_status).await; + } + } + + // Attempts to setup a LogMonitor for the logfile at fullpath + pub async fn monitor_path(&mut self, fullpath: &String, monitors: &mut HashMap, dash_state: &mut DashState, disable_status: bool) { + if self.logfiles_added.contains(&fullpath) { + return; + } + + if !disable_status { dash_state.vdash_status.message(&format!("file: {}", &fullpath), None); } + + let mut monitor = LogMonitor::new( fullpath.to_string()); + + let checkpoint_result = super::logfile_checkpoints::restore_checkpoint(&mut monitor); + + let checkpoint_was_restored = match checkpoint_result { + Ok(message) => { + if message.len() > 0 { + if !disable_status { dash_state.vdash_status.message(&format!("{}", &message), None); } + }; + true + }, + Err(e) => { + let message = &e.to_string(); + if message.len() > 0 && !disable_status { dash_state.vdash_status.message(&format!("{}", message), None); } + false // TODO note: do I need to handle version errors in some way? (due to change in serialised struct) + } + }; + + let result = if super::app::OPT.lock().unwrap().ignore_existing { + self.linemux_files.add_file(fullpath).await + } else { + if checkpoint_was_restored { + match monitor.load_logfile_from_time(dash_state, monitor.latest_checkpoint_time) { + Ok(_) => self.linemux_files.add_file(fullpath).await, + Err(e) => Err(e), + } + } else { + match monitor.load_logfile_from_time(dash_state, None) { + Ok(_) => self.linemux_files.add_file(fullpath).await, + Err(e) => Err(e), + } + + // // This method is 25% slower or worse + // self.linemux_files.add_file_from_start(fullpath).await + } + }; + + match result { + Ok(_) => { + monitor.canonicalise_monitor_index(monitors); + monitors.insert(fullpath.to_string(), monitor); + if !self.logfiles_added.contains(&fullpath) { self.logfiles_added.push(fullpath.to_string()); } + if let Some(index) = self.logfiles_failed.iter().position(|s| s == fullpath.as_str()) { + self.logfiles_failed.remove(index); + } + } + Err(e) => { + if !self.logfiles_failed.contains(&fullpath) { self.logfiles_failed.push(fullpath.to_string()); } + eprintln!("...load failed: {}", e); + eprintln!( "Note: it is ok for the file not to exist, but the file's parent directory must exist." ); + } + } + } + + /// Scans (or re-scans) the globpath and attempts to setup LogMonitors for any files found + pub async fn scan_globpath(&mut self, globpath: String, monitors: &mut HashMap, dash_state: &mut DashState, disable_status: bool) { + if !disable_status { dash_state.vdash_status.message(&format!("globpath: {}", globpath), None); } + + let paths_to_scan = globpath.clone(); + if !self.globpaths.contains(&globpath) { self.globpaths.push(globpath) } + + for entry in glob(paths_to_scan.as_str()).unwrap() { + match entry { + Ok(path) => { + if let Some(filepath) = path.to_str() { + self.monitor_path(&filepath.to_string(), monitors, dash_state, disable_status).await + } + }, + Err(e) => eprintln!("...globpath failed: {}", e), + } + } + } +} \ No newline at end of file diff --git a/src/custom/mod.rs b/src/custom/mod.rs new file mode 100644 index 0000000..e27bd98 --- /dev/null +++ b/src/custom/mod.rs @@ -0,0 +1,15 @@ +pub mod app; +pub mod app_timelines; +pub mod logfile_checkpoints; +pub mod logfiles_manager; +pub mod opt; +pub mod timelines; +pub mod web_requests; +pub mod ui; +pub mod ui_debug; +pub mod ui_help; +pub mod ui_keyboard; +pub mod ui_node; +pub mod ui_summary_table; +pub mod ui_summary; +pub mod ui_status; diff --git a/src/custom/opt.rs b/src/custom/opt.rs new file mode 100644 index 0000000..9637303 --- /dev/null +++ b/src/custom/opt.rs @@ -0,0 +1,83 @@ +///! Command line options and usage + +pub static MIN_TIMELINE_STEPS: usize = 10; + +pub use structopt::StructOpt; + +#[derive(StructOpt, Debug)] +#[structopt( + about = "Monitor Safe Network nodes in the terminal.\nNavigate using tab and arrow keys." +)] +pub struct Opt { + /// Maximum number of lines to keep for each logfile + #[structopt(short = "l", long, default_value = "100")] + pub lines_max: usize, + + /// Event update tick in milliseconds + #[structopt(long, default_value = "200")] + pub tick_rate: u64, + + /// Steps (width) of each timeline, helps tweak right justification. + #[structopt(short, long, default_value = "210")] + pub timeline_steps: usize, + + /// Ignore any existing logfile content + #[structopt(short, long)] + pub ignore_existing: bool, + + /// A *nix 'glob' path to match multiple files. + /// Can be provided multiple times as here: + /// + /// vdash -g "$HOME/.local/share/safe/node/**/safenode.log" -g "./remote-node-logs/*/logs/safenode.log" + #[structopt(name="glob-path", short, long, multiple=true)] + pub glob_paths: Vec, + + /// Enable periodic scan of any glob paths every so many seconds. 0 to disable. + #[structopt(long, default_value = "0")] + pub glob_scan: i64, + + /// Set checkpoint interval in seconds. 0 to disable checkpoints. + #[structopt(long, default_value = "300")] + pub checkpoint_interval: u64, + + /// Token conversion rate as a positive floating point number (e.g. 3.345) + /// This will be used if the price APIs are not used or failing. + #[structopt(long, default_value = "-1")] + pub currency_token_rate: f64, + + /// Fiat currency name for API + #[structopt(long, default_value = "USD")] + pub currency_apiname: String, + + /// Single character symbol for currency (e.g. "£" or "€") + #[structopt(long, default_value = "$")] + pub currency_symbol: String, + + /// Coingecko.com API key + #[structopt(long)] + pub coingecko_key: Option, + + /// Coingecko.com API polling interval (minutes) + #[structopt(long, default_value = "30")] + pub coingecko_interval: usize, + + /// Coinmarketcap.com API key + #[structopt(long)] + pub coinmarketcap_key: Option, + + /// Coinmarketcap.com API polling interval (minutes) + #[structopt(long, default_value = "30")] + pub coinmarketcap_interval: usize, + + /// One or more logfiles to monitor + #[structopt(name = "LOGFILE")] + pub files: Vec, + + /// Parses first logfile *only* and adds a debug output window (accessed with l/r arrow) + /// Also shows smaller debug output window to the right of the node view for the logfile + #[structopt(short, long)] + pub debug_window: bool, +} + +pub fn get_app_name() -> String { String::from(Opt::clap().get_name()) } +pub fn get_app_version() -> String { String::from(structopt::clap::crate_version!()) } diff --git a/src/custom/timelines.rs b/src/custom/timelines.rs new file mode 100644 index 0000000..cfffb00 --- /dev/null +++ b/src/custom/timelines.rs @@ -0,0 +1,378 @@ +use std::collections::HashMap; +use chrono::{DateTime, Duration, Utc}; +use ratatui::style::Color; + +use crate::custom::app::debug_log; + +pub fn get_duration_text(duration: Duration) -> String { + return if duration.num_weeks() > 104 { format!("{} years", duration.num_days()/365) } else if + duration.num_weeks() > 4 { format!("{} weeks", duration.num_weeks()) } else if + duration.num_hours() > 48 { format!("{} days", duration.num_days()) } else if + duration.num_hours() > 2 { format!("{} hrs", duration.num_hours()) } else if + duration.num_minutes() > 5 { format!("{} min", duration.num_minutes()) } else + { format!("{} sec", duration.num_seconds()) }; +} + +pub fn get_max_buckets_value(buckets: &Vec) -> u64 { + let mut max: u64 = 0; + for i in 0 .. buckets.len() - 1 { + if buckets[i] > max { max = buckets[i]; } + } + return max; +} + +pub fn get_min_buckets_value(buckets: &Vec) -> u64 { + let mut min: u64 = u64::MAX; + for i in 0 .. buckets.len() - 1 { + if buckets[i] > 0 && buckets[i] < min { min = buckets[i]; } + } + return min; +} + +///! Maintains one or more 'marching bucket' histories for +///! a given metric, each with its own duration and granularity. +///! +///! A Buckets is used to hold the history of values with +///! a given bucket_duration and maximum number of buckets. +///! +///! A Buckets begins with a single bucket of fixed +///! duration holding the initial metric value. New buckets +///! are added as time progresses until the number of buckets +///! covers the total duration of the Buckets. At this +///! point the oldest bucket is removed when a new bucket is +///! added, so that the total duration remains constant and +///! the specified maximum number of buckets is never +///! exceeded. +///! +///! By adding more than one Buckets, a given metric can be +///! recorded for different durations and with different +///! granularities. E.g. 60 * 1s buckets covers a minute +///! and 60 * 1m buckets covers an hour, and so on. +///! +///! TimelineMMM and BucketsMMM are similar structs which +///! implement timelines of min, mean and max values for +///! a given metric. + +/// Specify min, mean, max series (as opposed to value series) +#[derive(Default)] +pub enum MinMeanMax { + #[default] + Min = 1, + Mean = 2, + Max = 3, +} + +use serde::{Serialize, Deserialize}; +use serde_with; + +#[derive(Clone, Debug, Serialize, Deserialize)]pub struct Timeline { + pub name: String, + pub units_text: String, + pub is_mmm: bool, + pub is_cumulative: bool, + pub colour: Color, + + pub last_non_zero_value: u64, + buckets: HashMap, +} + +impl Timeline { + pub fn new(name: String, units_text: String, is_mmm: bool, is_cumulative: bool, colour: Color) -> Timeline { + Timeline { + name, + units_text, + is_mmm, + is_cumulative, + buckets: HashMap::::new(), + last_non_zero_value: 0, + colour, + } + } + + pub fn get_name(&self) -> &String { + &self.name + } + + pub fn add_bucket_set(&mut self, name: &'static str, duration: Duration, num_buckets: usize) { + self.buckets + .insert(name.to_string(), Buckets::new(duration, num_buckets, self.is_mmm)); + } + + pub fn get_bucket_set(&self, timescale_name: &str) -> Option<&Buckets> { + return self.buckets.get(timescale_name); + } + + pub fn get_bucket_set_mut(&mut self, timescale_name: &str) -> Option<&mut Buckets> { + return self.buckets.get_mut(timescale_name); + } + + pub fn get_buckets_mut(&mut self, timescale_name: &str, mmm_ui_mode: Option<&MinMeanMax>) -> Option<&Vec> { + if let Some(bucket_set) = self.buckets.get(timescale_name) { + return Some(bucket_set.buckets(mmm_ui_mode)); + } else { + return None; + } + } + + pub fn get_buckets(&self, timescale_name: &str, mmm_ui_mode: Option<&MinMeanMax>) -> Option<&Vec> { + if let Some(bucket_set) = self.buckets.get(timescale_name) { + return Some(bucket_set.buckets(mmm_ui_mode)); + } else { + return None; + } + } + + ///! Update all Buckets with new current time + ///! + ///! Call significantly more frequently than the smallest Buckets duration + pub fn update_current_time(&mut self, new_time: &DateTime) { + // debug_log!(format!("timeline::update_current_time() new_time: {:?}", new_time).as_str()); + for (_name, bs) in self.buckets.iter_mut() { + bs.update_current_time(new_time, self.is_cumulative); + } + } + + pub fn update_value(&mut self, time: &DateTime, value: u64) { + // debug_log!("update_value()"); + + if value > 0 {self.last_non_zero_value = value;} + for (_name, bs) in self.buckets.iter_mut() { + // debug_log!(format!("name : {}", _name).as_str()); + let mut index = Some(bs.num_buckets() - 1); + // debug_log!(format!("time : {}", time).as_str()); + if let Some(bucket_time) = bs.bucket_time { + // debug_log!(format!("bucket_time: {}", bucket_time).as_str()); + if time.lt(&bucket_time) { + // Use the closest bucket to this time + // debug_log!("increment (closest bucket)"); + let time_difference = (bucket_time - *time).num_nanoseconds(); + let bucket_duration = bs.bucket_duration.num_nanoseconds(); + if time_difference.and(bucket_duration).is_some() { + let buckets_behind = time_difference.unwrap() / bucket_duration.unwrap(); + if buckets_behind as usize >= bs.num_buckets() { + debug_log!(format!("increment DISCARDED buckets_behind: {}", buckets_behind).as_str()); + index = None; + } else { + // debug_log!(format!("increment INCLUDED buckets_behind: {}", buckets_behind).as_str()); + if bs.num_buckets() > 1 { + index = Some(bs.num_buckets() - 1 - buckets_behind as usize); + } + } + } + } + } + if let Some(index) = index { + // debug_log!(format!("increment index: {}", index).as_str()); + bs.bucket_update_value(index, value, self.is_cumulative); + } + } + // debug_log!("update_value() DONE"); + } +} + +use serde_with::DurationSeconds; +use serde_with::serde_as; + +/// Buckets operate as a value series (e.g. count per bucket), or +/// if Some(stats_mmm) they maintain min, mean and max series. + +// I use the same impl code for is_mmm true or false to avoid polymorphic code +#[serde_as] +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct Buckets { + pub bucket_time: Option>, // Start time of the active buckets + pub earliest_time: Option>, // Earliest time passed to update_current_time() + pub latest_time: Option>, // Most recent time passed to update_current_time() + + #[serde_as(as = "DurationSeconds")] + pub total_duration: Duration, + #[serde_as(as = "DurationSeconds")] + pub bucket_duration: Duration, + pub num_buckets: usize, + pub values_total: u64, + pub values_min: u64, + pub values_max: u64, + + pub is_mmm: bool, + + // if !is_mmm we only use buckets + pub buckets: Vec, // Value series + + // if is_mmm use only the following + pub buckets_count: Vec, // Number of values added to a bucket (timeslot) + pub buckets_total: Vec, // Total of all values added to a given bucket (timeslot) + pub buckets_min: Vec, // Min of all values + pub buckets_mean: Vec, // Average + pub buckets_max: Vec, // Max + + pub buckets_need_init: Vec, // Filled with 1 and set to 0 after init +} + +impl Buckets { + pub fn new(bucket_duration: Duration, num_buckets: usize, is_mmm: bool) -> Buckets { + let value_buckets_size = if is_mmm { 1 } else { num_buckets }; + let mmm_buckets_size = if is_mmm { num_buckets } else { 1 }; + + return Buckets { + bucket_time: None, + earliest_time: None, + latest_time: None, + bucket_duration, + num_buckets, + values_total: 0, + values_min: u64::MAX, + values_max: 0, + total_duration: bucket_duration * num_buckets as i32, + + + is_mmm: is_mmm, + buckets: vec![0; value_buckets_size], + + buckets_count: vec![0; mmm_buckets_size], + buckets_total: vec![0; mmm_buckets_size], + buckets_min: vec![0; mmm_buckets_size], + buckets_mean: vec![0; mmm_buckets_size], + buckets_max: vec![0; mmm_buckets_size], + + buckets_need_init: vec![1; mmm_buckets_size], + } + } + + /// Update all buckets with current time + pub fn update_current_time(&mut self, new_time: &DateTime, is_cumulative: bool) { + // debug_log!(format!("Buckets::update_current_time() new_time: {:?}", new_time).as_str()); + // if let Some(earliest_time) = self.earliest_time { + // debug_log!(format!("self.earliest_time: {:?}", earliest_time).as_str()); + // } else { + // debug_log!(format!("self.earliest_time: None").as_str()); + // } + if let Some(mut bucket_time) = self.bucket_time { + let mut end_time = bucket_time + self.bucket_duration; + // debug_log!(format!("end_time : {}", end_time).as_str()); + while end_time.lt(&new_time) { + // debug_log!("Start new bucket"); + // Start new bucket + self.bucket_time = Some(end_time); + bucket_time = end_time; + end_time = bucket_time + self.bucket_duration; + + if self.is_mmm { + for buckets in + &mut vec![ + &mut self.buckets_count, + &mut self.buckets_total, + &mut self.buckets_min, + &mut self.buckets_mean, + &mut self.buckets_max].iter_mut() { + + buckets.push(0); + if buckets.len() > self.num_buckets { + buckets.remove(0); + } + } + + self.buckets_need_init.push(1); + if self.buckets_need_init.len() > self.num_buckets { + self.buckets_need_init.remove(0); + } + } else { + self.buckets.push(0); + if self.buckets.len() > self.num_buckets { + if is_cumulative { + self.values_total -= self.buckets[0]; + } + self.buckets.remove(0); + } + } + } + } else { + self.bucket_time = Some(*new_time); + } + + if let Some(earliest_time) = self.earliest_time { + if new_time.lt(&earliest_time) { self.earliest_time = Some(*new_time); } + } else { + self.earliest_time = Some(*new_time); + }; + + if let Some(latest_time) = self.latest_time { + if new_time.gt(&latest_time) { self.latest_time = Some(*new_time); } + } else { + self.latest_time = Some(*new_time); + }; + } + + pub fn bucket_update_value(&mut self, index: usize, value: u64, is_cumulative: bool) { + // debug_log!(format!("bucket_update_value(index:{}, value:{}, is_cum:{}) is_mmm:{}", index, value, is_cumulative, self.is_mmm).as_str()); + if self.is_mmm { + debug_log!(format!("is_mmm: bucket_update_value(index:{}, value:{}, is_cum:{})", index, value, is_cumulative).as_str()); + if self.buckets_need_init[index] == 1 { + // debug_log!("is_mmm: doing init"); + + self.buckets_need_init[index] = 0; + + self.buckets_count[index] = 0; + self.buckets_total[index] = 0; + self.buckets_min[index] = u64::MAX; + self.buckets_mean[index] = 0; + self.buckets_max[index] = 0; + } + self.buckets_count[index] += 1; + self.buckets_total[index] += value; + self.buckets_mean[index] = self.buckets_total[index] / self.buckets_count[index]; + + if value < self.buckets_min[index] { self.buckets_min[index] = value } + if value > self.buckets_max[index] { self.buckets_max[index] = value } + + if value < self.values_min { self.values_min = value } + if value > self.values_max { self.values_max = value } + } else { + if is_cumulative { + self.buckets[index] += value; + if self.buckets[index] < self.values_min { self.values_min = self.buckets[index] } + if self.buckets[index] > self.values_max { self.values_max = self.buckets[index] } + self.values_total += value; + } else { + self.buckets[index] = value; + if value < self.values_min { self.values_min = value } + if value > self.values_max { self.values_max = value } + } + + } + } + + pub fn get_duration_text(&self) -> String { + let mut duration = self.total_duration; + if let Some(earliest_time) = self.earliest_time { + if let Some(latest_time) = self.latest_time { + // debug_log!(format!("get_duration_text() earliest_time: {:?} latest_time {:?}", earliest_time, latest_time).as_str()); + + if (latest_time - earliest_time).lt(&duration) && + (latest_time - earliest_time).num_seconds() > 0 { + duration = latest_time - earliest_time; + } else if latest_time.eq(&earliest_time) { + duration = self.bucket_duration; + } + }; + return get_duration_text(duration); + }; + + return String::from("(zero duration)"); + } + + pub fn num_buckets(&self) -> usize { return self.num_buckets; } + + pub fn buckets(&self, mmm_ui_mode: Option<&MinMeanMax>) -> &Vec { + if self.is_mmm { + return match mmm_ui_mode { + None => &self.buckets, + Some(MinMeanMax::Min) => &self.buckets_min, + Some(MinMeanMax::Mean) => &self.buckets_mean, + Some(MinMeanMax::Max) => &self.buckets_max, + } + } else { + return &self.buckets; + } + } +} + diff --git a/src/custom/ui.rs b/src/custom/ui.rs new file mode 100644 index 0000000..a67b1ff --- /dev/null +++ b/src/custom/ui.rs @@ -0,0 +1,126 @@ +/// Terminal based interface and dashboard +/// +/// Edit src/custom/ui.rs to create a customised fork of logtail-dash + +use super::app::{App, DashViewMain, DashState}; +use super::ui_summary::draw_summary_dash; +use super::ui_node::draw_node_dash; +use super::ui_help::draw_help_dash; +use super::ui_debug::draw_debug_dash; + +/// Provides string representation of a nanos amount, in either nanos or currency depending on dash_state +pub fn monetary_string(dash_state: &DashState, nanos: u64) -> String { + if dash_state.ui_uses_currency && dash_state.currency_per_token.is_some() { + let value = (dash_state.currency_per_token.unwrap() * (nanos as f64)) / 1e9 as f64; + return if value >= 0.01 { + format!("{:<1}{:.2}", dash_state.currency_symbol, value) + } else { + format!("{:<1}{:.9}", dash_state.currency_symbol, value) + } + } else { + return format!("{}", nanos); + } +} + +#[path = "../widgets/mod.rs"] +pub mod widgets; +use self::widgets::sparkline::Sparkline2; + +use ratatui::{ + layout::Rect, + style::{Color, Style}, + text::Line, + widgets::{Block, ListItem}, + Frame, +}; + +pub fn draw_dashboard(f: &mut Frame, app: &mut App) { + match app.dash_state.main_view { + DashViewMain::DashSummary => draw_summary_dash(f, &mut app.dash_state, &mut app.monitors), + DashViewMain::DashNode => draw_node_dash(f, &mut app.dash_state, &mut app.monitors), + DashViewMain::DashHelp => draw_help_dash(f, &mut app.dash_state), + DashViewMain::DashDebug => draw_debug_dash(f, &mut app.dash_state, &mut app.monitors), + } +} + +pub fn push_subheading(items: &mut Vec, subheading: &String) { + items.push( + ListItem::new(vec![Line::from(subheading.clone())]) + .style(Style::default().fg(Color::Yellow)), + ); +} + +pub fn push_text(items: &mut Vec, subheading: &String, optional_style: Option