From a5da1c3a34d2f2e203be72cb86dd3de6c8bf6159 Mon Sep 17 00:00:00 2001 From: AB-UK Date: Tue, 10 Mar 2026 15:33:06 +0000 Subject: [PATCH] Server implemented. Linux client implemented. --- .gitignore | 1 + Cargo.lock | 2228 +++++++++++++++++++++++++++ Cargo.toml | 8 + furumi-client-core/Cargo.toml | 16 + furumi-client-core/src/client.rs | 125 ++ furumi-client-core/src/error.rs | 18 + furumi-client-core/src/lib.rs | 5 + furumi-common/Cargo.toml | 12 + furumi-common/build.rs | 12 + furumi-common/proto/virtualfs.proto | 41 + furumi-common/src/lib.rs | 3 + furumi-mount-linux/Cargo.toml | 16 + furumi-mount-linux/src/fs.rs | 265 ++++ furumi-mount-linux/src/main.rs | 55 + furumi-server/Cargo.toml | 28 + furumi-server/src/main.rs | 68 + furumi-server/src/security/mod.rs | 83 + furumi-server/src/server.rs | 101 ++ furumi-server/src/vfs/local.rs | 197 +++ furumi-server/src/vfs/mod.rs | 20 + 20 files changed, 3302 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 furumi-client-core/Cargo.toml create mode 100644 furumi-client-core/src/client.rs create mode 100644 furumi-client-core/src/error.rs create mode 100644 furumi-client-core/src/lib.rs create mode 100644 furumi-common/Cargo.toml create mode 100644 furumi-common/build.rs create mode 100644 furumi-common/proto/virtualfs.proto create mode 100644 furumi-common/src/lib.rs create mode 100644 furumi-mount-linux/Cargo.toml create mode 100644 furumi-mount-linux/src/fs.rs create mode 100644 furumi-mount-linux/src/main.rs create mode 100644 furumi-server/Cargo.toml create mode 100644 furumi-server/src/main.rs create mode 100644 furumi-server/src/security/mod.rs create mode 100644 furumi-server/src/server.rs create mode 100644 furumi-server/src/vfs/local.rs create mode 100644 furumi-server/src/vfs/mod.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2ac5d18 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2228 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "async-lock" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "aws-lc-rs" +version = "1.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94bffc006df10ac2a68c83692d734a465f8ee6c5b384d8545a636f81d858f4bf" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4321e568ed89bb5a7d291a7f37997c2c0df89809d7b6d12062c81ddb54aa782e" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower 0.5.3", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "furumi-client-core" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "furumi-common", + "moka", + "prost", + "thiserror", + "tokio", + "tokio-stream", + "tonic", + "tracing", +] + +[[package]] +name = "furumi-common" +version = "0.1.0" +dependencies = [ + "prost", + "protobuf-src", + "tonic", + "tonic-build", +] + +[[package]] +name = "furumi-mount-linux" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "furumi-client-core", + "furumi-common", + "fuser", + "libc", + "tokio", + "tokio-stream", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "furumi-server" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-stream", + "async-trait", + "bytes", + "clap", + "furumi-common", + "futures", + "futures-core", + "futures-util", + "jsonwebtoken", + "libc", + "prost", + "rustls", + "tempfile", + "thiserror", + "tokio", + "tokio-stream", + "tonic", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "fuser" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53274f494609e77794b627b1a3cddfe45d675a6b2e9ba9c0fdc8d8eee2184369" +dependencies = [ + "libc", + "log", + "memchr", + "nix", + "page_size", + "pkg-config", + "smallvec", + "zerocopy", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "wasip2", + "wasip3", +] + +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.13.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "libc", + "pin-project-lite", + "socket2 0.6.3", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "jsonwebtoken" +version = "10.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0529410abe238729a60b108898784df8984c87f6054c9c4fcacc47e4803c1ce1" +dependencies = [ + "base64", + "getrandom 0.2.17", + "js-sys", + "pem", + "serde", + "serde_json", + "signature", + "simple_asn1", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "moka" +version = "0.12.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85f8024e1c8e71c778968af91d43700ce1d11b219d127d79fb2934153b82b42b" +dependencies = [ + "async-lock", + "crossbeam-channel", + "crossbeam-epoch", + "crossbeam-utils", + "equivalent", + "event-listener", + "futures-util", + "parking_lot", + "portable-atomic", + "smallvec", + "tagptr", + "uuid", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "page_size" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64", + "serde_core", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap 2.13.0", +] + +[[package]] +name = "pin-project" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[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.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" +dependencies = [ + "prost", +] + +[[package]] +name = "protobuf-src" +version = "2.1.1+27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6217c3504da19b85a3a4b2e9a5183d635822d83507ba0986624b5c05b83bfc40" +dependencies = [ + "cmake", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core", +] + +[[package]] +name = "simple_asn1" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d585997b0ac10be3c5ee635f1bab02d512760d14b7c468801ac8a01d9ae5f1d" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + +[[package]] +name = "tempfile" +version = "3.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.6.3", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost", + "socket2 0.5.10", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.13.0", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zerocopy" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c9a3719 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = [ + "furumi-common", + "furumi-server", + "furumi-client-core", + "furumi-mount-linux" +] +resolver = "2" diff --git a/furumi-client-core/Cargo.toml b/furumi-client-core/Cargo.toml new file mode 100644 index 0000000..f6864a0 --- /dev/null +++ b/furumi-client-core/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "furumi-client-core" +version = "0.1.0" +edition = "2024" + +[dependencies] +furumi-common = { path = "../furumi-common" } +anyhow = "1.0.102" +prost = "0.13.5" +tokio = { version = "1.50.0", features = ["full"] } +tokio-stream = "0.1.18" +tonic = "0.12.3" +thiserror = "2.0.18" +moka = { version = "0.12.10", features = ["sync", "future"] } +async-trait = "0.1.89" +tracing = "0.1.44" diff --git a/furumi-client-core/src/client.rs b/furumi-client-core/src/client.rs new file mode 100644 index 0000000..27e3fc7 --- /dev/null +++ b/furumi-client-core/src/client.rs @@ -0,0 +1,125 @@ +use crate::error::{ClientError, Result}; +use furumi_common::proto::{ + remote_file_system_client::RemoteFileSystemClient, AttrResponse, DirEntry, FileChunk, + PathRequest, ReadRequest, +}; +use moka::future::Cache; +use std::time::Duration; +use tokio_stream::StreamExt; +use tonic::codegen::InterceptedService; +use tonic::metadata::MetadataValue; +use tonic::transport::{Channel, Endpoint}; +use tonic::{Request, Status}; +use tracing::{debug, info}; + +#[derive(Clone)] +pub struct AuthInterceptor { + token: String, +} + +impl tonic::service::Interceptor for AuthInterceptor { + fn call(&mut self, mut request: Request<()>) -> std::result::Result, Status> { + if !self.token.is_empty() { + let token_str = format!("Bearer {}", self.token); + let meta_val = MetadataValue::try_from(&token_str) + .map_err(|_| Status::invalid_argument("Invalid token format"))?; + request.metadata_mut().insert("authorization", meta_val); + } + Ok(request) + } +} + +pub type GrpcClient = RemoteFileSystemClient>; + +#[derive(Clone)] +pub struct FurumiClient { + client: GrpcClient, + attr_cache: Cache, +} + +impl FurumiClient { + /// Connects to the Furumi-ng server with an optional bearer token. + pub async fn connect(addr: &str, token: &str) -> Result { + let endpoint = Endpoint::from_shared(addr.to_string()) + .map_err(|e| ClientError::Internal(format!("Invalid URI: {}", e)))? + .timeout(Duration::from_secs(30)) + .concurrency_limit(256) + .tcp_keepalive(Some(Duration::from_secs(60))) + .http2_keep_alive_interval(Duration::from_secs(60)); + + info!("Connecting to {}", addr); + let channel = endpoint.connect().await?; + + let interceptor = AuthInterceptor { + token: token.to_string(), + }; + + let client = RemoteFileSystemClient::with_interceptor(channel, interceptor); + + let attr_cache = Cache::builder() + .max_capacity(100_000) + .time_to_live(Duration::from_secs(5)) // short TTL to catch up changes quickly + .build(); + + Ok(Self { client, attr_cache }) + } + + /// Fetches file attributes from the server, utilizing an internal cache. + pub async fn get_attr(&self, path: &str) -> Result { + if let Some(attr) = self.attr_cache.get(path).await { + return Ok(attr); + } + + debug!("get_attr (cache miss): {}", path); + let mut client = self.client.clone(); + let req = tonic::Request::new(PathRequest { + path: path.to_string(), + }); + + let response = client.get_attr(req).await?.into_inner(); + + self.attr_cache.insert(path.to_string(), response.clone()).await; + + Ok(response) + } + + /// Reads directory contents from the server stream. + pub async fn read_dir(&self, path: &str) -> Result> { + debug!("read_dir: {}", path); + let mut client = self.client.clone(); + let req = tonic::Request::new(PathRequest { + path: path.to_string(), + }); + + let mut stream = client.read_dir(req).await?.into_inner(); + let mut entries = Vec::new(); + + while let Some(chunk) = stream.next().await { + let entry = chunk?; + entries.push(entry); + } + + Ok(entries) + } + + /// Fetches file chunk stream from the server. Returns the streaming receiver. + pub async fn read_file( + &self, + path: &str, + offset: u64, + size: u32, + chunk_size: u32, + ) -> Result> { + debug!("read_file: {} offset={} size={}", path, offset, size); + let mut client = self.client.clone(); + let req = tonic::Request::new(ReadRequest { + path: path.to_string(), + offset, + size, + chunk_size, + }); + + let stream = client.read_file(req).await?.into_inner(); + Ok(stream) + } +} diff --git a/furumi-client-core/src/error.rs b/furumi-client-core/src/error.rs new file mode 100644 index 0000000..32b2d17 --- /dev/null +++ b/furumi-client-core/src/error.rs @@ -0,0 +1,18 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ClientError { + #[error("Connect error: {0}")] + Connect(#[from] tonic::transport::Error), + + #[error("RPC error: {0}")] + Rpc(#[from] tonic::Status), + + #[error("Invalid path: {0}")] + InvalidPath(String), + + #[error("Internal error: {0}")] + Internal(String), +} + +pub type Result = std::result::Result; diff --git a/furumi-client-core/src/lib.rs b/furumi-client-core/src/lib.rs new file mode 100644 index 0000000..8053af6 --- /dev/null +++ b/furumi-client-core/src/lib.rs @@ -0,0 +1,5 @@ +pub mod client; +pub mod error; + +pub use client::FurumiClient; +pub use error::ClientError; diff --git a/furumi-common/Cargo.toml b/furumi-common/Cargo.toml new file mode 100644 index 0000000..a6403a2 --- /dev/null +++ b/furumi-common/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "furumi-common" +version = "0.1.0" +edition = "2024" + +[dependencies] +prost = "0.13.5" +tonic = "0.12.3" + +[build-dependencies] +protobuf-src = "2.1.1" +tonic-build = "0.12.3" diff --git a/furumi-common/build.rs b/furumi-common/build.rs new file mode 100644 index 0000000..d629323 --- /dev/null +++ b/furumi-common/build.rs @@ -0,0 +1,12 @@ +fn main() -> Result<(), Box> { + println!("cargo:rerun-if-changed=proto/virtualfs.proto"); + unsafe { + std::env::set_var("PROTOC", protobuf_src::protoc()); + } + + tonic_build::configure() + .build_server(true) + .build_client(true) + .compile_protos(&["proto/virtualfs.proto"], &["proto"])?; + Ok(()) +} diff --git a/furumi-common/proto/virtualfs.proto b/furumi-common/proto/virtualfs.proto new file mode 100644 index 0000000..04ee658 --- /dev/null +++ b/furumi-common/proto/virtualfs.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; +package virtualfs; + +message PathRequest { + string path = 1; +} + +message AttrResponse { + uint64 size = 1; + uint32 mode = 2; // Permissions and file type + uint64 mtime = 3; // Modification time + // ... other standard stat attributes +} + +message DirEntry { + string name = 1; + uint32 type = 2; // File or Directory, mapping roughly to libc::DT_REG, libc::DT_DIR, etc. +} + +message ReadRequest { + string path = 1; + uint64 offset = 2; + uint32 size = 3; + // Optional requested chunk size. If 0, the server uses its default chunk size. + uint32 chunk_size = 4; +} + +message FileChunk { + bytes data = 1; +} + +service RemoteFileSystem { + // Get file or directory attributes (size, permissions, timestamps). Maps to stat/getattr. + rpc GetAttr (PathRequest) returns (AttrResponse); + + // List directory contents. Uses Server Streaming to handle massively large directories efficiently. + rpc ReadDir (PathRequest) returns (stream DirEntry); + + // Read chunks of a file. Uses Server Streaming for efficient chunk delivery based on offset/size. + rpc ReadFile (ReadRequest) returns (stream FileChunk); +} diff --git a/furumi-common/src/lib.rs b/furumi-common/src/lib.rs new file mode 100644 index 0000000..28624d5 --- /dev/null +++ b/furumi-common/src/lib.rs @@ -0,0 +1,3 @@ +pub mod proto { + tonic::include_proto!("virtualfs"); +} diff --git a/furumi-mount-linux/Cargo.toml b/furumi-mount-linux/Cargo.toml new file mode 100644 index 0000000..1fdd7f2 --- /dev/null +++ b/furumi-mount-linux/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "furumi-mount-linux" +version = "0.1.0" +edition = "2024" + +[dependencies] +furumi-common = { path = "../furumi-common" } +furumi-client-core = { path = "../furumi-client-core" } +anyhow = "1.0.102" +fuser = "0.15.0" +libc = "0.2.183" +clap = { version = "4.5.60", features = ["derive", "env"] } +tracing = "0.1.44" +tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } +tokio = { version = "1.50.0", features = ["full"] } +tokio-stream = "0.1.18" diff --git a/furumi-mount-linux/src/fs.rs b/furumi-mount-linux/src/fs.rs new file mode 100644 index 0000000..04ed6d9 --- /dev/null +++ b/furumi-mount-linux/src/fs.rs @@ -0,0 +1,265 @@ +use fuser::{ + FileAttr, FileType, Filesystem, ReplyAttr, ReplyData, ReplyDirectory, ReplyEntry, Request, +}; +use furumi_client_core::FurumiClient; +use std::collections::HashMap; +use std::ffi::OsStr; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, UNIX_EPOCH}; +use tracing::{debug, error}; +use tokio::runtime::Handle; + +const TTL: Duration = Duration::from_secs(1); // 1 second FUSE kernel TTL + +pub struct FurumiFuse { + client: FurumiClient, + rt_handle: Handle, + // FUSE deals in inodes (u64). We need to map inode -> string path. + // In a real VFS, this requires a proper tree or bidirectional map. + // For simplicity: inode 1 is always the root "/". + inode_to_path: Arc>>, + // Mapping path back to inode to keep them consistent + path_to_inode: Arc>>, + next_inode: Arc>, +} + +impl FurumiFuse { + pub fn new(client: FurumiClient, rt_handle: Handle) -> Self { + let mut inode_to_path = HashMap::new(); + let mut path_to_inode = HashMap::new(); + + // Root inode is always 1 + inode_to_path.insert(1, "/".to_string()); + path_to_inode.insert("/".to_string(), 1); + + Self { + client, + rt_handle, + inode_to_path: Arc::new(Mutex::new(inode_to_path)), + path_to_inode: Arc::new(Mutex::new(path_to_inode)), + next_inode: Arc::new(Mutex::new(2)), // Inodes start from 2 + } + } + + fn get_inode(&self, path: &str) -> u64 { + let mut p2i = self.path_to_inode.lock().unwrap(); + if let Some(&inode) = p2i.get(path) { + inode + } else { + let mut next = self.next_inode.lock().unwrap(); + let inode = *next; + *next += 1; + p2i.insert(path.to_string(), inode); + self.inode_to_path.lock().unwrap().insert(inode, path.to_string()); + inode + } + } + + fn get_path(&self, inode: u64) -> Option { + self.inode_to_path.lock().unwrap().get(&inode).cloned() + } + + fn make_attr(inode: u64, attr: &furumi_common::proto::AttrResponse) -> FileAttr { + let kind = if attr.mode & libc::S_IFDIR != 0 { + FileType::Directory + } else { + FileType::RegularFile + }; + + FileAttr { + ino: inode, + size: attr.size, + blocks: (attr.size + 511) / 512, + atime: UNIX_EPOCH + Duration::from_secs(attr.mtime), + mtime: UNIX_EPOCH + Duration::from_secs(attr.mtime), + ctime: UNIX_EPOCH + Duration::from_secs(attr.mtime), + crtime: UNIX_EPOCH + Duration::from_secs(attr.mtime), + kind, + perm: (attr.mode & 0o777) as u16, + nlink: if kind == FileType::Directory { 2 } else { 1 }, + uid: unsafe { libc::getuid() }, // Mount as current user + gid: unsafe { libc::getgid() }, + rdev: 0, + blksize: 4096, + flags: 0, + } + } +} + +impl Filesystem for FurumiFuse { + fn lookup(&mut self, _req: &Request, parent: u64, name: &OsStr, reply: ReplyEntry) { + let name_str = name.to_string_lossy(); + debug!("lookup: parent={} name={}", parent, name_str); + + let parent_path = match self.get_path(parent) { + Some(p) => p, + None => { + reply.error(libc::ENOENT); + return; + } + }; + + let full_path = if parent_path == "/" { + format!("/{}", name_str) + } else { + format!("{}/{}", parent_path, name_str) + }; + + let client = self.client.clone(); + let path_clone = full_path.clone(); + + // Must block inside FUSE callbacks because fuser is synchronous + let attr_res = self.rt_handle.block_on(async { + client.get_attr(&path_clone).await + }); + + match attr_res { + Ok(attr) => { + let inode = self.get_inode(&full_path); + reply.entry(&TTL, &Self::make_attr(inode, &attr), 0); + } + Err(_) => { + reply.error(libc::ENOENT); + } + } + } + + fn getattr(&mut self, _req: &Request, ino: u64, _fh: Option, reply: ReplyAttr) { + debug!("getattr: ino={}", ino); + + let path = match self.get_path(ino) { + Some(p) => p, + None => { + reply.error(libc::ENOENT); + return; + } + }; + + let client = self.client.clone(); + let attr_res = self.rt_handle.block_on(async { + client.get_attr(&path).await + }); + + match attr_res { + Ok(attr) => { + reply.attr(&TTL, &Self::make_attr(ino, &attr)); + } + Err(_) => reply.error(libc::EIO), + } + } + + fn readdir( + &mut self, + _req: &Request, + ino: u64, + _fh: u64, + offset: i64, + mut reply: ReplyDirectory, + ) { + debug!("readdir: ino={} offset={}", ino, offset); + + let path = match self.get_path(ino) { + Some(p) => p, + None => { + reply.error(libc::ENOENT); + return; + } + }; + + let client = self.client.clone(); + let dir_res = self.rt_handle.block_on(async { + client.read_dir(&path).await + }); + + match dir_res { + Ok(entries) => { + // FUSE readdir requires us to push entries. + // offset 0 is ., offset 1 is .. + if offset == 0 { + let _ = reply.add(ino, 1, FileType::Directory, "."); + let _ = reply.add(ino, 2, FileType::Directory, ".."); + } + + for (i, entry) in entries.iter().enumerate() { + let entry_offset = (i + 2) as i64; + if entry_offset < offset { + continue; + } + + let full_path = if path == "/" { + format!("/{}", entry.name) + } else { + format!("{}/{}", path, entry.name) + }; + + let child_ino = self.get_inode(&full_path); + let kind = if entry.r#type == 4 { + FileType::Directory + } else { + FileType::RegularFile + }; + + // reply.add returns true if the buffer is full + if reply.add(child_ino, entry_offset + 1, kind, &entry.name) { + break; + } + } + reply.ok(); + } + Err(e) => { + error!("readdir error: {:?}", e); + reply.error(libc::EIO); + } + } + } + + fn read( + &mut self, + _req: &Request, + ino: u64, + _fh: u64, + offset: i64, + size: u32, + _flags: i32, + _lock_owner: Option, + reply: ReplyData, + ) { + debug!("read: ino={} offset={} size={}", ino, offset, size); + + let path = match self.get_path(ino) { + Some(p) => p, + None => { + reply.error(libc::ENOENT); + return; + } + }; + + let client = self.client.clone(); + + // We use block_on to convert the gRPC stream into a synchronous read for FUSE + let read_res: Result, String> = self.rt_handle.block_on(async { + match client.read_file(&path, offset as u64, size, size).await { + Ok(mut stream) => { + use tokio_stream::StreamExt; + let mut data = Vec::new(); + while let Some(chunk_res) = stream.next().await { + match chunk_res { + Ok(chunk) => data.extend_from_slice(&chunk.data), + Err(e) => return Err(e.to_string()), + } + } + Ok(data) + } + Err(e) => Err(e.to_string()), + } + }); + + match read_res { + Ok(data) => reply.data(&data), + Err(e) => { + error!("read error: {:?}", e); + reply.error(libc::EIO); + } + } + } +} diff --git a/furumi-mount-linux/src/main.rs b/furumi-mount-linux/src/main.rs new file mode 100644 index 0000000..9eed6f4 --- /dev/null +++ b/furumi-mount-linux/src/main.rs @@ -0,0 +1,55 @@ +pub mod fs; + +use clap::Parser; +use fuser::MountOption; +use std::path::PathBuf; +use furumi_client_core::FurumiClient; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct Args { + /// Server address to connect to + #[arg(short, long, env = "FURUMI_SERVER", default_value = "http://[::1]:50051")] + server: String, + + /// Authentication Bearer token (leave empty if auth is disabled on server) + #[arg(short, long, env = "FURUMI_TOKEN", default_value = "")] + token: String, + + /// Mount point directory + #[arg(short, long, env = "FURUMI_MOUNT")] + mount: PathBuf, +} + +fn main() -> Result<(), Box> { + tracing_subscriber::fmt::init(); + + let args = Args::parse(); + + if !args.mount.exists() || !args.mount.is_dir() { + eprintln!("Error: Mount point {:?} does not exist or is not a directory", args.mount); + std::process::exit(1); + } + + // Create a robust tokio runtime for the background gRPC work + let rt = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build()?; + + let client = rt.block_on(async { + FurumiClient::connect(&args.server, &args.token).await + })?; + + let fs = fs::FurumiFuse::new(client, rt.handle().clone()); + + let options = vec![ + MountOption::RO, + MountOption::FSName("furumi-ng".to_string()), + MountOption::NoExec, // Better security for media mount + ]; + + println!("Mounting Furumi-ng to {:?}", args.mount); + fuser::mount2(fs, args.mount, &options)?; + + Ok(()) +} diff --git a/furumi-server/Cargo.toml b/furumi-server/Cargo.toml new file mode 100644 index 0000000..c32e62f --- /dev/null +++ b/furumi-server/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "furumi-server" +version = "0.1.0" +edition = "2024" + +[dependencies] +furumi-common = { path = "../furumi-common" } +anyhow = "1.0.102" +bytes = "1.11.1" +clap = { version = "4.5.60", features = ["derive", "env"] } +futures = "0.3.32" +futures-core = "0.3.32" +futures-util = "0.3.32" +jsonwebtoken = "10.3.0" +libc = "0.2.183" +prost = "0.13.5" +rustls = "0.23.37" +thiserror = "2.0.18" +tokio = { version = "1.50.0", features = ["full"] } +tokio-stream = "0.1.18" +tonic = "0.12.3" +tracing = "0.1.44" +tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } +async-stream = "0.3.6" +async-trait = "0.1.89" + +[dev-dependencies] +tempfile = "3.26.0" diff --git a/furumi-server/src/main.rs b/furumi-server/src/main.rs new file mode 100644 index 0000000..2da4018 --- /dev/null +++ b/furumi-server/src/main.rs @@ -0,0 +1,68 @@ +pub mod vfs; +pub mod security; +pub mod server; + +use std::path::PathBuf; +use std::sync::Arc; +use clap::Parser; +use tonic::transport::Server; +use vfs::local::LocalVfs; +use furumi_common::proto::remote_file_system_server::RemoteFileSystemServer; +use server::RemoteFileSystemImpl; +use security::AuthInterceptor; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct Args { + /// IP address and port to bind the server to + #[arg(short, long, env = "FURUMI_BIND", default_value = "[::1]:50051")] + bind: String, + + /// Document root directory to expose via VFS + #[arg(short, long, env = "FURUMI_ROOT", default_value = ".")] + root: PathBuf, + + /// Authentication Bearer token (leave empty to disable auth) + #[arg(short, long, env = "FURUMI_TOKEN", default_value = "")] + token: String, +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + tracing_subscriber::fmt::init(); + + let args = Args::parse(); + let addr = args.bind.parse()?; + + // Resolve the document root to an absolute path for safety and clarity + let root_path = std::fs::canonicalize(&args.root) + .unwrap_or_else(|_| args.root.clone()); + + if !root_path.exists() || !root_path.is_dir() { + eprintln!("Error: Root path {:?} does not exist or is not a directory", root_path); + std::process::exit(1); + } + + let vfs = Arc::new(LocalVfs::new(&root_path)); + let remote_fs = RemoteFileSystemImpl::new(vfs); + let auth = AuthInterceptor::new(args.token.clone()); + let svc = RemoteFileSystemServer::with_interceptor(remote_fs, auth.clone()); + + println!("Furumi-ng Server listening on {}", addr); + if args.token.is_empty() { + println!("WARNING: Authentication is DISABLED"); + } else { + println!("Authentication is enabled (Bearer token required)"); + } + println!("Document Root: {:?}", root_path); + + Server::builder() + // Enable TCP Keep-Alive and HTTP2 Ping to keep connections alive for long media streams + .tcp_keepalive(Some(std::time::Duration::from_secs(60))) + .http2_keepalive_interval(Some(std::time::Duration::from_secs(60))) + .add_service(svc) + .serve(addr) + .await?; + + Ok(()) +} diff --git a/furumi-server/src/security/mod.rs b/furumi-server/src/security/mod.rs new file mode 100644 index 0000000..8bb76bd --- /dev/null +++ b/furumi-server/src/security/mod.rs @@ -0,0 +1,83 @@ +use std::path::{Component, Path}; +use tonic::{Request, Status}; + +/// Sanitizes a path strictly to prevent Path Traversal. +/// Rejects paths containing absolute routes outside the conceptual root +/// or any parent directory (`..`) traversal components. +pub fn sanitize_path(input: &str) -> std::result::Result { + let path = Path::new(input); + let mut normalized = std::path::PathBuf::new(); + + for component in path.components() { + match component { + Component::ParentDir => { + if !normalized.pop() { + return Err(Status::permission_denied("Path traversal attempt")); + } + } + Component::Normal(c) => normalized.push(c), + Component::CurDir | Component::RootDir | Component::Prefix(_) => { + // Ignore RootDir (making absolute paths logic relative to VFS root) + // Ignore Prefix (Windows C:) + // Ignore CurrentDir (.) + } + } + } + + Ok(normalized.to_string_lossy().into_owned()) +} + +/// A simple tonic interceptor for token-based authorization. +/// We expect a `authorization: Bearer ` header. +#[derive(Clone)] +pub struct AuthInterceptor { + expected_token: String, +} + +impl AuthInterceptor { + pub fn new(token: String) -> Self { + Self { expected_token: token } + } +} + +impl tonic::service::Interceptor for AuthInterceptor { + fn call(&mut self, req: Request<()>) -> std::result::Result, Status> { + // If no token is configured on the server, allow all (or reject all based on policy). + // Here we assume if expected_token is empty, auth is disabled. + if self.expected_token.is_empty() { + return Ok(req); + } + + match req.metadata().get("authorization") { + Some(t) => { + let token_str = t.to_str().unwrap_or(""); + let expected_header = format!("Bearer {}", self.expected_token); + if token_str == expected_header { + Ok(req) + } else { + Err(Status::unauthenticated("Invalid token")) + } + } + _ => Err(Status::unauthenticated("Missing authorization header")), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_sanitize_path_normal() { + assert_eq!(sanitize_path("etc/passwd").unwrap(), "etc/passwd"); + assert_eq!(sanitize_path("/etc/passwd").unwrap(), "etc/passwd"); + assert_eq!(sanitize_path("foo/./bar").unwrap(), "foo/bar"); + } + + #[test] + fn test_sanitize_path_traversal() { + assert!(sanitize_path("../etc/passwd").is_err()); + assert!(sanitize_path("/../etc/passwd").is_err()); + assert!(sanitize_path("foo/../../etc/passwd").is_err()); + } +} diff --git a/furumi-server/src/server.rs b/furumi-server/src/server.rs new file mode 100644 index 0000000..abb09b8 --- /dev/null +++ b/furumi-server/src/server.rs @@ -0,0 +1,101 @@ +use std::pin::Pin; +use tokio_stream::Stream; +use tonic::{Request, Response, Status}; + +use crate::vfs::VirtualFileSystem; +use furumi_common::proto::{ + remote_file_system_server::RemoteFileSystem, AttrResponse, DirEntry, FileChunk, + PathRequest, ReadRequest, +}; +use crate::security::sanitize_path; + +pub struct RemoteFileSystemImpl { + vfs: std::sync::Arc, +} + +impl RemoteFileSystemImpl { + pub fn new(vfs: std::sync::Arc) -> Self { + Self { vfs } + } +} + +#[tonic::async_trait] +impl RemoteFileSystem for RemoteFileSystemImpl { + async fn get_attr( + &self, + request: Request, + ) -> Result, Status> { + let req = request.into_inner(); + let safe_path = sanitize_path(&req.path)?; + + match self.vfs.get_attr(&safe_path).await { + Ok(attr) => Ok(Response::new(attr)), + Err(e) => Err(Status::internal(e.to_string())), + } + } + + type ReadDirStream = Pin< + Box< + dyn Stream> + Send + 'static, + >, + >; + + async fn read_dir( + &self, + request: Request, + ) -> Result, Status> { + let req = request.into_inner(); + let safe_path = sanitize_path(&req.path)?; + + match self.vfs.read_dir(&safe_path).await { + Ok(mut rx) => { + let stream = async_stream::try_stream! { + while let Some(result) = rx.recv().await { + match result { + Ok(entry) => yield entry, + Err(e) => Err(Status::internal(e.to_string()))?, + } + } + }; + Ok(Response::new(Box::pin(stream) as Self::ReadDirStream)) + } + Err(e) => Err(Status::internal(e.to_string())), + } + } + + type ReadFileStream = Pin< + Box< + dyn Stream> + Send + 'static, + >, + >; + + async fn read_file( + &self, + request: Request, + ) -> Result, Status> { + let req = request.into_inner(); + let safe_path = sanitize_path(&req.path)?; + + let sanitized_req = ReadRequest { + path: safe_path, + offset: req.offset, + size: req.size, + chunk_size: req.chunk_size, + }; + + match self.vfs.read_file(sanitized_req).await { + Ok(mut rx) => { + let stream = async_stream::try_stream! { + while let Some(result) = rx.recv().await { + match result { + Ok(chunk) => yield chunk, + Err(e) => Err(Status::internal(e.to_string()))?, + } + } + }; + Ok(Response::new(Box::pin(stream) as Self::ReadFileStream)) + } + Err(e) => Err(Status::internal(e.to_string())), + } + } +} diff --git a/furumi-server/src/vfs/local.rs b/furumi-server/src/vfs/local.rs new file mode 100644 index 0000000..16b4705 --- /dev/null +++ b/furumi-server/src/vfs/local.rs @@ -0,0 +1,197 @@ +use super::VirtualFileSystem; +use furumi_common::proto::{AttrResponse, DirEntry, FileChunk, ReadRequest}; +use anyhow::{Context, Result}; +use std::os::unix::fs::MetadataExt; +use std::path::{Path, PathBuf}; +use tokio::fs; +use tokio::io::{AsyncReadExt, AsyncSeekExt}; +use tokio::sync::mpsc::{self, Receiver}; + +pub struct LocalVfs { + root: PathBuf, +} + +impl LocalVfs { + pub fn new>(root: P) -> Self { + Self { + root: root.as_ref().to_path_buf(), + } + } + + /// Appends the sanitized relative path to the root. + fn resolve_path(&self, relative_path: &str) -> Result { + let rel_path = Path::new(relative_path); + // Note: Security module will handle path traversal sanitization before reaching this point. + // We assume `relative_path` is safe and strictly logical here. + let stripped = rel_path.strip_prefix("/").unwrap_or(rel_path); + Ok(self.root.join(stripped)) + } +} + +#[async_trait::async_trait] +impl VirtualFileSystem for LocalVfs { + async fn get_attr(&self, path: &str) -> Result { + let full_path = self.resolve_path(path)?; + let metadata = fs::metadata(&full_path).await.context("Failed to get metadata")?; + + Ok(AttrResponse { + size: metadata.len(), + mode: metadata.mode(), + mtime: metadata.mtime() as u64, + }) + } + + async fn read_dir(&self, path: &str) -> Result>> { + let full_path = self.resolve_path(path)?; + let mut dir = fs::read_dir(&full_path).await.context("Failed to read directory")?; + + let (tx, rx) = mpsc::channel(100); + + tokio::spawn(async move { + while let Ok(Some(entry)) = dir.next_entry().await { + // In Linux, DT_REG = 8, DT_DIR = 4. We can approximate this. + let file_type = entry.file_type().await.ok(); + let mut type_val = 0; + if let Some(ft) = file_type { + if ft.is_dir() { + type_val = 4; // DT_DIR roughly + } else if ft.is_file() { + type_val = 8; // DT_REG roughly + } + } + + let dir_entry = DirEntry { + name: entry.file_name().to_string_lossy().into_owned(), + r#type: type_val, + }; + + if tx.send(Ok(dir_entry)).await.is_err() { + break; + } + } + }); + + Ok(rx) + } + + async fn read_file(&self, req: ReadRequest) -> Result>> { + let full_path = self.resolve_path(&req.path)?; + let mut file = fs::File::open(&full_path).await.context("Failed to open file")?; + + // Seek to the requested offset + file.seek(std::io::SeekFrom::Start(req.offset)).await.context("Failed to seek in file")?; + + // Inform the kernel about our sequential read pattern for aggressive read-ahead + #[cfg(target_os = "linux")] + { + use std::os::unix::io::AsRawFd; + let fd = file.as_raw_fd(); + // POSIX_FADV_SEQUENTIAL = 2 + unsafe { + libc::posix_fadvise(fd, req.offset as libc::off_t, req.size as libc::off_t, libc::POSIX_FADV_SEQUENTIAL); + } + } + + // Limit chunks to 1MB default, or user requested, capping at 4MB for sanity + let mut chunk_size = req.chunk_size as usize; + if chunk_size == 0 { + chunk_size = 1024 * 1024; // 1 MB default + } + chunk_size = chunk_size.min(4 * 1024 * 1024); + + // Keep the channel size small (2-4 chunks) to apply backpressure and save memory + let (tx, rx) = mpsc::channel(4); + let max_size = req.size; + + tokio::spawn(async move { + let mut remaining = max_size; + use bytes::BytesMut; + + while remaining > 0 { + let to_read = (remaining as usize).min(chunk_size); + let mut buffer = BytesMut::zeroed(to_read); + + match file.read(&mut buffer).await { + Ok(0) => break, // EOF + Ok(n) => { + buffer.truncate(n); + let chunk = FileChunk { + data: buffer.freeze().to_vec(), + }; + remaining = remaining.saturating_sub(n as u32); + if tx.send(Ok(chunk)).await.is_err() { + break; // Client disconnected + } + } + Err(e) => { + let _ = tx.send(Err(e.into())).await; + break; + } + } + } + }); + + Ok(rx) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::io::Write; + use tempfile::tempdir; + + #[tokio::test] + async fn test_local_vfs_get_attr() { + let dir = tempdir().unwrap(); + let file_path = dir.path().join("test.txt"); + let mut file = std::fs::File::create(&file_path).unwrap(); + file.write_all(b"hello world").unwrap(); + + let vfs = LocalVfs::new(dir.path()); + let attr = vfs.get_attr("test.txt").await.unwrap(); + assert_eq!(attr.size, 11); + } + + #[tokio::test] + async fn test_local_vfs_read_dir() { + let dir = tempdir().unwrap(); + std::fs::File::create(dir.path().join("file1.txt")).unwrap(); + std::fs::create_dir(dir.path().join("subdir")).unwrap(); + + let vfs = LocalVfs::new(dir.path()); + let mut rx = vfs.read_dir("/").await.unwrap(); + + let mut entries = Vec::new(); + while let Some(Ok(entry)) = rx.recv().await { + entries.push(entry.name); + } + + assert!(entries.contains(&"file1.txt".to_string())); + assert!(entries.contains(&"subdir".to_string())); + } + + #[tokio::test] + async fn test_local_vfs_read_file() { + let dir = tempdir().unwrap(); + let file_path = dir.path().join("data.bin"); + let mut file = std::fs::File::create(&file_path).unwrap(); + file.write_all(b"0123456789").unwrap(); // 10 bytes + + let vfs = LocalVfs::new(dir.path()); + let req = ReadRequest { + path: "data.bin".to_string(), + offset: 2, + size: 5, + chunk_size: 0, + }; + + let mut rx = vfs.read_file(req).await.unwrap(); + let mut result = Vec::new(); + while let Some(Ok(chunk)) = rx.recv().await { + result.extend_from_slice(&chunk.data); + } + + assert_eq!(result, b"23456"); // bytes from offset 2, length 5 + } +} diff --git a/furumi-server/src/vfs/mod.rs b/furumi-server/src/vfs/mod.rs new file mode 100644 index 0000000..bac5621 --- /dev/null +++ b/furumi-server/src/vfs/mod.rs @@ -0,0 +1,20 @@ +pub mod local; + +use anyhow::Result; +use tokio::sync::mpsc::Receiver; + +use furumi_common::proto::{AttrResponse, DirEntry, FileChunk, ReadRequest}; + +/// Abstract Virtual File System trait representing the remote server operations. +#[async_trait::async_trait] +pub trait VirtualFileSystem: Send + Sync + 'static { + /// Get attributes for a file or directory. + async fn get_attr(&self, path: &str) -> Result; + + /// Read directory entries. Returns a stream (Receiver) of DirEntry. + /// Uses Result inside the Receiver to propagate individual entry errors if any. + async fn read_dir(&self, path: &str) -> Result>>; + + /// Read chunks of a file. Returns a stream (Receiver) of FileChunk. + async fn read_file(&self, req: ReadRequest) -> Result>>; +}