From 845cb468815056a47ac97e9a82aa767458bee8e2 Mon Sep 17 00:00:00 2001 From: 17ms <79069176+17ms@users.noreply.github.com> Date: Sat, 1 Apr 2023 20:02:13 +0300 Subject: [PATCH] major rewrite implementing new features --- Cargo.lock | 2577 ++++++++++++++++++++++++++++++++-- Cargo.toml | 9 +- src/client.rs | 326 ----- src/common.rs | 50 + src/comms.rs | 18 +- src/connector.rs | 219 +++ src/crypto.rs | 27 +- src/lib.rs | 8 +- src/listener.rs | 228 +++ src/main.rs | 83 +- src/server.rs | 286 ---- tests/integration_test.rs | 81 -- tests/sockets_integration.rs | 82 ++ 13 files changed, 3056 insertions(+), 938 deletions(-) mode change 100644 => 100755 Cargo.lock mode change 100644 => 100755 Cargo.toml delete mode 100644 src/client.rs create mode 100644 src/common.rs create mode 100755 src/connector.rs mode change 100644 => 100755 src/lib.rs create mode 100755 src/listener.rs mode change 100644 => 100755 src/main.rs delete mode 100644 src/server.rs delete mode 100644 tests/integration_test.rs create mode 100644 tests/sockets_integration.rs diff --git a/Cargo.lock b/Cargo.lock old mode 100644 new mode 100755 index d104a2a..f4066d9 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,298 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ab_glyph" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe21446ad43aa56417a767f3e2f3d7c4ca522904de1dd640529a76e9c5c3b33c" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" + +[[package]] +name = "accesskit" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4803cf8c252f374ae6bfbb341e49e5a37f7601f2ce74a105927a663eba952c67" + +[[package]] +name = "accesskit_consumer" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee8cf1202a4f94d31837f1902ab0a75c77b65bf59719e093703abe83efd74ec" +dependencies = [ + "accesskit", + "parking_lot", +] + +[[package]] +name = "accesskit_macos" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10be25f2b27bc33aa1647072e86b948b41596f1af1ae43a2b4b9be5d2011cbda" +dependencies = [ + "accesskit", + "accesskit_consumer", + "objc2", + "once_cell", + "parking_lot", +] + +[[package]] +name = "accesskit_unix" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630e7ee8f93c6246478bf0df6760db899b28d9ad54353a5f2d3157138ba817fc" +dependencies = [ + "accesskit", + "accesskit_consumer", + "async-channel", + "atspi", + "futures-lite", + "parking_lot", + "serde", + "zbus", +] + +[[package]] +name = "accesskit_windows" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13c462fabdd950ef14308a9390b07fa2e2e3aabccba1f3ea36ea2231bb942ab" +dependencies = [ + "accesskit", + "accesskit_consumer", + "arrayvec", + "once_cell", + "parking_lot", + "paste", + "windows", +] + +[[package]] +name = "accesskit_winit" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17727888757ec027ec221db33070e226ee07df44425b583bc67684204d35eff9" +dependencies = [ + "accesskit", + "accesskit_macos", + "accesskit_unix", + "accesskit_windows", + "parking_lot", + "winit", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-activity" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c77a0045eda8b888c76ea473c2b0515ba6f471d318f8927c5c72240937035a6" +dependencies = [ + "android-properties", + "bitflags", + "cc", + "jni-sys", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "arboard" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" +dependencies = [ + "clipboard-win", + "log", + "objc", + "objc-foundation", + "objc_id", + "once_cell", + "parking_lot", + "thiserror", + "winapi", + "x11rb", +] + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-broadcast" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" +dependencies = [ + "event-listener", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" +dependencies = [ + "async-lock", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +dependencies = [ + "async-lock", + "autocfg", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite", + "log", + "parking", + "polling", + "rustix", + "slab", + "socket2", + "waker-fn", +] + +[[package]] +name = "async-lock" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-recursion" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + [[package]] name = "async-stream" version = "0.3.4" @@ -21,18 +313,68 @@ checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "atty" -version = "0.2.14" +name = "async-task" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" + +[[package]] +name = "async-trait" +version = "0.1.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "proc-macro2", + "quote", + "syn 2.0.12", +] + +[[package]] +name = "atomic-waker" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" + +[[package]] +name = "atomic_refcell" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8" + +[[package]] +name = "atspi" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab84c09a770065868da0d713f1f4b35af85d96530a868f1c1a6c249178379187" +dependencies = [ + "async-recursion", + "async-trait", + "atspi-macros", + "enumflags2", + "futures-lite", + "serde", + "tracing", + "zbus", + "zbus_names", +] + +[[package]] +name = "atspi-macros" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ebc5a6f61f6996eca56a4cece7b3fe7da3b86f0473c7b71ab44e229f3acce4" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", + "zbus", + "zbus_names", + "zvariant", ] [[package]] @@ -41,12 +383,101 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-sys" +version = "0.1.0-beta.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" +dependencies = [ + "objc-sys", +] + +[[package]] +name = "block2" +version = "0.2.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" +dependencies = [ + "block-sys", + "objc2-encode", +] + +[[package]] +name = "blocking" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" +dependencies = [ + "async-channel", + "async-lock", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", +] + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + [[package]] name = "byteorder" version = "1.4.3" @@ -59,6 +490,34 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[package]] +name = "calloop" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a59225be45a478d772ce015d9743e49e92798ece9e34eda9a6aa2a6a7f40192" +dependencies = [ + "log", + "nix 0.25.1", + "slotmap", + "thiserror", + "vec_map", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.0" @@ -66,61 +525,538 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "clap" -version = "3.2.23" +name = "cfg_aliases" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" dependencies = [ - "atty", - "bitflags", - "clap_derive", - "clap_lex", - "indexmap", - "once_cell", - "strsim", - "termcolor", - "textwrap", + "libc", ] [[package]] -name = "clap_derive" -version = "3.2.18" +name = "cipher" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "clipboard-win" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +dependencies = [ + "error-code", + "str-buf", + "winapi", +] + +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation", + "foreign-types", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "clap_lex" -version = "0.2.4" +name = "digest" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "os_str_bytes", + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dlib" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" +dependencies = [ + "libloading", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "ecolor" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f99fe3cac305af9d6d92971af60d0f7ea4d783201ef1673571567b6699964d9" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "eframe" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df3ce60931e5f2d83bab4484d1a283908534d5308cc6b0c5c22c59cd15ee7cc" +dependencies = [ + "bytemuck", + "egui", + "egui-winit", + "egui_glow", + "glow", + "glutin", + "glutin-winit", + "js-sys", + "percent-encoding", + "raw-window-handle", + "thiserror", + "tracing", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winit", +] + +[[package]] +name = "egui" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6412a21e0bde7c0918f7fb44bbbb86b5e1f88e63c026a4e747cc7af02f76dfbe" +dependencies = [ + "accesskit", + "ahash", + "epaint", + "nohash-hasher", + "tracing", +] + +[[package]] +name = "egui-winit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab43597ba41f0ce39a364ad83185594578bfd8b3409b99dbcbb01df23afc3dbb" +dependencies = [ + "accesskit_winit", + "android-activity", + "arboard", + "egui", + "instant", + "smithay-clipboard", + "tracing", + "webbrowser", + "winit", +] + +[[package]] +name = "egui_glow" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8257332fb168a965b3dca81d6a344e053153773c889cabdba0b3b76f1629ae81" +dependencies = [ + "bytemuck", + "egui", + "glow", + "memoffset 0.6.5", + "tracing", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "emath" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8ecd80612937e0267909d5351770fe150004e24dab93954f69ca62eecd3f77e" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "enumflags2" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "epaint" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e78b5c58a1f7f621f9d546add2adce20636422c9b251e29f749e8a2f713c95" +dependencies = [ + "ab_glyph", + "ahash", + "atomic_refcell", + "bytemuck", + "ecolor", + "emath", + "nohash-hasher", + "parking_lot", +] + +[[package]] +name = "errno" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "error-code" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" +dependencies = [ + "libc", + "str-buf", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "flate2" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", ] [[package]] name = "fragilebyte" version = "0.3.0" dependencies = [ - "clap", + "aes-gcm", + "base64", + "eframe", + "egui", "local-ip-address", "ntest", - "rand", + "rand 0.7.3", + "sha256", "tokio", "tokio-test", + "x25519-dalek", ] [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-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-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] [[package]] name = "getrandom" @@ -130,7 +1066,104 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "ghash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glow" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e007a07a24de5ecae94160f141029e9a347282cfe25d1d58d85d845cf3130f1" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.30.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f89bab9ec7715de13d5d5402238e66f48e3a5ae636ebb45aba4013c962e2ff15" +dependencies = [ + "bitflags", + "cfg_aliases", + "cgl", + "core-foundation", + "dispatch", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2", + "once_cell", + "raw-window-handle", + "wayland-sys 0.30.1", + "windows-sys 0.45.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "629a873fc04062830bfe8f97c03773bcd7b371e23bcc465d0a61448cd1588fa4" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5aaf0abb5c4148685b33101ae326a207946b4d3764d6cdc79f8316cdaa8367d" +dependencies = [ + "gl_generator", + "windows-sys 0.45.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b53cb5fe568964aa066a3ba91eac5ecbac869fb0842cd0dc9e412434f1a1494" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef89398e90033fc6bc65e9bd42fd29bbbfd483bda5b56dc5562f455550618165" +dependencies = [ + "gl_generator", ] [[package]] @@ -139,21 +1172,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[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.2.6" @@ -164,20 +1182,142 @@ dependencies = [ ] [[package]] -name = "indexmap" -version = "1.9.2" +name = "hermit-abi" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +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", ] [[package]] -name = "libc" -version = "0.2.139" +name = "inout" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[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.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "linux-raw-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" [[package]] name = "local-ip-address" @@ -210,12 +1350,63 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.6" @@ -224,10 +1415,39 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.45.0", ] +[[package]] +name = "ndk" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.4.1+23.1.7779620" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +dependencies = [ + "jni-sys", +] + [[package]] name = "neli" version = "0.5.3" @@ -238,6 +1458,61 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "nix" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", + "static_assertions", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "ntest" version = "0.8.1" @@ -263,7 +1538,7 @@ checksum = "6f7caf063242bb66721e74515dc01a915901063fa1f994bee7a2b9136f13370e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -276,7 +1551,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -289,6 +1564,82 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + +[[package]] +name = "objc-sys" +version = "0.2.0-beta.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" + +[[package]] +name = "objc2" +version = "0.3.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe31e5425d3d0b89a15982c024392815da40689aceb34bad364d58732bcfd649" +dependencies = [ + "block2", + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2-encode" +version = "2.0.0-pre.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" +dependencies = [ + "objc-sys", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -296,10 +1647,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] -name = "os_str_bytes" -version = "6.4.1" +name = "opaque-debug" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "orbclient" +version = "0.3.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "974465c5e83cf9df05c1e4137b271d29035c902e39e5ad4c1939837e22160af8" +dependencies = [ + "cfg-if", + "redox_syscall 0.2.16", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25e9fb15717794fae58ab55c26e044103aad13186fbb625893f9a3bbcc24228" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" @@ -319,17 +1707,81 @@ checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "windows-sys 0.45.0", ] +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "pin-project-lite" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "png" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" +dependencies = [ + "bitflags", + "crc32fast", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "polling" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e1f879b2998099c2d69ab9605d145d5b661195627eccc680002c4918a7fb6fa" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.45.0", +] + +[[package]] +name = "polyval" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -346,48 +1798,37 @@ 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", - "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.51" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -395,8 +1836,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -406,7 +1857,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -415,9 +1875,24 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.8", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + [[package]] name = "redox_syscall" version = "0.2.16" @@ -427,12 +1902,168 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.8", + "redox_syscall 0.2.16", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "rustix" +version = "0.37.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d097081ed288dfe45699b72f5b5d648e5f15d64d900c7080273baa20c16a6849" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[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 = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sctk-adwaita" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc56402866c717f54e48b122eb93c69f709bc5a6359c403598992fd92f017931" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit", + "tiny-skia", +] + +[[package]] +name = "serde" +version = "1.0.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-xml-rs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0bf1ba0696ccf0872866277143ff1fd14d22eec235d2b23702f95e6660f7dfa" +dependencies = [ + "log", + "serde", + "thiserror", + "xml-rs", +] + +[[package]] +name = "serde_derive" +version = "1.0.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + +[[package]] +name = "serde_repr" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha256" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328169f167261957e83d82be47f9e36629e257c62308129033d7f7e7c173d180" +dependencies = [ + "hex", + "sha2", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -442,6 +2073,24 @@ dependencies = [ "libc", ] +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "slotmap" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" +dependencies = [ + "version_check", +] + [[package]] name = "smallvec" version = "1.10.0" @@ -449,20 +2098,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] -name = "socket2" -version = "0.4.7" +name = "smithay-client-toolkit" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454" +dependencies = [ + "bitflags", + "calloop", + "dlib", + "lazy_static", + "log", + "memmap2", + "nix 0.24.3", + "pkg-config", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + +[[package]] +name = "smithay-clipboard" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8" +dependencies = [ + "smithay-client-toolkit", + "wayland-client", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", ] [[package]] -name = "strsim" -version = "0.10.0" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "str-buf" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" + +[[package]] +name = "strict-num" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9df65f20698aeed245efdde3628a6b559ea1239bbb871af1b6e3b58c413b2bd1" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" @@ -476,50 +2172,98 @@ dependencies = [ ] [[package]] -name = "termcolor" -version = "1.2.0" +name = "syn" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" dependencies = [ - "winapi-util", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "textwrap" -version = "0.16.0" +name = "tempfile" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.45.0", +] [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.12", ] [[package]] -name = "tokio" -version = "1.26.0" +name = "tiny-skia" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "bfef3412c6975196fdfac41ef232f910be2bb37b9dd3313a49a1a6bc815a5bdb" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "png", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b5edac058fc98f51c935daea4d805b695b38e2f151241cad125ade2a2ac20d" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[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.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot", @@ -532,13 +2276,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.12", ] [[package]] @@ -573,9 +2317,9 @@ checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.19.4" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", "toml_datetime", @@ -583,10 +2327,106 @@ dependencies = [ ] [[package]] -name = "unicode-ident" -version = "1.0.6" +name = "tracing" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "ttf-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "universal-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" @@ -594,12 +2434,212 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "walkdir" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[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.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "wayland-client" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix 0.24.3", + "scoped-tls", + "wayland-commons", + "wayland-scanner", + "wayland-sys 0.29.5", +] + +[[package]] +name = "wayland-commons" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" +dependencies = [ + "nix 0.24.3", + "once_cell", + "smallvec", + "wayland-sys 0.29.5", +] + +[[package]] +name = "wayland-cursor" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" +dependencies = [ + "nix 0.24.3", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" +dependencies = [ + "bitflags", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" +dependencies = [ + "proc-macro2", + "quote", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" +dependencies = [ + "dlib", + "lazy_static", + "pkg-config", +] + +[[package]] +name = "wayland-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06" +dependencies = [ + "dlib", + "lazy_static", + "log", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579cc485bd5ce5bfa0d738e4921dd0b956eca9800be1fd2e5257ebe95bc4617e" +dependencies = [ + "core-foundation", + "dirs", + "jni", + "log", + "ndk-context", + "objc", + "raw-window-handle", + "url", + "web-sys", +] + [[package]] name = "winapi" version = "0.3.9" @@ -625,12 +2665,48 @@ dependencies = [ "winapi", ] +[[package]] +name = "winapi-wsapoll" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" +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" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0286ba339aa753e70765d521bb0242cc48e1194562bfa2a2ad7ac8a6de28f5d5" +dependencies = [ + "windows-implement", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-implement" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9539b6bd3eadbd9de66c9666b22d802b833da7e996bc06896142e09854a61767" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -657,9 +2733,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -672,51 +2748,268 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winit" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f504e8c117b9015f618774f8d58cd4781f5a479bc41079c064f974cbb253874" +dependencies = [ + "android-activity", + "bitflags", + "cfg_aliases", + "core-foundation", + "core-graphics", + "dispatch", + "instant", + "libc", + "log", + "mio", + "ndk", + "objc2", + "once_cell", + "orbclient", + "percent-encoding", + "raw-window-handle", + "redox_syscall 0.3.5", + "sctk-adwaita", + "smithay-client-toolkit", + "wasm-bindgen", + "wayland-client", + "wayland-commons", + "wayland-protocols", + "wayland-scanner", + "web-sys", + "windows-sys 0.45.0", + "x11-dl", +] [[package]] name = "winnow" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" dependencies = [ "memchr", ] + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" +dependencies = [ + "gethostname", + "nix 0.24.3", + "winapi", + "winapi-wsapoll", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" +dependencies = [ + "nix 0.24.3", +] + +[[package]] +name = "x25519-dalek" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2392b6b94a576b4e2bf3c5b2757d63f10ada8020a2e4d08ac849ebcf6ea8e077" +dependencies = [ + "curve25519-dalek", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "xcursor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" +dependencies = [ + "nom", +] + +[[package]] +name = "xml-rs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" + +[[package]] +name = "zbus" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dc29e76f558b2cb94190e8605ecfe77dd40f5df8c072951714b4b71a97f5848" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-recursion", + "async-task", + "async-trait", + "byteorder", + "derivative", + "dirs", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix 0.26.2", + "once_cell", + "ordered-stream", + "rand 0.8.5", + "serde", + "serde-xml-rs", + "serde_repr", + "sha1", + "static_assertions", + "tracing", + "uds_windows", + "winapi", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62a80fd82c011cd08459eaaf1fd83d3090c1b61e6d5284360074a7475af3a85d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f34f314916bd89bdb9934154627fab152f4f28acdda03e7c4c68181b214fe7e3" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + +[[package]] +name = "zvariant" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fe4914a985446d6fd287019b5fceccce38303d71407d9e6e711d44954a05d8" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34c20260af4b28b3275d6676c7e2a6be0d4332e8e0aba4616d34007fd84e462a" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b22993dbc4d128a17a3b6c92f1c63872dd67198537ee728d8b5d7c40640a8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] diff --git a/Cargo.toml b/Cargo.toml old mode 100644 new mode 100755 index b26f702..3ba99e0 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,14 @@ edition = "2021" [dependencies] tokio = { version = "1.20.4", features = ["full"] } -clap = { version = "3.2.8", features = ["derive"] } local-ip-address = "0.4.4" -rand = "0.8.5" +rand = "0.7.0" +eframe = "0.21.3" +egui = "0.21.0" +x25519-dalek = "1.2.0" +aes-gcm = "0.10.1" +base64 = "0.21.0" +sha256 = "1.1.2" [dev-dependencies] tokio-test = "0.4.2" diff --git a/src/client.rs b/src/client.rs deleted file mode 100644 index ca37dcf..0000000 --- a/src/client.rs +++ /dev/null @@ -1,326 +0,0 @@ -use std::{ - collections::HashMap, - error::Error, - io::stdin, - path::PathBuf, - process::exit, - sync::mpsc::{self, Receiver, Sender}, - thread, - time::Duration, -}; -use tokio::{ - fs::File, - io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader, BufWriter}, - net::{ - tcp::{ReadHalf, WriteHalf}, - TcpStream, - }, - time::sleep, -}; - -pub async fn connect( - addr: String, - fileroot: PathBuf, - access_key: String, - download_all: bool, -) -> Result<(), Box> { - let (tx, rx): (Sender, Receiver) = mpsc::channel(); - - let connection_task = thread::spawn(move || async move { - println!("[+] Connecting to {}", addr); - let mut stream = TcpStream::connect(addr.clone()).await?; - - let (reader, writer) = stream.split(); - let mut reader = BufReader::new(reader); - let mut writer = BufWriter::new(writer); - - let mut buf = Vec::new(); - - // Authenticate connection - match authenticate_connection(&mut reader, &mut writer, &mut buf, &access_key).await? { - None => println!("[+] Connection authenticated successfully"), - Some(err_msg) => { - println!("{}", err_msg); - exit(0x0100); - } - } - - // Receive chunksize - let chunksize = recv_msg_string(&mut reader, &mut buf) - .await? - .parse::()?; - println!("[+] Selected chunksize: {}", chunksize); - - // ACK chunksize - send_msg(&mut writer, "ACK\n").await?; - - // Receive metadata - let metadata = match receive_metadata(&mut reader, &mut writer, &mut buf).await? { - Some(metadata) => metadata, - None => exit(0x0100), - }; - - println!("[+] Received metadata: {:#?}", metadata); - - // Send request for each file by filename - println!("\n[+] [ + Enter] to make a request\n"); - println!("[+] \"DISCONNECT\" to disconnect"); - handle_file_reqs( - &mut reader, - &mut writer, - rx, - &chunksize, - &metadata, - &fileroot, - &download_all, - ) - .await?; - - // Terminating connection - println!("[+] Requesting connection termination"); - writer.write_all(b"FIN\n").await?; - writer.flush().await?; - - Ok::<(), Box>(()) - }); - - // Separate thread for blocking stdin - let input_task = thread::spawn(move || handle_stdin(tx)); - - match connection_task.join().unwrap().await { - Ok(_) => {} - Err(e) => { - eprintln!("[ERROR] Error inside connection thread: {}", e); - exit(0x0100); - } - } - - if !download_all { - match input_task.join().unwrap() { - Ok(_) => {} - Err(e) => { - eprintln!("[ERROR] Error inside input thread: {}", e); - exit(0x0100); - } - } - } - - Ok(()) -} - -async fn send_msg( - writer: &mut BufWriter>, - msg: &str, -) -> Result<(), Box> { - writer.write_all(msg.as_bytes()).await?; - writer.flush().await?; - Ok(()) -} - -async fn recv_msg_string( - reader: &mut BufReader>, - buf: &mut Vec, -) -> Result> { - let bytes_received = reader.read_until(b'\n', buf).await?; - - if bytes_received == 0 { - let e: Box = - format!("No message received or server crashed").into(); - return Err::>(e); - } - - let msg = String::from_utf8(buf.clone())?; - buf.clear(); - - Ok(msg.trim().to_string()) -} - -fn handle_stdin(tx: Sender) -> Result<(), Box> { - let mut input_string = String::new(); - while input_string.trim() != "DISCONNECT" { - input_string.clear(); - stdin().read_line(&mut input_string)?; - print!("\n"); - tx.send(input_string.clone())?; - } - - Ok::<(), Box>(()) -} - -async fn authenticate_connection( - reader: &mut BufReader>, - writer: &mut BufWriter>, - buf: &mut Vec, - access_key: &String, -) -> Result, Box> { - // Receive ACK to indicate ready-to-receive status - if recv_msg_string(reader, buf).await? != "SYN" { - return Ok(Some( - "[-] Server is not ready to receive access key, terminating connection".to_string(), - )); - } - - // Send access key - send_msg(writer, (access_key.to_string() + "\n").as_str()).await?; - - // Terminate connection if key is invalid - if recv_msg_string(reader, buf).await? == "FIN" { - return Ok(Some( - "[-] Incorrect access key, terminating connection".to_string(), - )); - } else { - send_msg(writer, "ACK\n").await?; - Ok(None) - } -} - -async fn receive_metadata( - reader: &mut BufReader>, - writer: &mut BufWriter>, - buf: &mut Vec, -) -> Result>, Box> { - // Receive file amount or terminate if no files available - let msg = recv_msg_string(reader, buf).await?; - if msg == "FIN" { - println!("[-] Server does not have any files available, closing connection"); - return Ok(None); - } - - let file_amount = msg.parse::()?; - println!("[+] Total of {} files available", file_amount); - - // ACK file amount - send_msg(writer, "ACK\n").await?; - - // Receive file metadata - let mut metadata = HashMap::new(); - while metadata.len() < file_amount { - let msg = recv_msg_string(reader, buf).await?; - - // Parse 'filesize:filename' - let split = msg.split(":").collect::>(); - let filesize = split[0].trim().parse::()?; - let filename = split[1].trim().to_string(); - - metadata.insert(filename, filesize); - } - - Ok(Some(metadata)) -} - -async fn create_filehandle( - fileroot: &PathBuf, - filename: &String, -) -> Result<(BufWriter, PathBuf), Box> { - let mut output_path = fileroot.clone(); - output_path.push(&filename); - let output_file = File::create(output_path.clone()).await?; - println!("[+] New file: {:#?}", output_path); - - Ok((BufWriter::new(output_file), output_path)) -} - -async fn handle_file_reqs( - reader: &mut BufReader>, - writer: &mut BufWriter>, - rx: Receiver, - chunksize: &usize, - metadata: &HashMap, - fileroot: &PathBuf, - download_all: &bool, -) -> Result<(), Box> { - let filenames = metadata.keys().collect::>(); - let mut filenames_iter = filenames.iter(); - - let mut input_string = String::new(); - - loop { - input_string.clear(); - - if *download_all { - match filenames_iter.next() { - Some(filename) => { - input_string.push_str(filename); - } - None => input_string.push_str("DISCONNECT"), - } - } else { - // Blocks the current thread until a message is readable - // Requests (messages) get queued if they can't be served immediately - let msg = rx.recv()?; - input_string.push_str(msg.trim()); - } - - // Terminate connection on request - if input_string == "DISCONNECT" { - break; - } else if !metadata.contains_key(input_string.as_str()) { - println!("[-] No file named '{}' available\n", input_string); - continue; - } - - // Handle request based on input received from channel - println!("[+] Requesting file named '{}'", input_string); - send_msg(writer, (input_string.to_string() + "\n").as_str()).await?; - - // Create file locally - let (mut file_buf, output_path) = create_filehandle(&fileroot, &input_string).await?; - - // Receive the file itself - let filesize = metadata.get(input_string.as_str()).unwrap().clone(); - receive_file(reader, &mut file_buf, &filesize, chunksize).await?; - - // ACK file - send_msg(writer, "ACK\n").await?; - println!( - "[+] Successfully wrote {} bytes to {:#?}\n", - filesize, output_path - ); - } - - Ok(()) -} - -async fn receive_file( - reader: &mut BufReader>, - file_buf: &mut BufWriter, - filesize: &u64, - chunksize: &usize, -) -> Result<(), Box> { - let mut remaining_data = *filesize; - let mut buf = vec![0u8; *chunksize]; - - while remaining_data != 0 { - if remaining_data >= *chunksize as u64 { - let read_result = reader.read(&mut buf); - - match read_result.await { - Ok(0) => { - println!("[-] Connection lost, trying again until [Ctrl + C]..."); - sleep(Duration::from_secs(5)).await; - continue; - } - Ok(n) => { - file_buf.write_all(&mut buf).await?; - file_buf.flush().await?; - remaining_data = remaining_data - n as u64; - } - _ => {} - } - } else { - let read_result = reader.read(&mut buf); - - match read_result.await { - Ok(_) => { - let mut buf_slice = &buf[0..(remaining_data as usize)]; - file_buf.write_all(&mut buf_slice).await?; - file_buf.flush().await?; - remaining_data = 0; - } - _ => {} - } - } - } - - Ok(()) -} diff --git a/src/common.rs b/src/common.rs new file mode 100644 index 0000000..1a25b3e --- /dev/null +++ b/src/common.rs @@ -0,0 +1,50 @@ +use crate::crypto; +use aes_gcm::{aead::consts::U12, aes::Aes256, AesGcm}; +use rand::rngs::OsRng; +use std::{collections::HashMap, error::Error, net::SocketAddr, path::PathBuf}; +use tokio::{ + io::{BufReader, BufWriter}, + net::{ + tcp::{ReadHalf, WriteHalf}, + TcpStream, + }, +}; + +#[derive(Debug, PartialEq, Eq)] +pub enum Message { + ErrorMsg(String), + Files(Vec), + Metadata(HashMap), + Chunksize(usize), + ClientConnect(SocketAddr), + ClientDisconnect(SocketAddr), + ClientReq(String), + ClientReqAll, + ConnectionReady, + Shutdown, +} +pub struct Connection<'a> { + pub reader: BufReader>, + pub writer: BufWriter>, + pub cipher: AesGcm, + pub rng: OsRng, +} + +impl<'a> Connection<'a> { + pub async fn new( + socket: &'a mut TcpStream, + ) -> Result, Box> { + let (reader, writer) = socket.split(); + let mut reader = BufReader::new(reader); + let mut writer = BufWriter::new(writer); + let cipher = crypto::aes_cipher(&mut reader, &mut writer, true).await?; + let rng = OsRng; + + Ok(Self { + reader, + writer, + cipher, + rng, + }) + } +} diff --git a/src/comms.rs b/src/comms.rs index a8169c3..236dc6e 100755 --- a/src/comms.rs +++ b/src/comms.rs @@ -15,6 +15,7 @@ pub async fn send( data: &Vec, ) -> Result<(), Box> { let enc: Vec; + if let (Some(cipher), Some(rng)) = (cipher, rng) { enc = crypto::aes_encrypt(data, cipher, rng)?; } else { @@ -26,7 +27,6 @@ pub async fn send( .as_bytes() .to_vec(); encoded.push(b':'); - writer.write_all(&encoded).await?; writer.flush().await?; @@ -36,22 +36,22 @@ pub async fn send( pub async fn recv( reader: &mut BufReader>, cipher: Option<&mut AesGcm>, - buf: &mut Vec, -) -> Result<(), Box> { - let n = reader.read_until(b':', buf).await?; +) -> Result, Box> { + let mut buf = Vec::new(); + let n = reader.read_until(b':', &mut buf).await?; if n == 0 { - todo!("error: connection closed unexpectedly"); + todo!("maybe error handling :)"); } buf.pop(); - *buf = general_purpose::STANDARD_NO_PAD.decode(&buf)?.to_vec(); + buf = general_purpose::STANDARD_NO_PAD.decode(&buf)?.to_vec(); if let Some(cipher) = cipher { - *buf = crypto::aes_decrypt(&buf, cipher)?; + buf = crypto::aes_decrypt(&buf, cipher)?; } else { - *buf = buf.clone(); + buf = buf.clone(); } - Ok(()) + Ok(buf) } diff --git a/src/connector.rs b/src/connector.rs new file mode 100755 index 0000000..2bfbafe --- /dev/null +++ b/src/connector.rs @@ -0,0 +1,219 @@ +use crate::{ + common::{Connection, Message}, + comms, crypto, +}; +use std::{collections::HashMap, error::Error, net::SocketAddr, path::PathBuf}; +use tokio::{ + fs::File, + io::{AsyncWriteExt, BufWriter}, + net::TcpStream, + sync::mpsc, +}; + +#[derive(Debug)] +pub struct Request { + pub name: String, + pub size: u64, + pub hash: String, +} + +impl Request { + pub fn new(name: String, metadata: &HashMap) -> Option { + let (size, hash) = metadata.get(&name)?.clone(); + Some(Self { name, size, hash }) + } +} + +#[derive(Debug, Clone)] +pub struct Connector { + target_addr: SocketAddr, + access_key: &'static str, + output_path: PathBuf, +} + +impl Connector { + pub fn new(target_addr: SocketAddr, access_key: &'static str, output_path: PathBuf) -> Self { + Self { + target_addr, + access_key, + output_path, + } + } + + pub async fn connect( + self, + tx: mpsc::Sender, + mut rx: mpsc::Receiver, + ) -> Result<(), Box> { + let mut socket = TcpStream::connect(self.target_addr).await?; + let mut connection = Connection::new(&mut socket).await?; + + self.authorize(&mut connection).await?; + let metadata = self.metadata(&mut connection).await?; + tx.send(Message::Metadata(metadata.clone())).await?; + self.request_handler(&mut connection, &mut rx, &metadata) + .await?; + + let msg = b"FIN".to_vec(); + comms::send( + &mut connection.writer, + Some(&mut connection.cipher), + Some(&mut connection.rng), + &msg, + ) + .await?; + + Ok(()) + } + + async fn authorize( + &self, + conn: &mut Connection<'_>, + ) -> Result<(), Box> { + let msg = self.access_key.to_string().as_bytes().to_vec(); + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let msg = String::from_utf8(buf)?; + + if msg == "FIN" { + todo!("maybe error handling :)"); + } + + Ok(()) + } + + async fn metadata( + &self, + conn: &mut Connection<'_>, + ) -> Result, Box> { + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let amt: usize = String::from_utf8(buf)?.parse()?; + + let msg = b"AMT".to_vec(); + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + let mut metadata = HashMap::new(); + + while metadata.len() < amt { + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let msg = String::from_utf8(buf)?; + + let split: Vec<&str> = msg.split(":").collect(); + let name = split[0].trim().to_string(); + let size: u64 = split[1].trim().parse()?; + let hash = split[2].trim().to_string(); + + metadata.insert(name, (size, hash)); + } + + Ok(metadata) + } + + async fn new_handle( + &self, + filename: &str, + ) -> Result<(BufWriter, String), Box> { + let mut dir_path = self.output_path.clone(); + dir_path.push(filename); + let str_path = dir_path.to_str().unwrap().to_string(); + let filehandle = File::create(dir_path).await?; + + Ok((BufWriter::new(filehandle), str_path)) + } + + async fn request( + &self, + conn: &mut Connection<'_>, + req: Request, + ) -> Result> { + let (mut handle, path) = self.new_handle(&req.name).await?; + let msg = req.hash.as_bytes().to_vec(); + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + let mut remaining = req.size.clone(); + + while remaining != 0 { + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + handle.write_all(&buf).await?; + handle.flush().await?; + remaining -= buf.len() as u64; + } + + let msg: Vec; + let new_hash = crypto::try_hash(&path)?; + + if new_hash == req.hash { + msg = b"OK".to_vec(); + } else { + msg = b"ERROR".to_vec(); + } + + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + Ok(true) + } + + async fn request_handler( + &self, + conn: &mut Connection<'_>, + rx: &mut mpsc::Receiver, + metadata: &HashMap, + ) -> Result<(), Box> { + loop { + let rx_msg = rx.recv().await; + + match rx_msg.unwrap() { + Message::ClientReq(name) => { + let req = Request::new(name, metadata).unwrap(); // TODO: handle + self.request(conn, req).await?; + } + Message::ClientReqAll => { + for name in metadata.keys() { + let req = Request::new(name.clone(), metadata).unwrap(); // TODO: handle + self.request(conn, req).await?; + } + } + Message::Shutdown => { + let msg = b"DISCONNECT".to_vec(); + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + break; + } + _ => continue, + } + } + + Ok(()) + } +} diff --git a/src/crypto.rs b/src/crypto.rs index 6b9e490..9e4e1c2 100755 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -5,7 +5,7 @@ use aes_gcm::{ Aes256Gcm, AesGcm, KeyInit, Nonce, }; use rand::{rngs::OsRng, RngCore}; -use std::error::Error; +use std::{error::Error, path::Path}; use tokio::{ io::{BufReader, BufWriter}, net::tcp::{ReadHalf, WriteHalf}, @@ -15,34 +15,36 @@ use x25519_dalek::{EphemeralSecret, PublicKey, SharedSecret}; const AES_NONCE_SIZE: usize = 12; const DH_PBK_SIZE: usize = 32; -pub async fn edh( +async fn edh( reader: &mut BufReader>, writer: &mut BufWriter>, - buf: &mut Vec, go_first: bool, ) -> Result> { + let buf: Vec; let own_sec = EphemeralSecret::new(OsRng); let own_pbk = PublicKey::from(&own_sec); let msg = own_pbk.as_bytes().to_vec(); if go_first { comms::send(writer, None, None, &msg).await?; - comms::recv(reader, None, buf).await?; + buf = comms::recv(reader, None).await?; } else { - comms::recv(reader, None, buf).await?; + buf = comms::recv(reader, None).await?; comms::send(writer, None, None, &msg).await?; } let slice: [u8; DH_PBK_SIZE] = buf[..DH_PBK_SIZE].try_into()?; - buf.clear(); let recv_pbk = PublicKey::from(slice); Ok(own_sec.diffie_hellman(&recv_pbk)) } -pub fn aes_cipher( - secret: SharedSecret, +pub async fn aes_cipher( + reader: &mut BufReader>, + writer: &mut BufWriter>, + go_first: bool, ) -> Result, Box> { + let secret = edh(reader, writer, go_first).await?; Ok(Aes256Gcm::new(secret.as_bytes().into())) } @@ -78,12 +80,19 @@ pub fn aes_decrypt( Ok(decrypted) } +pub fn try_hash(path: &String) -> Result> { + let path = Path::new(path); + let hash = sha256::try_digest(path)?; + + Ok(hash) +} + #[cfg(test)] mod tests { use super::*; #[test] - fn test_aes() { + fn aes_implementations() { use aes_gcm::aead; let mut gen_rng = aead::OsRng; diff --git a/src/lib.rs b/src/lib.rs old mode 100644 new mode 100755 index c07f47e..4cf68ae --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,6 @@ -pub mod client; -pub mod server; +pub mod common; +pub mod comms; +pub mod connector; +pub mod crypto; +//pub mod gui; +pub mod listener; diff --git a/src/listener.rs b/src/listener.rs new file mode 100755 index 0000000..a36afa1 --- /dev/null +++ b/src/listener.rs @@ -0,0 +1,228 @@ +use crate::{ + common::{Connection, Message}, + comms, crypto, +}; +use rand::{distributions::Alphanumeric, Rng}; +use std::{collections::HashMap, error::Error, net::SocketAddr, path::PathBuf, str::FromStr}; +use tokio::{ + fs::File, + io::AsyncReadExt, + net::{TcpListener, TcpStream}, + sync::mpsc::{self}, +}; + +#[derive(Debug, Clone, Copy)] +pub struct Listener { + host_addr: SocketAddr, + access_key: &'static str, + chunksize: usize, +} + +// TODO: impl Drop (?) + +impl Listener { + pub fn new(host_addr: SocketAddr, access_key: &'static str, chunksize: usize) -> Self { + Self { + host_addr, + access_key, + chunksize, + } + } + + pub async fn start( + self, + tx: mpsc::Sender, + mut kill: mpsc::Receiver, + files: Vec, + ) -> Result<(), Box> { + tokio::select! { + _ = self.listen(tx, files) => Ok(()), + _ = kill.recv() => Ok(()), + } + } + + async fn listen( + self, + tx: mpsc::Sender, + files: Vec, + ) -> Result<(), Box> { + let listener = TcpListener::bind(self.host_addr).await?; + + loop { + let files = files.clone(); + let (mut socket, addr) = listener.accept().await?; + tx.send(Message::ClientConnect(addr)).await?; + let this_tx = tx.clone(); + + tokio::spawn(async move { + self.connection(&mut socket, addr, this_tx, &files).await?; + Ok::<(), Box>(()) + }); + } + } + + async fn connection( + &self, + socket: &mut TcpStream, + addr: SocketAddr, + tx: mpsc::Sender, + files: &Vec, + ) -> Result<(), Box> { + let mut connection = Connection::new(socket).await?; + + if !self.authorize(&mut connection).await? { + return Ok::<(), Box>(()); + } + + let index = self.metadata_handler(&mut connection, &files).await?; + tx.send(Message::ConnectionReady).await?; + self.request_handler(&mut connection, &index).await?; + tx.send(Message::ClientDisconnect(addr)).await?; + + Ok::<(), Box>(()) + } + + async fn authorize( + &self, + conn: &mut Connection<'_>, + ) -> Result> { + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let key = String::from_utf8(buf)?; + let msg: Vec; + let res: bool; + + if key != self.access_key { + res = false; + msg = b"DISCONNECT".to_vec(); + } else { + res = true; + msg = b"OK".to_vec(); + } + + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + Ok(res) + } + + async fn metadata( + &self, + files: &Vec, + ) -> Result< + (usize, Vec<(String, u64, String)>, HashMap), + Box, + > { + let mut metadata: Vec<(String, u64, String)> = Vec::new(); + let mut index = HashMap::new(); + + for path in files { + let split: Vec<&str> = path.split("/").collect(); // TODO: different path delimiters? + let name = split[split.len() - 1].to_string(); + let handle = File::open(PathBuf::from_str(path)?).await?; + let size = handle.metadata().await?.len(); + let hash = crypto::try_hash(path)?; + + if size > 0 { + metadata.push((name, size, hash.clone())); + index.insert(hash, path.clone()); + } + } + + Ok((metadata.len(), metadata, index)) + } + + async fn metadata_handler( + &self, + conn: &mut Connection<'_>, + files: &Vec, + ) -> Result, Box> { + let (amt, metadata, index) = self.metadata(files).await?; + let msg = amt.to_string().as_bytes().to_vec(); + + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let msg = String::from_utf8(buf)?; + + if msg != "AMT" { + todo!("maybe error handling :)"); + } + + for file in metadata { + let msg = format!("{}:{}:{}", file.0, file.1, file.2) + .as_bytes() + .to_vec(); + + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &msg, + ) + .await?; + } + + Ok(index) + } + + async fn request_handler( + &self, + conn: &mut Connection<'_>, + index: &HashMap, + ) -> Result<(), Box> { + loop { + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let cmd = String::from_utf8(buf)?; + + if cmd == "DISCONNECT" { + break; + } + + let mut file = File::open(index[&cmd].clone()).await?; + let mut remaining = file.metadata().await?.len(); + let mut send_buf = vec![0u8; self.chunksize]; + + while remaining != 0 { + let n = file.read(&mut send_buf).await?; + + comms::send( + &mut conn.writer, + Some(&mut conn.cipher), + Some(&mut conn.rng), + &send_buf[..n].to_vec(), + ) + .await?; + + remaining = remaining - n as u64; + } + + let buf = comms::recv(&mut conn.reader, Some(&mut conn.cipher)).await?; + let msg = String::from_utf8(buf)?; + + if msg == "ERROR" { + todo!("maybe error handling :)"); + } + } + + Ok(()) + } +} + +pub fn keygen() -> String { + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(8) + .map(char::from) + .collect::() +} diff --git a/src/main.rs b/src/main.rs old mode 100644 new mode 100755 index 7f1098f..9ef49be --- a/src/main.rs +++ b/src/main.rs @@ -1,87 +1,8 @@ -use clap::Parser; -use fragilebyte::{client, server}; -use std::{error::Error, path::PathBuf, process::exit, str::FromStr}; +//use fragilebyte::gui; +use std::error::Error; use tokio; -#[derive(Parser, Debug)] -#[clap(author, about, version, long_about = None)] -struct Args { - #[clap(short = 't', long, value_parser)] - /// Server's address when connecting as a client - target: Option, - #[clap(short = 'k', long, value_parser)] - /// Alphanumeric 8 characters long key required to establish a connection to the host - key: Option, - #[clap(default_value_t = 8080u16, short = 'p', long, value_parser = validate_arg::)] - /// Port where the service is hosted - port: u16, - #[clap(default_value_t = 8192usize, short = 'b', long, value_parser = validate_arg::)] - /// Chunksize used in the file transfer (bytes) - chunksize: usize, - #[clap(default_value_t = false, long, action)] - /// Run only in the local network - localhost: bool, - #[clap(default_value_t = 30, long, value_parser = validate_arg::)] - /// Seconds of inactivity after which the server closes itself - timeout: u64, - #[clap(short = 'f', long, value_parser)] - /// Path to the folder where the files are outputted as a client or - /// served from as a server [default: './output' / './data'] - fileroot: Option, - #[clap(default_value_t = false, short = 'a', long, action)] - /// Automatically download every available file from the host (skips stdin) - all: bool, -} - #[tokio::main] async fn main() -> Result<(), Box> { - let args = Args::parse(); - - match args.target { - Some(addr) => { - // Client - let fileroot = match args.fileroot { - Some(n) => n, - None => PathBuf::from("./output"), - }; - let access_key = match args.key { - Some(n) => n, - None => { - eprintln!("[-] Access key required as a client, please try again"); - exit(0x0100); - } - }; - - client::connect(addr, fileroot, access_key, args.all) - .await - .expect("Error initializing client"); - } - None => { - // Server - let fileroot = match args.fileroot { - Some(n) => n, - None => PathBuf::from("./data"), - }; - - server::listen( - args.port, - fileroot, - args.chunksize, - args.localhost, - args.timeout, - false, - ) - .await - .expect("Error initializing server"); - } - } - Ok(()) } - -fn validate_arg(value: &str) -> Result { - match value.parse::() { - Ok(n) => Ok(n), - Err(_) => Err(format!("Invalid argument: {}", value)), - } -} diff --git a/src/server.rs b/src/server.rs deleted file mode 100644 index 57b861f..0000000 --- a/src/server.rs +++ /dev/null @@ -1,286 +0,0 @@ -use local_ip_address::local_ip; -use rand::{distributions::Alphanumeric, thread_rng, Rng}; -use std::{ - error::Error, - fs::read_dir, - net::{IpAddr, SocketAddr}, - path::PathBuf, - process::exit, - str::FromStr, - time::Duration, -}; -use tokio::{ - self, - fs::File, - io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader, BufWriter}, - net::{ - tcp::{ReadHalf, WriteHalf}, - TcpListener, - }, - time::timeout, -}; - -pub async fn listen( - port: u16, - fileroot: PathBuf, - chunksize: usize, - localhost: bool, - timeout_duration: u64, - use_testing_key: bool, -) -> Result<(), Box> { - let addr = match localhost { - true => SocketAddr::new(IpAddr::from_str("127.0.0.1")?, port), - false => { - println!("[+] Listening on {}:{}", local_ip()?, port); - SocketAddr::new(IpAddr::from_str("0.0.0.0")?, port) - } - }; - // Use weak access key for integration testing, otherwise 8 char alphanumeric - let access_key = match use_testing_key { - true => "test".to_string(), - false => generate_key(), - }; - - let listener = TcpListener::bind(addr).await?; - println!("[+] Access key: {}", access_key); - - loop { - // The first loop iteration would take the ownership without cloning - let alt_fileroot = fileroot.clone(); - let alt_access_key = access_key.clone(); - - let (mut socket, addr) = - match timeout(Duration::from_secs(timeout_duration), listener.accept()).await { - Ok(n) => n?, - Err(_) => { - println!( - "\n[-] Connection timed out after {} seconds", - timeout_duration - ); - break; - } - }; - - println!("\n[NEW] {}: Connected", addr); - - tokio::spawn(async move { - let (reader, writer) = socket.split(); - let mut reader = BufReader::new(reader); - let mut writer = BufWriter::new(writer); - - let mut vec_buf = Vec::new(); - - // ACK ready-to-receive status - send_msg(&mut writer, "SYN\n").await?; - - // Check access key - if !check_access_key(&mut reader, &mut writer, &mut vec_buf, &alt_access_key).await? { - println!("[FIN] {}: Incorrect access key", addr); - return Ok::<(), Box>(()); - } - - // Send chunksize - send_msg(&mut writer, (chunksize.to_string() + "\n").as_str()).await?; - - // ACK chunksize - if recv_msg_string(&mut reader, &mut vec_buf).await? != "ACK" { - return Ok::<(), Box>(()); - } - - // Send metadata - match handle_metadata(&mut reader, &mut writer, &mut vec_buf, &alt_fileroot, &addr) - .await? - { - None => println!("[DATA] {}: Ready to serve files", addr), - Some(err_msg) => { - println!("{}", err_msg); - exit(0x0100); - } - } - - // Send filedata - match handle_file_reqs( - &mut reader, - &mut writer, - &mut vec_buf, - &alt_fileroot, - &chunksize, - &addr, - ) - .await? - { - None => println!("[FIN] {}: Disconnected", addr), - Some(err_msg) => { - println!("{}", err_msg); - exit(0x0100); - } - } - - Ok::<(), Box>(()) - }); - } - - Ok(()) -} - -async fn get_metadata( - fileroot: &PathBuf, -) -> Result<(Vec<(String, u64)>, usize), Box> { - let mut metadata = Vec::<(String, u64)>::new(); - let paths = read_dir(fileroot)?; - - for filename in paths { - let filepath = filename?.path().display().to_string(); - let split = filepath.split("/").collect::>(); - let filename = split[split.len() - 1].to_string(); - let file = File::open(filepath).await?; - let filesize = file.metadata().await?.len(); - - if filesize > 0 { - metadata.push((filename, filesize)); - } - } - - let amount = metadata.len(); - - Ok((metadata, amount)) -} - -async fn handle_metadata( - reader: &mut BufReader>, - writer: &mut BufWriter>, - buf: &mut Vec, - fileroot: &PathBuf, - addr: &SocketAddr, -) -> Result, Box> { - let (metadata_list, file_amount) = get_metadata(fileroot).await?; - - // Terminate if fileroot is empty - if file_amount == 0 { - send_msg(writer, "FIN\n").await?; - return Ok(Some(format!( - "[-] No files inside {:#?}, shutting host down", - fileroot - ))); - } - - // Send metadata amount - send_msg(writer, (file_amount.to_string() + "\n").as_str()).await?; - - // ACK metadata amount - if recv_msg_string(reader, buf).await? != "ACK" { - return Ok(Some(format!( - "[ERROR] {}: No confirmation of metadata amount", - addr - ))); - } - - // Send metadata - for file in &metadata_list { - send_msg(writer, format!("{}:{}\n", file.1, file.0).as_str()).await?; - } - - Ok(None) -} - -fn generate_key() -> String { - thread_rng() - .sample_iter(&Alphanumeric) - .take(8) - .map(char::from) - .collect::() -} - -async fn send_msg( - writer: &mut BufWriter>, - msg: &str, -) -> Result<(), Box> { - writer.write_all(msg.as_bytes()).await?; - writer.flush().await?; - Ok(()) -} - -async fn recv_msg_string( - reader: &mut BufReader>, - buf: &mut Vec, -) -> Result> { - let bytes_received = reader.read_until(b'\n', buf).await?; - - if bytes_received == 0 { - let e: Box = - format!("No message received or client crashed").into(); - return Err::>(e); - } - - let msg = String::from_utf8(buf.clone())?; - buf.clear(); - - Ok(msg.trim().to_string()) -} - -async fn check_access_key( - reader: &mut BufReader>, - writer: &mut BufWriter>, - buf: &mut Vec, - access_key: &String, -) -> Result> { - if recv_msg_string(reader, buf).await? != *access_key { - send_msg(writer, "FIN\n").await?; - return Ok(false); - } else { - send_msg(writer, "ACK\n").await?; - recv_msg_string(reader, buf).await?; // Might be a bit unnecessary ACK - return Ok(true); - } -} - -async fn handle_file_reqs( - reader: &mut BufReader>, - writer: &mut BufWriter>, - buf: &mut Vec, - fileroot: &PathBuf, - chunksize: &usize, - addr: &SocketAddr, -) -> Result, Box> { - loop { - // Receive filename or termination request - let req = recv_msg_string(reader, buf).await?; - - if req == "FIN" { - break; - } - - let mut input_path = fileroot.clone(); - input_path.push(req); - - println!("\n[REQ] {}: {:#?}", addr, input_path); - let mut file = File::open(input_path.clone()).await?; - let mut remaining_data = file.metadata().await?.len(); - let mut filebuf = vec![0u8; *chunksize]; - - // Serve the file itself - while remaining_data != 0 { - let read_result = file.read(&mut filebuf); - match read_result.await { - Ok(n) => { - writer.write_all(&filebuf).await?; - writer.flush().await?; - remaining_data = remaining_data - n as u64; - } - _ => {} - } - } - - // ACK file - if recv_msg_string(reader, buf).await? != "ACK" { - return Ok(Some(format!( - "[ERROR] {}: No confirmation of file {:#?}", - addr, input_path - ))); - } else { - println!("[ACK] {}: File finished successfully", addr); - } - } - - Ok(None) -} diff --git a/tests/integration_test.rs b/tests/integration_test.rs deleted file mode 100644 index b8cb29c..0000000 --- a/tests/integration_test.rs +++ /dev/null @@ -1,81 +0,0 @@ -use fragilebyte::{client, server}; -use ntest::timeout; -use rand::{distributions::Alphanumeric, thread_rng, Rng}; -use std::{ - fs::{read_to_string, remove_file, File}, - io::{BufWriter, Write}, - path::PathBuf, - thread::{self, sleep}, - time::Duration, -}; -use tokio_test::block_on; - -#[test] -#[timeout(8000)] -/// Syncs three textfiles from ./data to ./output and checks that their contents match -fn inputless_filesync_test() { - let data = vec![ - ("1.txt", create_data()), - ("2.txt", create_data()), - ("3.txt", create_data()), - ]; - - for file in &data { - let filepath = String::from("./data/") + file.0; - let mut writer = BufWriter::new(File::create(filepath).unwrap()); - writer.write_all(file.1.as_bytes()).unwrap(); - } - - let server_handle = thread::spawn(|| { - // Start the server in the local network, timeouts after 5 secs of inactivity - block_on(server::listen( - 8080u16, - PathBuf::from("./data"), - 8192usize, - true, - 5, - true, - )) - .unwrap(); - }); - - let client_handle = thread::spawn(|| { - // Run the client inputless - block_on(client::connect( - String::from("127.0.0.1:8080"), - PathBuf::from("./output"), - "test".to_string(), - true, - )) - .unwrap(); - }); - - client_handle.join().unwrap(); - - // Sleep to give server time to start up - sleep(Duration::from_millis(500)); - - server_handle.join().unwrap(); - - for file in data { - let filepath = String::from("./output/") + file.0; - let content = read_to_string(filepath).unwrap(); - - assert_eq!( - content, file.1, - "Output [{}] does not match input [{}]", - content, file.1 - ); - - remove_file(String::from("./output/") + file.0).unwrap(); - remove_file(String::from("./data/") + file.0).unwrap(); - } -} - -fn create_data() -> String { - thread_rng() - .sample_iter(&Alphanumeric) - .take(30) - .map(char::from) - .collect::() -} diff --git a/tests/sockets_integration.rs b/tests/sockets_integration.rs new file mode 100644 index 0000000..3f2dea1 --- /dev/null +++ b/tests/sockets_integration.rs @@ -0,0 +1,82 @@ +use fragilebyte::{common::Message, connector::Connector, listener::Listener}; +use ntest::timeout; +use rand::{distributions::Alphanumeric, thread_rng, Rng}; +use std::{ + fs::{self, File}, + io::{BufWriter, Write}, + net::SocketAddr, + path::PathBuf, + thread, +}; +use tokio::sync::mpsc; +use tokio_test::block_on; + +#[test] +#[timeout(2000)] +/// Tests communication between GUI and individual handlers by mocking GUI signals. +fn filesync_signals() { + let testdata = vec![ + ("1.txt", generate_data()), + ("2.txt", generate_data()), + ("3.txt", generate_data()), + ]; + + let mut paths = Vec::new(); + + for file in &testdata { + let filepath = String::from("./tests/data/") + file.0; + let mut writer = BufWriter::new(File::create(filepath.clone()).unwrap()); + paths.push(filepath); + writer.write_all(file.1.as_bytes()).unwrap(); + } + + let output_path = PathBuf::from("./tests/output/"); + let server_addr = SocketAddr::from(([127, 0, 0, 1], 9191)); + + let (kill_server_tx, server_rx) = mpsc::channel::(2); + let (server_tx, mut local_server_rx) = mpsc::channel::(2); + let (local_client_tx, client_rx) = mpsc::channel::(2); + let (client_tx, mut local_client_rx) = mpsc::channel::(2); + + let server_handle = thread::spawn(move || { + let listener = Listener::new(server_addr, "xyz", 8192usize); + block_on(listener.start(server_tx, server_rx, paths)).unwrap(); + }); + + let server_channel_handle = thread::spawn(move || { + block_on(local_server_rx.recv()).unwrap(); // ClientConnect + block_on(local_server_rx.recv()).unwrap(); // ConnectionReady + block_on(local_server_rx.recv()).unwrap(); // ClientDisconnect + block_on(kill_server_tx.send(Message::Shutdown)).unwrap(); + }); + + let client_handle = thread::spawn(move || { + let output_path = output_path.clone(); + let connector = Connector::new(server_addr, "xyz", output_path); + block_on(connector.connect(client_tx, client_rx)).unwrap() + }); + + let client_channel_handle = thread::spawn(move || { + block_on(local_client_rx.recv()).unwrap(); // Metadata(HashMap) + block_on(local_client_tx.send(Message::ClientReqAll)).unwrap(); + block_on(local_client_tx.send(Message::Shutdown)).unwrap(); + }); + + client_handle.join().unwrap(); + client_channel_handle.join().unwrap(); + server_handle.join().unwrap(); + server_channel_handle.join().unwrap(); + + for file in testdata { + fs::remove_file(String::from("./tests/output/") + file.0).unwrap(); + fs::remove_file(String::from("./tests/data/") + file.0).unwrap(); + } +} + +fn generate_data() -> String { + thread_rng() + .sample_iter(&Alphanumeric) + .take(30) + .map(char::from) + .collect::() +}