commit 77f9604dceb301c32668eaf05040a9641080be1a Author: AB Date: Wed Jun 3 18:44:25 2020 +0300 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/http-fuse.iml b/.idea/http-fuse.iml new file mode 100644 index 0000000..9b4cf84 --- /dev/null +++ b/.idea/http-fuse.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3a37236 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9186724 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Run_furumi.xml b/.idea/runConfigurations/Run_furumi.xml new file mode 100644 index 0000000..9e9cb93 --- /dev/null +++ b/.idea/runConfigurations/Run_furumi.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e3eaa2e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "env": { + "RUST_BACKTRACE": "1", + }, + "request": "launch", + "name": "Debug executable 'furumi'", + "cargo": { + "args": [ + "run", + "--", + "--conf", + "/etc/mus-fuse.yml" + ], + }, + "cwd": "${workspaceFolder}", + "postDebugTask": "Umount FUSE", + "preLaunchTask": "Umount FUSE", + } + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'furumi'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=furumi", + "--package=furumi" + ], + "filter": { + "name": "furumi", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ], +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4fbbf1e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "lldb.displayFormat": "auto", + "lldb.showDisassembly": "never", + "lldb.dereferencePointers": true +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..05a822f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,14 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Umount FUSE", + "type": "shell", + "command": "fusermount -u mnt", + "group": "build", + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..40d2722 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1845 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "anyhow" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff" + +[[package]] +name = "arc-swap" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62" + +[[package]] +name = "async-trait" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da71fef07bc806586090247e971229289f64c210a278ee5ae419314eb386b31d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "base64" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bumpalo" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "bytes" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" + +[[package]] +name = "cc" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" +dependencies = [ + "num-integer", + "num-traits 0.2.11", + "time", +] + +[[package]] +name = "clap" +version = "2.33.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", + "yaml-rust 0.3.5", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "config" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9107d78ed62b3fa5a86e7d18e647abed48cfd8f8fab6c72f4cdb982d196f7e6" +dependencies = [ + "lazy_static 1.4.0", + "nom", + "rust-ini", + "serde 1.0.106", + "serde-hjson", + "serde_json", + "toml", + "yaml-rust 0.4.3", +] + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "ctrlc" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a4ba686dff9fa4c1c9636ce1010b0cf98ceb421361b0bb3d6faeec43bd217a7" +dependencies = [ + "nix", + "winapi 0.3.8", +] + +[[package]] +name = "dtoa" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" + +[[package]] +name = "encoding_rs" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" + +[[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 = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "furumi" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64", + "chrono", + "clap", + "config", + "ctrlc", + "env_logger", + "futures", + "futures-intrusive", + "libc", + "log", + "percent-encoding", + "polyfuse", + "polyfuse-tokio", + "reqwest", + "serde 1.0.106", + "serde_json", + "size_format", + "slab", + "time", + "tokio", + "tracing", + "tracing-futures", + "tracing-subscriber", +] + +[[package]] +name = "futures" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" + +[[package]] +name = "futures-executor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2c14b89bb14a9ec2f724a8cd9653b83b8e3f7ed510cc6129a36785dfe8cc9f1" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" + +[[package]] +name = "futures-macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" + +[[package]] +name = "futures-task" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" + +[[package]] +name = "futures-util" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "h2" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "log", + "slab", + "tokio", + "tokio-util", +] + +[[package]] +name = "hermit-abi" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "hyper" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6e7655b9594024ad0ee439f3b5a7299369dc2a3f459b47c696f9ff676f9aa1f" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "log", + "pin-project", + "socket2", + "time", + "tokio", + "tower-service", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-tls", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +dependencies = [ + "autocfg", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" + +[[package]] +name = "js-sys" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce10c23ad2ea25ceca0093bd3192229da4c5b3c0f2de499c1ecac0d98d452177" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" + +[[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.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" + +[[package]] +name = "linked-hash-map" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" +dependencies = [ + "serde 0.8.23", + "serde_test", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" + +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" + +[[package]] +name = "memoffset" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow 0.2.1", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-named-pipes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" +dependencies = [ + "log", + "mio", + "miow 0.3.3", + "winapi 0.3.8", +] + +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +dependencies = [ + "iovec", + "libc", + "mio", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "miow" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" +dependencies = [ + "socket2", + "winapi 0.3.8", +] + +[[package]] +name = "native-tls" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +dependencies = [ + "lazy_static 1.4.0", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "net2" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "nix" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "void", +] + +[[package]] +name = "nom" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +dependencies = [ + "memchr", + "version_check 0.1.5", +] + +[[package]] +name = "num" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" +dependencies = [ + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits 0.2.11", +] + +[[package]] +name = "num-complex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +dependencies = [ + "autocfg", + "num-traits 0.2.11", +] + +[[package]] +name = "num-integer" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +dependencies = [ + "autocfg", + "num-traits 0.2.11", +] + +[[package]] +name = "num-iter" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00" +dependencies = [ + "autocfg", + "num-integer", + "num-traits 0.2.11", +] + +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +dependencies = [ + "autocfg", + "num-integer", + "num-traits 0.2.11", +] + +[[package]] +name = "num-traits" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +dependencies = [ + "num-traits 0.2.11", +] + +[[package]] +name = "num-traits" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "openssl" +version = "0.10.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "lazy_static 1.4.0", + "libc", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7410fef80af8ac071d4f63755c0ab89ac3df0fd1ea91f1d1f37cf5cec4395990" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api", + "parking_lot_core", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec 0.6.13", + "winapi 0.3.8", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edc93aeee735e60ecb40cf740eb319ff23eab1c5748abfdb5c180e4ce49f7791" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" + +[[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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + +[[package]] +name = "polyfuse" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c86bdb29d99db89a3bc9b526be16876fabcdbe0e591e62834f73e9e1d7bca47" +dependencies = [ + "async-trait", + "bitflags", + "bytes", + "futures", + "lazy_static 1.4.0", + "libc", + "memoffset", + "pin-project-lite", + "smallvec 0.6.13", + "tracing", +] + +[[package]] +name = "polyfuse-tokio" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50251fce76caef59c98616649af93f0e277ed2987c72f391119c7412546b6e4" +dependencies = [ + "bytes", + "futures", + "libc", + "mio", + "polyfuse", + "tokio", + "tracing", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" + +[[package]] +name = "proc-macro-hack" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" + +[[package]] +name = "proc-macro-nested" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" + +[[package]] +name = "proc-macro2" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[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", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "regex" +version = "1.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" + +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "reqwest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "hyper-tls", + "js-sys", + "lazy_static 1.4.0", + "log", + "mime", + "mime_guess", + "native-tls", + "percent-encoding", + "pin-project-lite", + "serde 1.0.106", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rust-ini" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static 1.4.0", + "winapi 0.3.8", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "security-framework" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" + +[[package]] +name = "serde" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-hjson" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b833c5ad67d52ced5f5938b2980f32a9c1c5ef047f0b4fb3127e7a423c76153" +dependencies = [ + "lazy_static 0.2.11", + "linked-hash-map 0.3.0", + "num-traits 0.1.43", + "regex", + "serde 0.8.23", +] + +[[package]] +name = "serde_derive" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" +dependencies = [ + "itoa", + "ryu", + "serde 1.0.106", +] + +[[package]] +name = "serde_test" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" +dependencies = [ + "serde 0.8.23", +] + +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde 1.0.106", + "url", +] + +[[package]] +name = "sharded-slab" +version = "0.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" +dependencies = [ + "lazy_static 1.4.0", +] + +[[package]] +name = "signal-hook-registry" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +dependencies = [ + "arc-swap", + "libc", +] + +[[package]] +name = "size_format" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed5f6ab2122c6dec69dca18c72fa4590a27e581ad20d44960fe74c032a0b23b" +dependencies = [ + "generic-array", + "num", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "smallvec" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" + +[[package]] +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "syn" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.8", +] + +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static 1.4.0", +] + +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "tokio" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9c43f1bb96970e153bcbae39a65e249ccb942bd9d36dbdf086024920417c9c" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static 1.4.0", + "libc", + "memchr", + "mio", + "mio-named-pipes", + "mio-uds", + "num_cpus", + "pin-project-lite", + "signal-hook-registry", + "slab", + "tokio-macros", + "winapi 0.3.8", +] + +[[package]] +name = "tokio-macros" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" +dependencies = [ + "serde 1.0.106", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "tracing" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1721cc8cf7d770cc4257872507180f35a4797272f5962f24c806af9e7faf52ab" +dependencies = [ + "cfg-if", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fbad39da2f9af1cae3016339ad7f2c7a9e870f12e8fd04c4fd7ef35b30c0d2b" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aa83a9a47081cd522c09c81b31aec2c9273424976f922ad61c053b58350b715" +dependencies = [ + "lazy_static 1.4.0", +] + +[[package]] +name = "tracing-futures" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" +dependencies = [ + "lazy_static 1.4.0", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ccba2f8f16e0ed268fc765d9b7ff22e965e7185d32f8f1ec8294fe17d86e79" +dependencies = [ + "serde 1.0.106", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d53c40489aa69c9aed21ff483f26886ca8403df33bdc2d2f87c60c1617826d2" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static 1.4.0", + "matchers", + "regex", + "serde 1.0.106", + "serde_json", + "sharded-slab", + "smallvec 1.4.0", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "try-lock" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check 0.9.2", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +dependencies = [ + "smallvec 1.4.0", +] + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasm-bindgen" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0" +dependencies = [ + "cfg-if", + "serde 1.0.106", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded84f06e0ed21499f6184df0e0cb3494727b0c5da89534e0fcc55c51d812101" +dependencies = [ + "bumpalo", + "lazy_static 1.4.0", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64487204d863f109eb77e8462189d111f27cb5712cc9fdb3461297a76963a2f6" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9ba19973a58daf4db6f352eda73dc0e289493cd29fb2632eb172085b6521acd" + +[[package]] +name = "web-sys" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b72fe77fd39e4bd3eaa4412fd299a0be6b3dfe9d2597e2f1c20beb968f41d17" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.8", +] + +[[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 = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "yaml-rust" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" + +[[package]] +name = "yaml-rust" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" +dependencies = [ + "linked-hash-map 0.5.3", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..53b41fb --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "furumi" +version = "0.1.0" +authors = ["AB "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +polyfuse = "0.3.3" +polyfuse-tokio = "0.2" +tracing-subscriber = "0.2.5" +libc = "0.2.69" +anyhow = "1" +slab = "0.4" +tracing = "0.1" +tracing-futures = "0.2" +futures = "0.3" +futures-intrusive = "0.2" + +# config deps +reqwest = { version = "0.10", features = ["json", "blocking"] } +tokio = { version = "0.2", features = ["full"] } +serde = { version = "1.0", features = ["derive"] } +clap = {version = "2.33", features = ["yaml"]} +serde_json = "1.0" +percent-encoding = "2.1" +time = "0.1" +chrono = "0.4" +env_logger = "0.7" +log = { version = "^0.4.5", features = ["std"] } +size_format = "1.0" +base64 = "0.12" +ctrlc = "3.1" +config = "0.9" + +[dev-dependencies.tokio] +version = "0.2" +features = [ "full" ] + diff --git a/assets/umount.sh b/assets/umount.sh new file mode 100644 index 0000000..c64c477 --- /dev/null +++ b/assets/umount.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +fusermount -u "$1" || true \ No newline at end of file diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..7d7ea0d --- /dev/null +++ b/src/config.rs @@ -0,0 +1,87 @@ +use clap::{App, Arg}; +use std::process; + +extern crate chrono; +extern crate config; + + +#[derive(Default, Debug, Clone, PartialEq)] +pub struct Config { + pub server: String, + pub mountpoint: String, + pub username: Option, + pub password: Option, + pub conf_file: String, +} + + +pub fn read() -> Config { + // Parse opts and args + let cli_args = App::new(env!("CARGO_PKG_NAME")) + .version(env!("CARGO_PKG_VERSION")) + .author(env!("CARGO_PKG_AUTHORS")) + .about(env!("CARGO_PKG_DESCRIPTION")) + .arg( + Arg::with_name("conf") + .short("c") + .long("conf") + .help("Config file to use") + .takes_value(true) + .required(true), + ) + .get_matches(); + + info!("Logger initialized. Set RUST_LOG=[debug,error,info,warn,trace] Default: info"); + info!("Starting {} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")); + + // Read config file and env vars + let config_file = cli_args.value_of("conf").unwrap(); + let mut settings = config::Config::default(); + settings = match settings.merge(config::File::with_name(config_file)) { + Ok(conf_content) => { + info!("Using config file {}", config_file); + conf_content.to_owned() + } + Err(e) => { + error!("Can't read config file - {}", e); + process::exit(0x0001); + } + }; + let server = match settings.get_str("server") { + Ok(server) => server, + Err(_) => { + error!("Server is not set in config. Set `server` directive."); + process::exit(0x0002); + } + }; + let mountpoint = match settings.get_str("mountpoint") { + Ok(mountpoint) => mountpoint, + Err(_) => { + error!("Mountpoint is not set in config. Set `mountpoint` directive."); + process::exit(0x0003); + } + }; + + let username = match settings.get_str("username") { + Ok(username) => Some(username), + Err(_) => { + None + } + }; + let password = match settings.get_str("password") { + Ok(password) => Some(password), + Err(_) => { + None + } + }; + if password == None || username == None { + warn!("Insecure server detected. Set `username` and `password` directives to use auth."); + } + Config { + server: server, + username: username, + password: password, + mountpoint: mountpoint, + conf_file: config_file.to_string(), + } +} \ No newline at end of file diff --git a/src/filesystem.rs b/src/filesystem.rs new file mode 100644 index 0000000..17aba13 --- /dev/null +++ b/src/filesystem.rs @@ -0,0 +1,945 @@ +#![allow(clippy::unnecessary_mut_passed)] +#![deny(clippy::unimplemented)] + +use crate::config; +use crate::http; + + +use polyfuse::{ + io::{Reader, Writer}, + op, + reply::{Collector, Reply, ReplyAttr, ReplyEntry, ReplyOpen, ReplyWrite, ReplyXattr}, + Context, DirEntry, FileAttr, Filesystem, Forget, Operation, +}; +use slab::Slab; +use std::{ + collections::hash_map::{Entry, HashMap}, + ffi::{OsStr, OsString}, + fmt::Debug, + io, + sync::Arc, + time::Duration, +}; +use tokio::sync::Mutex; +use tracing_futures::Instrument; +use std::path::Path; + + +type Ino = u64; + +#[derive(Debug)] +struct INodeTable { + map: HashMap>>, + next_ino: Ino, +} + +impl INodeTable { + fn new() -> Self { + Self { + map: HashMap::new(), + next_ino: 1, // a + } + } + + fn vacant_entry(&mut self) -> VacantEntry<'_> { + let ino = self.next_ino; + VacantEntry { table: self, ino } + } + + fn get(&self, ino: Ino) -> Option>> { + self.map.get(&ino).cloned() + } + + fn remove(&mut self, ino: Ino) -> Option>> { + self.map.remove(&ino) + } +} + +#[derive(Debug)] +struct VacantEntry<'a> { + table: &'a mut INodeTable, + ino: u64, +} + +impl VacantEntry<'_> { + fn ino(&self) -> Ino { + self.ino + } + + fn insert(self, inode: INode) { + let Self { table, ino } = self; + table.map.insert(ino, Arc::new(Mutex::new(inode))); + table.next_ino += 1; + } +} + +#[derive(Debug)] +struct INode { + attr: FileAttr, + xattrs: HashMap>>, + refcount: u64, + links: u64, + kind: INodeKind, +} + +#[derive(Debug)] +enum INodeKind { + RegularFile(Vec), + Directory(Directory), + Symlink(Arc), +} + +#[derive(Debug, Clone)] +struct Directory { + children: HashMap, + parent: Option, +} + +impl Directory { + fn collect_entries(&self, attr: &FileAttr) -> Vec> { + let mut entries = Vec::with_capacity(self.children.len() + 2); + let mut offset: u64 = 1; + + entries.push(Arc::new(DirEntry::dir(".", attr.ino(), offset))); + offset += 1; + + entries.push(Arc::new(DirEntry::dir( + "..", + self.parent.unwrap_or_else(|| attr.ino()), + offset, + ))); + offset += 1; + + for (name, &ino) in &self.children { + entries.push(Arc::new(DirEntry::new(name, ino, offset))); + offset += 1; + } + + entries + } +} + +#[derive(Debug)] +struct DirHandle { + entries: Vec>, +} + +#[derive(Debug)] +pub struct MemFS { + inodes: Mutex, + ttl: Duration, + dir_handles: Mutex>>>, + cfg: config::Config, +} + +impl MemFS { + pub fn new(cfg: &config::Config) -> Self { + let mut inodes = INodeTable::new(); + //let self.cfg = cfg; + //let entries = http::list_directory(&cfg.server, &cfg.username, &cfg.password, "/").await; + inodes.vacant_entry().insert(INode { + attr: { + let mut attr = FileAttr::default(); + attr.set_ino(1); + attr.set_nlink(2); + attr.set_mode(libc::S_IFDIR | 0o755); + attr + }, + xattrs: HashMap::new(), + refcount: u64::max_value() / 2, + links: u64::max_value() / 2, + kind: INodeKind::Directory(Directory { + children: HashMap::new(), + parent: None, + }), + }); + + Self { + inodes: Mutex::new(inodes), + dir_handles: Mutex::default(), + ttl: Duration::from_secs(60 * 60 * 24), + cfg: cfg.clone(), + } + } + + fn make_entry_reply(&self, ino: Ino, attr: FileAttr) -> ReplyEntry { + let mut reply = ReplyEntry::default(); + reply.ino(ino); + reply.attr(attr); + reply.ttl_entry(self.ttl); + reply + } + + async fn lookup_inode(&self, parent: Ino, name: &OsStr) -> io::Result { + // warn!("==> lookup_inode: parent: {:?}, name: {:?}", parent, name); + + let inodes = self.inodes.lock().await; + + let parent = inodes.get(parent).ok_or_else(no_entry)?; + let parent = parent.lock().await; + + let parent = match parent.kind { + INodeKind::Directory(ref dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + let child_ino = parent.children.get(&*name).copied().ok_or_else(no_entry)?; + let child = inodes.get(child_ino).unwrap_or_else(|| unreachable!()); + let mut child = child.lock().await; + child.refcount += 1; + // warn!("==> lookup_inode: child_ino: {:?}, child.attr: {:?}", child_ino, child.attr); + Ok(self.make_entry_reply(child_ino, child.attr)) + } + + async fn make_node(&self, parent: Ino, name: &OsStr, f: F) -> io::Result + where + F: FnOnce(&VacantEntry<'_>) -> INode, + { + // debug!("make_node: parent: {:?}, name: {:?}", parent, name); + let mut inodes = self.inodes.lock().await; + + let parent = inodes.get(parent).ok_or_else(no_entry)?; + let mut parent = parent.lock().await; + + let parent = match parent.kind { + INodeKind::Directory(ref mut dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + match parent.children.entry(name.into()) { + Entry::Occupied(..) => Err(io::Error::from_raw_os_error(libc::EEXIST)), + Entry::Vacant(map_entry) => { + let inode_entry = inodes.vacant_entry(); + let inode = f(&inode_entry); + + let reply = self.make_entry_reply(inode_entry.ino(), inode.attr); + map_entry.insert(inode_entry.ino()); + inode_entry.insert(inode); + + Ok(reply) + } + } + } + + async fn link_node(&self, ino: u64, newparent: Ino, newname: &OsStr) -> io::Result { + { + let inodes = self.inodes.lock().await; + + let inode = inodes.get(ino).ok_or_else(no_entry)?; + + let newparent = inodes.get(newparent).ok_or_else(no_entry)?; + let mut newparent = newparent.lock().await; + let newparent = match newparent.kind { + INodeKind::Directory(ref mut dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + match newparent.children.entry(newname.into()) { + Entry::Occupied(..) => return Err(io::Error::from_raw_os_error(libc::EEXIST)), + Entry::Vacant(entry) => { + entry.insert(ino); + let mut inode = inode.lock().await; + let inode = &mut *inode; + inode.links += 1; + inode.attr.set_nlink(inode.attr.nlink() + 1); + } + } + } + + self.lookup_inode(newparent, newname).await + } + + async fn unlink_node(&self, parent: Ino, name: &OsStr) -> io::Result<()> { + let inodes = self.inodes.lock().await; + + let parent = inodes.get(parent).ok_or_else(no_entry)?; + let mut parent = parent.lock().await; + let parent = match parent.kind { + INodeKind::Directory(ref mut dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + let &ino = parent.children.get(name).ok_or_else(no_entry)?; + + let inode = inodes.get(ino).unwrap_or_else(|| unreachable!()); + let mut inode = inode.lock().await; + let inode = &mut *inode; + + match inode.kind { + INodeKind::Directory(ref dir) if !dir.children.is_empty() => { + return Err(io::Error::from_raw_os_error(libc::ENOTEMPTY)); + } + _ => (), + } + + parent + .children + .remove(name) + .unwrap_or_else(|| unreachable!()); + + inode.links = inode.links.saturating_sub(1); + inode.attr.set_nlink(inode.attr.nlink().saturating_sub(1)); + + Ok(()) + } + + async fn rename_node(&self, parent: Ino, name: &OsStr, newname: &OsStr) -> io::Result<()> { + let inodes = self.inodes.lock().await; + + let parent = inodes.get(parent).ok_or_else(no_entry)?; + let mut parent = parent.lock().await; + let parent = match parent.kind { + INodeKind::Directory(ref mut dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + let &ino = parent.children.get(name).ok_or_else(no_entry)?; + + match parent.children.entry(newname.into()) { + Entry::Occupied(..) => Err(io::Error::from_raw_os_error(libc::EEXIST)), + Entry::Vacant(entry) => { + entry.insert(ino); + parent + .children + .remove(name) + .unwrap_or_else(|| unreachable!()); + Ok(()) + } + } + } + + async fn graft_node( + &self, + parent: Ino, + name: &OsStr, + newparent: Ino, + newname: &OsStr, + ) -> io::Result<()> { + debug_assert_ne!(parent, newparent); + + let inodes = self.inodes.lock().await; + + let parent = inodes.get(parent).ok_or_else(no_entry)?; + let mut parent = parent.lock().await; + let parent = match parent.kind { + INodeKind::Directory(ref mut dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + let newparent = inodes.get(newparent).ok_or_else(no_entry)?; + let mut newparent = newparent.lock().await; + let newparent = match newparent.kind { + INodeKind::Directory(ref mut dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + match newparent.children.entry(newname.into()) { + Entry::Occupied(..) => Err(io::Error::from_raw_os_error(libc::EEXIST)), + Entry::Vacant(entry) => { + let ino = parent.children.remove(name).ok_or_else(no_entry)?; + entry.insert(ino); + Ok(()) + } + } + } + + async fn do_lookup(&self, op: &op::Lookup<'_>) -> io::Result { + // warn!("do_lookup: op: {:?}", op); + let gg = self.lookup_inode(op.parent(), op.name()).await; + // warn!("===> do_lookup: lookup_inode: {:?}", gg); + gg + } + + async fn do_forget(&self, forgets: &[Forget]) { + let mut inodes = self.inodes.lock().await; + + for forget in forgets { + if let Some(inode) = inodes.get(forget.ino()) { + let mut inode = inode.lock().await; + inode.refcount = inode.refcount.saturating_sub(forget.nlookup()); + if inode.refcount == 0 && inode.links == 0 { + inodes.remove(forget.ino()); + } + } + } + } + + async fn do_getattr(&self, op: &op::Getattr<'_>) -> io::Result { + // warn!("do_getattr: op: {:?}", op); + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let inode = inode.lock().await; + + let mut reply = ReplyAttr::new(inode.attr); + reply.ttl_attr(self.ttl); + + Ok(reply) + } + + async fn do_setattr(&self, op: &op::Setattr<'_>) -> io::Result { + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let mut inode = inode.lock().await; + + if let Some(mode) = op.mode() { + inode.attr.set_mode(mode); + } + if let Some(uid) = op.uid() { + inode.attr.set_uid(uid); + } + if let Some(gid) = op.gid() { + inode.attr.set_gid(gid); + } + if let Some(size) = op.size() { + inode.attr.set_size(size); + } + if let Some(atime) = op.atime() { + inode.attr.set_atime(atime); + } + if let Some(mtime) = op.mtime() { + inode.attr.set_mtime(mtime); + } + if let Some(ctime) = op.ctime() { + inode.attr.set_ctime(ctime); + } + + let mut reply = ReplyAttr::new(inode.attr); + reply.ttl_attr(self.ttl); + + Ok(reply) + } + + async fn do_readlink(&self, op: &op::Readlink<'_>) -> io::Result> { + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let inode = inode.lock().await; + + match inode.kind { + INodeKind::Symlink(ref link) => Ok(link.clone()), + _ => Err(io::Error::from_raw_os_error(libc::EINVAL)), + } + } + + pub async fn fetch_remote(&self, path: &Path, parent: u64) -> io::Result<()> { + let remote_entries = http::list_directory( + &self.cfg.server, &self.cfg.username, &self.cfg.password, path).await.unwrap(); + for r_entry in remote_entries.iter(){ + match &r_entry.r#type { + Some(r#type) => { + match r#type.as_str() { + "file" => { + let f_name = r_entry.name.as_ref().unwrap(); + self.make_node( + parent, OsStr::new(f_name.as_str()), |entry| { + INode { + attr: { + // debug!("Adding file {:?} - {:?}", f_name, entry); + let mut attr = FileAttr::default(); + attr.set_ino(entry.ino()); + attr.set_mtime(r_entry.parse_rfc2822()); + attr.set_size(r_entry.size.unwrap()); + attr.set_nlink(1); + attr.set_mode(libc::S_IFREG | 0o444); + attr + }, + xattrs: HashMap::new(), + refcount: 1, + links: 1, + kind: INodeKind::RegularFile(vec![]), + } + }) + .await; + } + "directory" => { + let f_name = r_entry.name.as_ref().unwrap(); + self.make_node( + parent, OsStr::new(f_name.as_str()), |entry| { + INode { + attr: { + // debug!("Adding directory {:?} - {:?}", f_name, entry); + let mut attr = FileAttr::default(); + attr.set_ino(entry.ino()); + attr.set_mtime(r_entry.parse_rfc2822()); + attr.set_nlink(1); + attr.set_mode(libc::S_IFDIR | 0o755); + attr + }, + xattrs: HashMap::new(), + refcount: u64::max_value() / 2, + links: u64::max_value() / 2, + kind: INodeKind::Directory(Directory { + children: HashMap::new(), + parent: Some(parent), + }), + } + }).await; + } + &_ => {} + } + } + None => {} + } + } + Ok(()) + } + + async fn full_path(&self, inode: u64) { + + } + + async fn do_opendir(&self, op: &op::Opendir<'_>) -> io::Result { + // debug!("do_opendir: op: {:?}", op); + + let mut dirs = self.dir_handles.lock().await; + info!("dirs: {:?}", dirs); + for x in dirs { + info!("x: {:?}", x); + + } + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + + let inode = inode.lock().await; + + let children = match &inode.kind { + INodeKind::Directory(dir) => { + match dir.parent { + Some(parent) => { + let par_inode = inodes.get(parent).ok_or_else(no_entry)?; + let par_inode = par_inode.lock().await; + + let _uri = match &par_inode.kind { + INodeKind::Directory(dir) => { + dir.children.clone() + } + _ => HashMap::new() + }; + _uri + } + None => HashMap::new() + } + } + _ => {HashMap::new()} + }; + + let mut uri = Path::new("/"); + for (name, inode) in &children { + if inode == &op.ino() { + uri = Path::new(name.as_os_str()); + } + } + + drop(dirs); + drop(inodes); + drop(inode); + self.fetch_remote(uri, op.ino()).await; + + let mut dirs = self.dir_handles.lock().await; + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + + let inode = inode.lock().await; + + + if inode.attr.nlink() == 0 { + return Err(no_entry()); + } + let dir = match inode.kind { + INodeKind::Directory(ref dir) => dir, + _ => return Err(io::Error::from_raw_os_error(libc::ENOTDIR)), + }; + + let key = dirs.insert(Arc::new(Mutex::new(DirHandle { + entries: dir.collect_entries(&inode.attr), + }))); + + Ok(ReplyOpen::new(key as u64)) + } + + async fn do_readdir(&self, op: &op::Readdir<'_>) -> io::Result { + // warn!("do_readdir: op: {:?}", op); + let dirs = self.dir_handles.lock().await; + + let dir = dirs + .get(op.fh() as usize) + .cloned() + .ok_or_else(unknown_error)?; + let dir = dir.lock().await; + + let mut total_len = 0; + let entries: Vec<_> = dir + .entries + .iter() + .skip(op.offset() as usize) + .take_while(|entry| { + let entry: &DirEntry = &*entry; + total_len += entry.as_ref().len() as u32; + total_len < op.size() + }) + .cloned() + .collect(); + + Ok(entries) + } + + async fn do_releasedir(&self, op: &op::Releasedir<'_>) -> io::Result<()> { + let mut dirs = self.dir_handles.lock().await; + + let dir = dirs.remove(op.fh() as usize); + drop(dir); + + Ok(()) + } + + async fn do_mknod(&self, op: &op::Mknod<'_>) -> io::Result { + warn!("do_mknod: op: {:?}", op); + match op.mode() & libc::S_IFMT { + libc::S_IFREG => (), + _ => return Err(io::Error::from_raw_os_error(libc::ENOTSUP)), + } + + self.make_node(op.parent(), op.name(), |entry| INode { + attr: { + let mut attr = FileAttr::default(); + attr.set_ino(entry.ino()); + attr.set_nlink(1); + attr.set_mode(op.mode()); + attr + }, + xattrs: HashMap::new(), + refcount: 1, + links: 1, + kind: INodeKind::RegularFile(vec![]), + }) + .await + } + + async fn do_mkdir(&self, op: &op::Mkdir<'_>) -> io::Result { + // warn!("do_mkdir: op: {:?}", op); + self.make_node(op.parent(), op.name(), |entry| INode { + attr: { + let mut attr = FileAttr::default(); + attr.set_ino(entry.ino()); + attr.set_nlink(2); + attr.set_mode(op.mode() | libc::S_IFDIR); + attr + }, + xattrs: HashMap::new(), + refcount: 1, + links: 1, + kind: INodeKind::Directory(Directory { + children: HashMap::new(), + parent: Some(op.parent()), + }), + }) + .await + } + + async fn do_symlink(&self, op: &op::Symlink<'_>) -> io::Result { + self.make_node(op.parent(), op.name(), |entry| INode { + attr: { + let mut attr = FileAttr::default(); + attr.set_ino(entry.ino()); + attr.set_nlink(1); + attr.set_mode(libc::S_IFLNK | 0o777); + attr + }, + xattrs: HashMap::new(), + refcount: 1, + links: 1, + kind: INodeKind::Symlink(Arc::new(op.link().into())), + }) + .await + } + + async fn do_link(&self, op: &op::Link<'_>) -> io::Result { + self.link_node(op.ino(), op.newparent(), op.newname()).await + } + + async fn do_unlink(&self, op: &op::Unlink<'_>) -> io::Result<()> { + self.unlink_node(op.parent(), op.name()).await + } + + async fn do_rmdir(&self, op: &op::Rmdir<'_>) -> io::Result<()> { + self.unlink_node(op.parent(), op.name()).await + } + + async fn do_rename(&self, op: &op::Rename<'_>) -> io::Result<()> { + if op.flags() != 0 { + // TODO: handle RENAME_NOREPLACE and RENAME_EXCHANGE. + return Err(io::Error::from_raw_os_error(libc::EINVAL)); + } + + match (op.parent(), op.newparent()) { + (parent, newparent) if parent == newparent => { + self.rename_node(parent, op.name(), op.newname()).await + } + (parent, newparent) => { + self.graft_node(parent, op.name(), newparent, op.newname()) + .await + } + } + } + + async fn do_getxattr(&self, op: &op::Getxattr<'_>) -> io::Result { + // warn!("do_getxattr: op: {:?}", op); + + let inodes = self.inodes.lock().await; + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let inode = inode.lock().await; + + let value = inode + .xattrs + .get(op.name()) + .ok_or_else(|| io::Error::from_raw_os_error(libc::ENODATA))?; + + match op.size() { + 0 => Ok(Either::Left(ReplyXattr::new(value.len() as u32))), + size => { + if value.len() as u32 > size { + return Err(io::Error::from_raw_os_error(libc::ERANGE)); + } + Ok(Either::Right(value.clone())) + } + } + } + + async fn do_setxattr(&self, op: &op::Setxattr<'_>) -> io::Result<()> { + // warn!("do_setxattr: op: {:?}", op); + + let create = op.flags() as i32 & libc::XATTR_CREATE != 0; + let replace = op.flags() as i32 & libc::XATTR_REPLACE != 0; + if create && replace { + return Err(io::Error::from_raw_os_error(libc::EINVAL)); + } + + let inodes = self.inodes.lock().await; + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let mut inode = inode.lock().await; + + match inode.xattrs.entry(op.name().into()) { + Entry::Occupied(..) if create => Err(io::Error::from_raw_os_error(libc::EEXIST)), + Entry::Occupied(entry) => { + let value = Arc::make_mut(entry.into_mut()); + *value = op.value().into(); + Ok(()) + } + Entry::Vacant(..) if replace => Err(io::Error::from_raw_os_error(libc::ENODATA)), + Entry::Vacant(entry) => { + if create { + entry.insert(Arc::default()); + } else { + entry.insert(Arc::new(op.value().into())); + } + Ok(()) + } + } + } + + async fn do_listxattr(&self, op: &op::Listxattr<'_>) -> io::Result { + // warn!("do_listxattr: op: {:?}", op); + let inodes = self.inodes.lock().await; + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let inode = inode.lock().await; + + match op.size() { + 0 => { + let total_len = inode.xattrs.keys().map(|name| name.len() as u32 + 1).sum(); + Ok(Either::Left(ReplyXattr::new(total_len))) + } + size => { + let mut total_len = 0; + let names = inode.xattrs.keys().fold(OsString::new(), |mut acc, name| { + acc.push(name); + acc.push("\0"); + total_len += name.len() as u32 + 1; + acc + }); + + if total_len > size { + return Err(io::Error::from_raw_os_error(libc::ERANGE)); + } + + Ok(Either::Right(names)) + } + } + } + + async fn do_removexattr(&self, op: &op::Removexattr<'_>) -> io::Result<()> { + let inodes = self.inodes.lock().await; + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let mut inode = inode.lock().await; + + match inode.xattrs.entry(op.name().into()) { + Entry::Occupied(entry) => { + entry.remove(); + Ok(()) + } + Entry::Vacant(..) => Err(io::Error::from_raw_os_error(libc::ENODATA)), + } + } + + async fn do_read(&self, op: &op::Read<'_>) -> io::Result { + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let inode = inode.lock().await; + + let content = match inode.kind { + INodeKind::RegularFile(ref content) => content, + _ => return Err(io::Error::from_raw_os_error(libc::EINVAL)), + }; + + let offset = op.offset() as usize; + let size = op.size() as usize; + + let content = content.get(offset..).unwrap_or(&[]); + let content = &content[..std::cmp::min(content.len(), size)]; + + Ok(content.to_vec()) + } + + async fn do_write( + &self, + op: &op::Write<'_>, + reader: &mut R, + ) -> io::Result + where + R: Reader + Unpin, + { + let inodes = self.inodes.lock().await; + + let inode = inodes.get(op.ino()).ok_or_else(no_entry)?; + let mut inode = inode.lock().await; + let inode = &mut *inode; + + let content = match inode.kind { + INodeKind::RegularFile(ref mut content) => content, + _ => return Err(io::Error::from_raw_os_error(libc::EINVAL)), + }; + + let offset = op.offset() as usize; + let size = op.size() as usize; + + content.resize(offset + size, 0); + + use futures::io::AsyncReadExt; + reader + .read_exact(&mut content[offset..offset + size]) + .await?; + + inode.attr.set_size(content.len() as u64); + + Ok(ReplyWrite::new(op.size())) + } +} + +#[polyfuse::async_trait] +impl Filesystem for MemFS { + #[allow(clippy::cognitive_complexity)] + async fn call<'a, 'cx, T: ?Sized>( + &'a self, + cx: &'a mut Context<'cx, T>, + op: Operation<'cx>, + ) -> io::Result<()> + where + T: Reader + Writer + Send + Unpin, + { + let span = tracing::debug_span!("MemFS::call", unique = cx.unique()); + span.in_scope(|| tracing::debug!(?op)); + + macro_rules! try_reply { + ($e:expr) => { + match ($e).instrument(span.clone()).await { + Ok(reply) => { + span.in_scope(|| tracing::debug!(reply=?reply)); + cx.reply(reply).await + } + Err(err) => { + let errno = err.raw_os_error().unwrap_or(libc::EIO); + span.in_scope(|| tracing::debug!(errno=errno)); + cx.reply_err(errno).await + } + } + }; + } + + match op { + Operation::Lookup(op) => try_reply!(self.do_lookup(&op)), + Operation::Forget(forgets) => { + self.do_forget(forgets.as_ref()).await; + Ok(()) + } + Operation::Getattr(op) => try_reply!(self.do_getattr(&op)), + Operation::Setattr(op) => try_reply!(self.do_setattr(&op)), + Operation::Readlink(op) => try_reply!(self.do_readlink(&op)), + + Operation::Opendir(op) => try_reply!(self.do_opendir(&op)), + Operation::Readdir(op) => try_reply!(self.do_readdir(&op)), + Operation::Releasedir(op) => try_reply!(self.do_releasedir(&op)), + + Operation::Mknod(op) => try_reply!(self.do_mknod(&op)), + Operation::Mkdir(op) => try_reply!(self.do_mkdir(&op)), + Operation::Symlink(op) => try_reply!(self.do_symlink(&op)), + Operation::Unlink(op) => try_reply!(self.do_unlink(&op)), + Operation::Rmdir(op) => try_reply!(self.do_rmdir(&op)), + Operation::Link(op) => try_reply!(self.do_link(&op)), + Operation::Rename(op) => try_reply!(self.do_rename(&op)), + + Operation::Getxattr(op) => try_reply!(self.do_getxattr(&op)), + Operation::Setxattr(op) => try_reply!(self.do_setxattr(&op)), + Operation::Listxattr(op) => try_reply!(self.do_listxattr(&op)), + Operation::Removexattr(op) => try_reply!(self.do_removexattr(&op)), + + Operation::Read(op) => try_reply!(self.do_read(&op)), + Operation::Write(op) => { + let res = self + .do_write(&op, &mut cx.reader()) + .instrument(span.clone()) + .await; + try_reply!(async { res }) + } + + _ => { + span.in_scope(|| tracing::debug!("NOSYS")); + Ok(()) + } + } + } +} + +fn no_entry() -> io::Error { + io::Error::from_raw_os_error(libc::ENOENT) +} + +fn unknown_error() -> io::Error { + io::Error::from_raw_os_error(libc::EIO) +} + +// FIXME: use either crate. +#[derive(Debug)] +enum Either { + Left(L), + Right(R), +} + +impl Reply for Either + where + L: Reply, + R: Reply, +{ + #[inline] + fn collect_bytes<'a, C: ?Sized>(&'a self, collector: &mut C) + where + C: Collector<'a>, + { + match self { + Either::Left(l) => l.collect_bytes(collector), + Either::Right(r) => r.collect_bytes(collector), + } + } +} diff --git a/src/http.rs b/src/http.rs new file mode 100644 index 0000000..20c2261 --- /dev/null +++ b/src/http.rs @@ -0,0 +1,69 @@ +extern crate base64; +use reqwest::{blocking::Client, header::CONTENT_LENGTH}; +use serde::Deserialize; +use std::{ + collections::{BTreeMap, HashMap, HashSet}, + env, + ffi::OsStr, + fmt, + path::Path, + process, + thread::sleep, + time::{Duration,SystemTime}, +}; + + +#[derive(Default, Debug, Clone, PartialEq, Deserialize)] +pub struct RemoteEntry { + pub name: Option, + pub r#type: Option, + pub mtime: Option, + pub size: Option, +} + +impl RemoteEntry{ + pub fn parse_rfc2822(&self) -> SystemTime{ + let rfc2822 = DateTime::parse_from_rfc2822(&self.mtime.as_ref().unwrap()).unwrap(); + SystemTime::from(rfc2822) + } +} + +use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime}; +use chrono::format::ParseError; + + +pub async fn list_directory( + server: &std::string::String, + username: &Option, + password: &Option, + path: &Path) -> + Result, reqwest::Error> { + info!("Fetching path '{}{}'", server, path.display()); + let client = reqwest::Client::new(); + let http_auth = match username { + Some(username) => { + // info!("Using Basic Auth"); + let mut _buf = String::new(); + _buf.push_str( + format!( + "{}:{}", + username, + password.as_ref().unwrap() + ).as_str() + ); + + base64::encode(_buf) + } + None => {String::new()} + }; + //info!("AUTH: {:?}", http_auth); + let resp = client + .get(format!("{}/{}", server, path.display()).as_str()) + .header("Authorization", format!("Basic {}", http_auth)) + .send() + .await? + .json::>() + .await?; + info!("Found {} entries into '{}'", resp.len(), path.display()); + Ok(resp) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9a35309 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,36 @@ +use std::path::PathBuf; +#[macro_use] +extern crate log; +use env_logger::Env; +use std::{process,path::Path}; + +mod config; +mod filesystem; +mod http; + + +#[tokio::main] +async fn main() -> Result<(), std::io::Error> { + env_logger::from_env(Env::default().default_filter_or("info")).init(); + let cfg = config::read(); + //let http::list_directory(&cfg.server, &cfg.username, &cfg.password, "/").await; + warn!("{:?}", cfg); + + //let mut args = pico_args::Arguments::from_env(); + + let mountpoint: PathBuf = PathBuf::from(&cfg.mountpoint); + if !mountpoint.is_dir() { + error!("The mountpoint must be a directory"); + process::exit(0x0004); + } + + let memfs = filesystem::MemFS::new(&cfg); + memfs.fetch_remote(Path::new("/"), 1).await; + polyfuse_tokio::mount(memfs, mountpoint, &[]).await?; + + Ok(()) +} +/* +Mkdir { parent: 1, name: "123", mode: 493, umask: 18 } +Mknod { parent: 1, name: "123233", mode: 33188, rdev: 0, umask: 18 } +*/ \ No newline at end of file