From: Max Value Date: Sun, 23 Nov 2025 10:57:08 +0000 (+0000) Subject: First changes X-Git-Url: https://git.ozva.co.uk/?a=commitdiff_plain;p=ozva-cloud First changes --- diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 7e8981e..0000000 --- a/.dockerignore +++ /dev/null @@ -1,13 +0,0 @@ -# Directories -/.git/ -/.github/ -/target/ -/examples/ -/docs/ -/benches/ -/tmp/ - -# Files -.gitignore -*.md -LICENSE* \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0f84cc9..161a451 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target -/.vscode \ No newline at end of file +/.vscode +Cargo.lock +*.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 225f1ae..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,666 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -## [0.43.0] - 2024-11-04 - -### Bug Fixes - -- Auth failed if password contains `:` ([#449](https://github.com/sigoden/dufs/issues/449)) -- Resolve speed bottleneck in 10G network ([#451](https://github.com/sigoden/dufs/issues/451)) - -### Features - -- Webui displays subdirectory items ([#457](https://github.com/sigoden/dufs/issues/457)) -- Support binding abstract unix socket ([#468](https://github.com/sigoden/dufs/issues/468)) -- Provide healthcheck API ([#474](https://github.com/sigoden/dufs/issues/474)) - -### Refactor - -- Do not show size for Dir ([#447](https://github.com/sigoden/dufs/issues/447)) - -## [0.42.0] - 2024-09-01 - -### Bug Fixes - -- Garbled characters caused by atob ([#422](https://github.com/sigoden/dufs/issues/422)) -- Webui unexpected save-btn when file is non-editable ([#429](https://github.com/sigoden/dufs/issues/429)) -- Login succeeded but popup `Forbidden` ([#437](https://github.com/sigoden/dufs/issues/437)) - -### Features - -- Implements remaining http cache conditionalss ([#407](https://github.com/sigoden/dufs/issues/407)) -- Base64 index-data to avoid misencoding ([#421](https://github.com/sigoden/dufs/issues/421)) -- Webui support logout ([#439](https://github.com/sigoden/dufs/issues/439)) - -### Refactor - -- No inline scripts in HTML ([#391](https://github.com/sigoden/dufs/issues/391)) -- Return 400 for propfind request when depth is neither 0 nor 1 ([#403](https://github.com/sigoden/dufs/issues/403)) -- Remove sabredav-partialupdate from DAV res header ([#415](https://github.com/sigoden/dufs/issues/415)) -- Date formatting in cache tests ([#428](https://github.com/sigoden/dufs/issues/428)) -- Some query params work as flag and must not accept a value ([#431](https://github.com/sigoden/dufs/issues/431)) -- Improve logout at asserts/index.js ([#440](https://github.com/sigoden/dufs/issues/440)) -- Make logout works on safari ([#442](https://github.com/sigoden/dufs/issues/442)) - -## [0.41.0] - 2024-05-22 - -### Bug Fixes - -- Timestamp format of getlastmodified in dav xml ([#366](https://github.com/sigoden/dufs/issues/366)) -- Strange issue that occurs only on Microsoft WebDAV ([#382](https://github.com/sigoden/dufs/issues/382)) -- Head div overlap main contents when wrap ([#386](https://github.com/sigoden/dufs/issues/386)) - -### Features - -- Tls handshake timeout ([#368](https://github.com/sigoden/dufs/issues/368)) -- Add api to get the hash of a file ([#375](https://github.com/sigoden/dufs/issues/375)) -- Add log-file option ([#383](https://github.com/sigoden/dufs/issues/383)) - -### Refactor - -- Digest_auth related tests ([#372](https://github.com/sigoden/dufs/issues/372)) -- Add fixed-width numerals to date and size on file list page ([#378](https://github.com/sigoden/dufs/issues/378)) - -## [0.40.0] - 2024-02-13 - -### Bug Fixes - -- Guard req and destination path ([#359](https://github.com/sigoden/dufs/issues/359)) - -### Features - -- Revert supporting for forbidden permission ([#352](https://github.com/sigoden/dufs/issues/352)) - -### Refactor - -- Do not try to bind ipv6 if no ipv6 ([#348](https://github.com/sigoden/dufs/issues/348)) -- Improve invalid auth ([#356](https://github.com/sigoden/dufs/issues/356)) -- Improve resolve_path and handle_assets, abandon guard_path ([#360](https://github.com/sigoden/dufs/issues/360)) - -## [0.39.0] - 2024-01-11 - -### Bug Fixes - -- Upload more than 100 files in directory ([#317](https://github.com/sigoden/dufs/issues/317)) -- Auth precedence ([#325](https://github.com/sigoden/dufs/issues/325)) -- Serve files with names containing newline char ([#328](https://github.com/sigoden/dufs/issues/328)) -- Corrupted zip when downloading large folders ([#337](https://github.com/sigoden/dufs/issues/337)) - -### Features - -- Empty search `?q=` list all paths ([#311](https://github.com/sigoden/dufs/issues/311)) -- Add `--compress` option ([#319](https://github.com/sigoden/dufs/issues/319)) -- Upgrade to hyper 1.0 ([#321](https://github.com/sigoden/dufs/issues/321)) -- Auth supports forbidden permissions ([#329](https://github.com/sigoden/dufs/issues/329)) -- Supports resumable uploads ([#343](https://github.com/sigoden/dufs/issues/343)) - -### Refactor - -- Change the format of www-authenticate ([#312](https://github.com/sigoden/dufs/issues/312)) -- Change the value name of `--config` ([#313](https://github.com/sigoden/dufs/issues/313)) -- Optimize http range parsing and handling ([#323](https://github.com/sigoden/dufs/issues/323)) -- Propfind with auth no need to list all ([#344](https://github.com/sigoden/dufs/issues/344)) - -## [0.38.0] - 2023-11-28 - -### Bug Fixes - -- Unable to start if config file omit bind/port fields ([#294](https://github.com/sigoden/dufs/issues/294)) - -### Features - -- Password can contain `:` `@` `|` ([#297](https://github.com/sigoden/dufs/issues/297)) -- Deprecate the use of `|` to separate auth rules ([#298](https://github.com/sigoden/dufs/issues/298)) -- More flexible config values ([#299](https://github.com/sigoden/dufs/issues/299)) -- Ui supports view file ([#301](https://github.com/sigoden/dufs/issues/301)) - -### Refactor - -- Take improvements from the edge browser ([#289](https://github.com/sigoden/dufs/issues/289)) -- Ui change the cursor for upload-btn to a pointer ([#291](https://github.com/sigoden/dufs/issues/291)) -- Ui improve uploading progress ([#296](https://github.com/sigoden/dufs/issues/296)) - -## [0.37.1] - 2023-11-08 - -### Bug Fixes - -- Use DUFS_CONFIG to specify the config file path ([#286](https://github.com/sigoden/dufs/issues/286) - -## [0.37.0] - 2023-11-08 - -### Bug Fixes - -- Sort path ignore case ([#264](https://github.com/sigoden/dufs/issues/264)) -- Ui show user-name next to the user-icon ([#278](https://github.com/sigoden/dufs/issues/278)) -- Auto delete half-uploaded files ([#280](https://github.com/sigoden/dufs/issues/280)) - -### Features - -- Deprecate `--auth-method`, as both options are available ([#279](https://github.com/sigoden/dufs/issues/279)) -- Support config file with `--config` option ([#281](https://github.com/sigoden/dufs/issues/281)) -- Support hashed password ([#283](https://github.com/sigoden/dufs/issues/283)) - -### Refactor - -- Remove one clone on `assets_prefix` ([#270](https://github.com/sigoden/dufs/issues/270)) -- Optimize tests -- Improve code quality ([#282](https://github.com/sigoden/dufs/issues/282)) - -## [0.36.0] - 2023-08-24 - -### Bug Fixes - -- Ui readonly if no write perm ([#258](https://github.com/sigoden/dufs/issues/258)) - -### Testing - -- Remove dependency on native tls ([#255](https://github.com/sigoden/dufs/issues/255)) - -## [0.35.0] - 2023-08-14 - -### Bug Fixes - -- Search should ignore entry path ([#235](https://github.com/sigoden/dufs/issues/235)) -- Typo __ASSERTS_PREFIX__ ([#252](https://github.com/sigoden/dufs/issues/252)) - -### Features - -- Sort by type first, then sort by name/mtime/size ([#241](https://github.com/sigoden/dufs/issues/241)) - -## [0.34.2] - 2023-06-05 - -### Bug Fixes - -- Ui refresh page after login ([#230](https://github.com/sigoden/dufs/issues/230)) -- Webdav only see public folder even logging in ([#231](https://github.com/sigoden/dufs/issues/231)) - -## [0.34.1] - 2023-06-02 - -### Bug Fixes - -- Auth logic ([#224](https://github.com/sigoden/dufs/issues/224)) -- Allow all cors headers and methods ([#225](https://github.com/sigoden/dufs/issues/225)) - -### Refactor - -- Ui checkAuth ([#226](https://github.com/sigoden/dufs/issues/226)) - -## [0.34.0] - 2023-06-01 - -### Bug Fixes - -- URL-encoded filename when downloading in safari ([#203](https://github.com/sigoden/dufs/issues/203)) -- Ui path table show move action ([#219](https://github.com/sigoden/dufs/issues/219)) -- Ui set default max uploading to 1 ([#220](https://github.com/sigoden/dufs/issues/220)) - -### Features - -- Webui editing support multiple encodings ([#197](https://github.com/sigoden/dufs/issues/197)) -- Add timestamp metadata to generated zip file ([#204](https://github.com/sigoden/dufs/issues/204)) -- Show precise file size with decimal ([#210](https://github.com/sigoden/dufs/issues/210)) -- [**breaking**] New auth ([#218](https://github.com/sigoden/dufs/issues/218)) - -### Refactor - -- Cli positional rename root => SERVE_PATH([#215](https://github.com/sigoden/dufs/issues/215)) - -## [0.33.0] - 2023-03-17 - -### Bug Fixes - -- Cors allow-request-header add content-type ([#184](https://github.com/sigoden/dufs/issues/184)) -- Hidden don't works on some files ([#188](https://github.com/sigoden/dufs/issues/188)) -- Basic auth sometimes does not work ([#194](https://github.com/sigoden/dufs/issues/194)) - -### Features - -- Guess plain text encoding then set content-type charset ([#186](https://github.com/sigoden/dufs/issues/186)) - -### Refactor - -- Improve error handle ([#195](https://github.com/sigoden/dufs/issues/195)) - -## [0.32.0] - 2023-02-22 - -### Bug Fixes - -- Set the STOPSIGNAL to SIGINT for Dockerfile -- Remove Method::Options auth check ([#168](https://github.com/sigoden/dufs/issues/168)) -- Clear search input also clear query ([#178](https://github.com/sigoden/dufs/issues/178)) - -### Features - -- [**breaking**] Add option --allow-archive ([#152](https://github.com/sigoden/dufs/issues/152)) -- Use env var for args ([#170](https://github.com/sigoden/dufs/issues/170)) -- Hiding only directories instead of files ([#175](https://github.com/sigoden/dufs/issues/175)) -- API to search and list directories ([#177](https://github.com/sigoden/dufs/issues/177)) -- Support edit files ([#179](https://github.com/sigoden/dufs/issues/179)) -- Support new file ([#180](https://github.com/sigoden/dufs/issues/180)) -- Ui improves the login experience ([#182](https://github.com/sigoden/dufs/issues/182)) - -## [0.31.0] - 2022-11-11 - -### Bug Fixes - -- Auth not works with --path-prefix ([#138](https://github.com/sigoden/dufs/issues/138)) -- Don't search on empty query string ([#140](https://github.com/sigoden/dufs/issues/140)) -- Status code for MKCOL on existing resource ([#142](https://github.com/sigoden/dufs/issues/142)) -- Panic on PROPFIND // ([#144](https://github.com/sigoden/dufs/issues/144)) - -### Features - -- Support unix sockets ([#145](https://github.com/sigoden/dufs/issues/145)) - -## [0.30.0] - 2022-09-09 - -### Bug Fixes - -- Hide path by ext name ([#126](https://github.com/sigoden/dufs/issues/126)) - -### Features - -- Support sort by name, mtime, size ([#128](https://github.com/sigoden/dufs/issues/128)) -- Add --assets options to override assets ([#134](https://github.com/sigoden/dufs/issues/134)) - -## [0.29.0] - 2022-08-03 - -### Bug Fixes - -- Table row hover highlighting in dark mode ([#122](https://github.com/sigoden/dufs/issues/122)) - -### Features - -- Support ecdsa tls cert ([#119](https://github.com/sigoden/dufs/issues/119)) - -## [0.28.0] - 2022-08-01 - -### Bug Fixes - -- File path contains special characters ([#114](https://github.com/sigoden/dufs/issues/114)) - -### Features - -- Add table row hover ([#115](https://github.com/sigoden/dufs/issues/115)) -- Support customize http log format ([#116](https://github.com/sigoden/dufs/issues/116)) - -## [0.27.0] - 2022-07-25 - -### Features - -- Improve hidden to support glob ([#108](https://github.com/sigoden/dufs/issues/108)) -- Adjust digest auth timeout to 1day ([#110](https://github.com/sigoden/dufs/issues/110)) - -## [0.26.0] - 2022-07-11 - -### Bug Fixes - -- Cors headers ([#100](https://github.com/sigoden/dufs/issues/100)) - -### Features - -- Make --path-prefix works on serving single file ([#102](https://github.com/sigoden/dufs/issues/102)) - -## [0.25.0] - 2022-07-06 - -### Features - -- Ui supports creating folder ([#91](https://github.com/sigoden/dufs/issues/91)) -- Ui supports move folder/file to new path ([#92](https://github.com/sigoden/dufs/issues/92)) -- Check permission on move/copy destination ([#93](https://github.com/sigoden/dufs/issues/93)) -- Add completions ([#97](https://github.com/sigoden/dufs/issues/97)) -- Limit the number of concurrent uploads ([#98](https://github.com/sigoden/dufs/issues/98)) - -## [0.24.0] - 2022-07-02 - -### Bug Fixes - -- Unexpected stack overflow when searching a lot ([#87](https://github.com/sigoden/dufs/issues/87)) - -### Features - -- Allow search with --render-try-index ([#88](https://github.com/sigoden/dufs/issues/88)) - -## [0.23.1] - 2022-06-30 - -### Bug Fixes - -- Safari layout and compatibility ([#83](https://github.com/sigoden/dufs/issues/83)) -- Permissions of unzipped files ([#84](https://github.com/sigoden/dufs/issues/84)) - -## [0.23.0] - 2022-06-29 - -### Features - -- Use feature to conditional support tls ([#77](https://github.com/sigoden/dufs/issues/77)) - -### Ci - -- Support more platforms ([#76](https://github.com/sigoden/dufs/issues/76)) - -## [0.22.0] - 2022-06-26 - -### Features - -- Support hiding folders with --hidden ([#73](https://github.com/sigoden/dufs/issues/73)) - -## [0.21.0] - 2022-06-23 - -### Bug Fixes - -- Escape name contains html escape code ([#65](https://github.com/sigoden/dufs/issues/65)) - -### Features - -- Use custom logger with timestamp in rfc3339 ([#67](https://github.com/sigoden/dufs/issues/67)) - -### Refactor - -- Split css/js from index.html ([#68](https://github.com/sigoden/dufs/issues/68)) - -## [0.20.0] - 2022-06-20 - -### Bug Fixes - -- DecodeURI searching string ([#61](https://github.com/sigoden/dufs/issues/61)) - -### Features - -- Added basic auth ([#60](https://github.com/sigoden/dufs/issues/60)) -- Add option --allow-search ([#62](https://github.com/sigoden/dufs/issues/62)) - -## [0.19.0] - 2022-06-19 - -### Features - -- [**breaking**] Path level access control ([#52](https://github.com/sigoden/dufs/issues/52)) -- Serve single file ([#54](https://github.com/sigoden/dufs/issues/54)) -- Ui hidden root dirname ([#58](https://github.com/sigoden/dufs/issues/58)) -- Reactive webpage ([#51](https://github.com/sigoden/dufs/issues/51)) -- [**breaking**] Rename to dufs ([#59](https://github.com/sigoden/dufs/issues/59)) - -### Refactor - -- [**breaking**] Rename --cors to --enable-cors ([#57](https://github.com/sigoden/dufs/issues/57)) - -## [0.18.0] - 2022-06-18 - -### Features - -- Add option --render-try-index ([#47](https://github.com/sigoden/dufs/issues/47)) -- Add slash to end of dir href - -## [0.17.1] - 2022-06-16 - -### Bug Fixes - -- Range request ([#44](https://github.com/sigoden/dufs/issues/44)) - -## [0.17.0] - 2022-06-15 - -### Bug Fixes - -- Webdav propfind dir with slash ([#42](https://github.com/sigoden/dufs/issues/42)) - -### Features - -- Listen both ipv4 and ipv6 by default ([#40](https://github.com/sigoden/dufs/issues/40)) - -### Refactor - -- Trivial changes ([#41](https://github.com/sigoden/dufs/issues/41)) - -## [0.16.0] - 2022-06-12 - -### Features - -- Implement head method ([#33](https://github.com/sigoden/dufs/issues/33)) -- Display upload speed and time left ([#34](https://github.com/sigoden/dufs/issues/34)) -- Support tls-key in pkcs#8 format ([#35](https://github.com/sigoden/dufs/issues/35)) -- Options method return status 200 - -### Testing - -- Add integration tests ([#36](https://github.com/sigoden/dufs/issues/36)) - -## [0.15.1] - 2022-06-11 - -### Bug Fixes - -- Cannot upload ([#32](https://github.com/sigoden/dufs/issues/32)) - -## [0.15.0] - 2022-06-10 - -### Bug Fixes - -- Encode webdav href as uri ([#28](https://github.com/sigoden/dufs/issues/28)) -- Query dir param - -### Features - -- Add basic dark theme ([#29](https://github.com/sigoden/dufs/issues/29)) -- Add empty state placeholder to page([#30](https://github.com/sigoden/dufs/issues/30)) - -## [0.14.0] - 2022-06-07 - -### Bug Fixes - -- Send index page with content-type ([#26](https://github.com/sigoden/dufs/issues/26)) - -### Features - -- Support ipv6 ([#25](https://github.com/sigoden/dufs/issues/25)) -- Add favicon ([#27](https://github.com/sigoden/dufs/issues/27)) - -## [0.13.2] - 2022-06-06 - -### Bug Fixes - -- Filename xml escaping -- Escape path-prefix/url-prefix different - -## [0.13.1] - 2022-06-05 - -### Bug Fixes - -- Escape filename ([#21](https://github.com/sigoden/dufs/issues/21)) - -### Refactor - -- Use logger ([#22](https://github.com/sigoden/dufs/issues/22)) - -## [0.13.0] - 2022-06-05 - -### Bug Fixes - -- Ctrl+c not exit sometimes - -### Features - -- Implement more webdav methods ([#13](https://github.com/sigoden/dufs/issues/13)) -- Use digest auth ([#14](https://github.com/sigoden/dufs/issues/14)) -- Add webdav proppatch handler ([#18](https://github.com/sigoden/dufs/issues/18)) - -## [0.12.1] - 2022-06-04 - -### Features - -- Support webdav ([#10](https://github.com/sigoden/dufs/issues/10)) -- Remove unzip uploaded feature ([#11](https://github.com/sigoden/dufs/issues/11)) - -## [0.11.0] - 2022-06-03 - -### Features - -- Support gracefully shutdown server -- Listen 0.0.0.0 by default - -## [0.10.1] - 2022-06-02 - -### Bug Fixes - -- Panic when bind already used port - -## [0.10.0] - 2022-06-02 - -### Bug Fixes - -- Remove unzip file even failed to unzip -- Rename --no-auth-read to --no-auth-access -- Broken ui - -### Documentation - -- Refactor readme - -### Features - -- Change auth logic/options -- Improve ui - -### Refactor - -- Small improvement - -## [0.9.0] - 2022-06-02 - -### Documentation - -- Improve readme - -### Features - -- Support path prefix -- List all ifaces when listening 0.0.0.0 -- Support tls - -## [0.8.0] - 2022-06-01 - -### Bug Fixes - -- Some typos -- Caught 500 if no permission to access dir - -### Features - -- Cli add allow-symlink option -- Add some headers to res -- Support render-index/render-spa - -## [0.7.0] - 2022-05-31 - -### Bug Fixes - -- Downloaded zip file has no.zip ext in firefox -- Unzip override existed file in uploadonly mode -- Miss file 500 -- Not found dir when allow_upload is false - -### Features - -- Drag and drop uploads, upload folder - -## [0.6.0] - 2022-05-31 - -### Features - -- Delete confirm -- Distinct upload and delete operation -- Support range requests - -### Refactor - -- Improve code quality - -## [0.5.0] - 2022-05-30 - -### Features - -- Add mime and cache headers to response -- Add no-auth-read options -- Unzip zip file when unload - -## [0.4.0] - 2022-05-29 - -### Features - -- Replace --static option to --no-edit -- Add cors - -## [0.3.0] - 2022-05-29 - -### Documentation - -- Update readme demo png - -### Features - -- Automatically create dir while uploading -- Support searching - -### Refactor - -- Handler zip - -### Styling - -- Optimize css - -## [0.2.1] - 2022-05-28 - -### Bug Fixes - -- Cannot upload in root -- Optimize download zip - -### Documentation - -- Improve readme - -### Features - -- Aware RUST_LOG - -## [0.2.0] - 2022-05-28 - -### Documentation - -- Update demo png -- Improve readme - -### Features - -- Add logger -- Download folder as zip file - -## [0.1.0] - 2022-05-26 - -### Bug Fixes - -- Caught server error when symlink broken - -### Documentation - -- Improve readme -- Update readme - -### Features - -- Add basic auth and readonly mode -- Support delete operation -- Remove parent path - -### Styling - -- Cargo fmt -- Update index page - -### Build - -- Remove dev deps - -### Ci - -- Init ci - - diff --git a/Cargo.lock b/Cargo.lock index 81a6319..71f9298 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -492,63 +492,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "dufs" -version = "0.43.0" -dependencies = [ - "alphanumeric-sort", - "anyhow", - "assert_cmd", - "assert_fs", - "async-stream", - "async_zip", - "base64 0.22.1", - "bytes", - "chardetng", - "chrono", - "clap", - "clap_complete", - "content_inspector", - "digest_auth", - "form_urlencoded", - "futures-util", - "glob", - "headers", - "http-body-util", - "hyper", - "hyper-util", - "if-addrs", - "indexmap", - "lazy_static", - "log", - "md5", - "mime_guess", - "percent-encoding", - "pin-project-lite", - "port_check", - "predicates", - "regex", - "reqwest", - "rstest", - "rustls-pemfile", - "rustls-pki-types", - "serde", - "serde_json", - "serde_yaml", - "sha-crypt", - "sha2", - "smart-default", - "socket2", - "tokio", - "tokio-rustls", - "tokio-util", - "url", - "urlencoding", - "uuid", - "walkdir", - "xml-rs", -] - [[package]] name = "encoding_rs" version = "0.8.35" @@ -1303,6 +1246,63 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "ozva-cloud" +version = "0.1.0" +dependencies = [ + "alphanumeric-sort", + "anyhow", + "assert_cmd", + "assert_fs", + "async-stream", + "async_zip", + "base64 0.22.1", + "bytes", + "chardetng", + "chrono", + "clap", + "clap_complete", + "content_inspector", + "digest_auth", + "form_urlencoded", + "futures-util", + "glob", + "headers", + "http-body-util", + "hyper", + "hyper-util", + "if-addrs", + "indexmap", + "lazy_static", + "log", + "md5", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "port_check", + "predicates", + "regex", + "reqwest", + "rstest", + "rustls-pemfile", + "rustls-pki-types", + "serde", + "serde_json", + "serde_yaml", + "sha-crypt", + "sha2", + "smart-default", + "socket2", + "tokio", + "tokio-rustls", + "tokio-util", + "url", + "urlencoding", + "uuid", + "walkdir", + "xml-rs", +] + [[package]] name = "parking" version = "2.2.1" diff --git a/Cargo.toml b/Cargo.toml index 51a1e1d..2662f93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "dufs" -version = "0.43.0" +name = "ozva-cloud" +version = "0.1.0" edition = "2021" -authors = ["sigoden "] -description = "Dufs is a distinctive utility file server" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/sigoden/dufs" -repository = "https://github.com/sigoden/dufs" +authors = ["William Greenwood "] +description = "Ozone-Value Holdings file sharing service" +license = "MIT" +homepage = "https://www.ozva.co.uk" +repository = "https://git.ozva.co.uk/ozva-cloud" categories = ["command-line-utilities", "web-programming::http-server"] keywords = ["static", "file", "server", "webdav", "cli"] diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d27bbb8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM --platform=linux/amd64 messense/rust-musl-cross:x86_64-musl AS amd64 -COPY . . -RUN cargo install --path . --root / - -FROM --platform=linux/amd64 messense/rust-musl-cross:aarch64-musl AS arm64 -COPY . . -RUN cargo install --path . --root / - -FROM ${TARGETARCH} AS builder - -FROM scratch -COPY --from=builder /bin/dufs /bin/dufs -STOPSIGNAL SIGINT -ENTRYPOINT ["/bin/dufs"] diff --git a/Dockerfile-release b/Dockerfile-release deleted file mode 100644 index 94219fb..0000000 --- a/Dockerfile-release +++ /dev/null @@ -1,19 +0,0 @@ -FROM alpine as builder -ARG REPO VER TARGETPLATFORM -RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - TARGET="x86_64-unknown-linux-musl"; \ - elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - TARGET="aarch64-unknown-linux-musl"; \ - elif [ "$TARGETPLATFORM" = "linux/386" ]; then \ - TARGET="i686-unknown-linux-musl"; \ - elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ - TARGET="armv7-unknown-linux-musleabihf"; \ - fi && \ - wget https://github.com/${REPO}/releases/download/${VER}/dufs-${VER}-${TARGET}.tar.gz && \ - tar -xf dufs-${VER}-${TARGET}.tar.gz && \ - mv dufs /bin/ - -FROM scratch -COPY --from=builder /bin/dufs /bin/dufs -STOPSIGNAL SIGINT -ENTRYPOINT ["/bin/dufs"] diff --git a/LICENSE-APACHE b/LICENSE-APACHE deleted file mode 100644 index 261eeb9..0000000 --- a/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.html b/README.html new file mode 100644 index 0000000..59ceb7b --- /dev/null +++ b/README.html @@ -0,0 +1,269 @@ +

OzVa Cloud

+

Forked from Dufs at this commit.

+ +

+Usage: ozva-cloud [OPTIONS] [serve-path]
+
+Arguments:
+  [serve-path]  Specific path to serve [default: .]
+
+Options:
+  -c, --config <file>        Specify configuration file
+  -b, --bind <addrs>         Specify bind address or unix socket
+  -p, --port <port>          Specify port to listen on [default: 5000]
+      --path-prefix <path>   Specify a path prefix
+      --hidden <value>       Hide paths from directory listings, e.g. tmp,*.log,*.lock
+  -a, --auth <rules>         Add auth roles, e.g. user:pass@/dir1:rw,/dir2
+  -A, --allow-all            Allow all operations
+      --allow-upload         Allow upload files/folders
+      --allow-delete         Allow delete files/folders
+      --allow-search         Allow search files/folders
+      --allow-symlink        Allow symlink to files/folders outside root directory
+      --allow-archive        Allow download folders as archive file
+      --enable-cors          Enable CORS, sets `Access-Control-Allow-Origin: *`
+      --render-index         Serve index.html when requesting a directory, returns 404 if not found index.html
+      --render-try-index     Serve index.html when requesting a directory, returns directory listing if not found index.html
+      --render-spa           Serve SPA(Single Page Application)
+      --assets <path>        Set the path to the assets directory for overriding the built-in assets
+      --log-format <format>  Customize http log format
+      --log-file <file>      Specify the file to save logs to, other than stdout/stderr
+      --compress <level>     Set zip compress level [default: low] [possible values: none, low, medium, high]
+      --completions <shell>  Print shell completion script for <shell> [possible values: bash, elvish, fish, powershell, zsh]
+      --tls-cert <path>      Path to an SSL/TLS certificate to serve with HTTPS
+      --tls-key <path>       Path to the SSL/TLS certificate's private key
+  -h, --help                 Print help
+  -V, --version              Print version
+
+

Examples

+

Serve current working directory in read-only mode

+
ozva-cloud
+
+

Allow all operations like upload/delete/search/create/edit...

+
ozva-cloud -A
+
+

Only allow upload operation

+
ozva-cloud --allow-upload
+
+

Serve a specific directory

+
ozva-cloud Downloads
+
+

Serve a single file

+
ozva-cloud linux-distro.iso
+
+

Serve a single-page application like react/vue

+
ozva-cloud --render-spa
+
+

Serve a static website with index.html

+
ozva-cloud --render-index
+
+

Require username/password

+
ozva-cloud -a admin:123@/:rw
+
+

Listen on specific host:ip

+
ozva-cloud -b 127.0.0.1 -p 80
+
+

Listen on unix socket

+
ozva-cloud -b /tmp/ozva-cloud.socket
+
+

Use https

+
ozva-cloud --tls-cert my.crt --tls-key my.key
+
+

API

+

Upload a file

+
curl -T path-to-file http://127.0.0.1:5000/new-path/path-to-file
+
+

Download a file

+
curl http://127.0.0.1:5000/path-to-file           # download the file
+curl http://127.0.0.1:5000/path-to-file?hash      # retrieve the sha256 hash of the file
+
+

Download a folder as zip file

+
curl -o path-to-folder.zip http://127.0.0.1:5000/path-to-folder?zip
+
+

Delete a file/folder

+
curl -X DELETE http://127.0.0.1:5000/path-to-file-or-folder
+
+

Create a directory

+
curl -X MKCOL http://127.0.0.1:5000/path-to-folder
+
+

Move the file/folder to the new path

+
curl -X MOVE http://127.0.0.1:5000/path -H "Destination: http://127.0.0.1:5000/new-path"
+
+

List/search directory contents

+
curl http://127.0.0.1:5000?q=Dockerfile           # search for files, similar to `find -name Dockerfile`
+curl http://127.0.0.1:5000?simple                 # output names only, similar to `ls -1`
+curl http://127.0.0.1:5000?json                   # output paths in json format
+
+

With authorization (Both basic or digest auth works)

+
curl http://127.0.0.1:5000/file --user user:pass                 # basic auth
+curl http://127.0.0.1:5000/file --user user:pass --digest        # digest auth
+
+

Resumable downloads

+
curl -C- -o file http://127.0.0.1:5000/file
+
+

Resumable uploads

+
upload_offset=$(curl -I -s http://127.0.0.1:5000/file | tr -d '\r' | sed -n 's/content-length: //p')
+dd skip=$upload_offset if=file status=none ibs=1 | \
+  curl -X PATCH -H "X-Update-Range: append" --data-binary @- http://127.0.0.1:5000/file
+
+

Health checks

+
curl http://127.0.0.1:5000/__ozva-cloud__/health
+
+

Advanced Topics

+

Access Control

+

ozva-cloud supports account based access control. You can control who can do what on which path with --auth/-a.

+
ozva-cloud -a admin:admin@/:rw -a guest:guest@/
+ozva-cloud -a user:pass@/:rw,/dir1 -a @/
+
+
    +
  1. Use @ to separate the account and paths. No account means anonymous user.
  2. +
  3. Use : to separate the username and password of the account.
  4. +
  5. Use , to separate paths.
  6. +
  7. Use path suffix :rw/:ro set permissions: read-write/read-only. :ro can be omitted.
  8. +
+
    +
  • -a admin:admin@/:rw: admin has complete permissions for all paths.
  • +
  • -a guest:guest@/: guest has read-only permissions for all paths.
  • +
  • -a user:pass@/:rw,/dir1: user has read-write permissions for /*, has read-only permissions for /dir1/*.
  • +
  • -a @/: All paths is publicly accessible, everyone can view/download it.
  • +
+

Auth permissions are restricted by ozva-cloud global permissions. If ozva-cloud does not enable upload permissions via --allow-upload, then the account will not have upload permissions even if it is granted read-write(:rw) permissions.

+

Hashed Password

+

DUFS supports the use of sha-512 hashed password.

+

Create hashed password:

+
$ openssl passwd -6 123456 # or `mkpasswd -m sha-512 123456`
+$6$tWMB51u6Kb2ui3wd$5gVHP92V9kZcMwQeKTjyTRgySsYJu471Jb1I6iHQ8iZ6s07GgCIO69KcPBRuwPE5tDq05xMAzye0NxVKuJdYs/
+
+

Use hashed password:

+
ozva-cloud -a 'admin:$6$tWMB51u6Kb2ui3wd$5gVHP92V9kZcMwQeKTjyTRgySsYJu471Jb1I6iHQ8iZ6s07GgCIO69KcPBRuwPE5tDq05xMAzye0NxVKuJdYs/@/:rw'
+
+
+

The hashed password contains $6, which can expand to a variable in some shells, so you have to use single quotes to wrap it.

+
+

Two important things for hashed passwords:

+
    +
  1. ozva-cloud only supports sha-512 hashed passwords, so ensure that the password string always starts with $6$.
  2. +
  3. Digest authentication does not function properly with hashed passwords.
  4. +
+

Hide Paths

+

ozva-cloud supports hiding paths from directory listings via option --hidden <glob>,....

+
ozva-cloud --hidden .git,.DS_Store,tmp
+
+
+

The glob used in --hidden only matches file and directory names, not paths. So --hidden dir1/file is invalid.

+
+
ozva-cloud --hidden '.*'                          # hidden dotfiles
+ozva-cloud --hidden '*/'                          # hidden all folders
+ozva-cloud --hidden '*.log,*.lock'                # hidden by exts
+ozva-cloud --hidden '*.log' --hidden '*.lock'
+
+

Log Format

+

ozva-cloud supports customize http log format with option --log-format.

+

The log format can use following variables.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
variabledescription
$remote_addrclient address
$remote_useruser name supplied with authentication
$requestfull original request line
$statusresponse status
$http_arbitrary request header field. examples: $http_user_agent, $http_referer
+

The default log format is '$remote_addr "$request" $status'.

+
2022-08-06T06:59:31+08:00 INFO - 127.0.0.1 "GET /" 200
+
+

Disable http log

+
ozva-cloud --log-format=''
+
+

Log user-agent

+
ozva-cloud --log-format '$remote_addr "$request" $status $http_user_agent'
+
+
2022-08-06T06:53:55+08:00 INFO - 127.0.0.1 "GET /" 200 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
+
+

Log remote-user

+
ozva-cloud --log-format '$remote_addr $remote_user "$request" $status' -a /@admin:admin -a /folder1@user1:pass1
+
+
2022-08-06T07:04:37+08:00 INFO - 127.0.0.1 admin "GET /" 200
+
+

Environment variables

+

All options can be set using environment variables prefixed with DUFS_.

+
[serve-path]                DUFS_SERVE_PATH="."
+    --config <file>         DUFS_CONFIG=config.yaml
+-b, --bind <addrs>          DUFS_BIND=0.0.0.0
+-p, --port <port>           DUFS_PORT=5000
+    --path-prefix <path>    DUFS_PATH_PREFIX=/ozva-cloud
+    --hidden <value>        DUFS_HIDDEN=tmp,*.log,*.lock
+-a, --auth <rules>          DUFS_AUTH="admin:admin@/:rw|@/" 
+-A, --allow-all             DUFS_ALLOW_ALL=true
+    --allow-upload          DUFS_ALLOW_UPLOAD=true
+    --allow-delete          DUFS_ALLOW_DELETE=true
+    --allow-search          DUFS_ALLOW_SEARCH=true
+    --allow-symlink         DUFS_ALLOW_SYMLINK=true
+    --allow-archive         DUFS_ALLOW_ARCHIVE=true
+    --enable-cors           DUFS_ENABLE_CORS=true
+    --render-index          DUFS_RENDER_INDEX=true
+    --render-try-index      DUFS_RENDER_TRY_INDEX=true
+    --render-spa            DUFS_RENDER_SPA=true
+    --assets <path>         DUFS_ASSETS=./assets
+    --log-format <format>   DUFS_LOG_FORMAT=""
+    --log-file <file>       DUFS_LOG_FILE=./ozva-cloud.log
+    --compress <compress>   DUFS_COMPRESS=low
+    --tls-cert <path>       DUFS_TLS_CERT=cert.pem
+    --tls-key <path>        DUFS_TLS_KEY=key.pem
+
+

Configuration File

+

You can specify and use the configuration file by selecting the option --config <path-to-config.yaml>.

+

The following are the configuration items:

+
serve-path: '.'
+bind: 0.0.0.0
+port: 5000
+path-prefix: /ozva-cloud
+hidden:
+  - tmp
+  - '*.log'
+  - '*.lock'
+auth:
+  - admin:admin@/:rw
+  - user:pass@/src:rw,/share
+  - '@/'  # According to the YAML spec, quoting is required.
+allow-all: false
+allow-upload: true
+allow-delete: true
+allow-search: true
+allow-symlink: true
+allow-archive: true
+enable-cors: true
+render-index: true
+render-try-index: true
+render-spa: true
+assets: ./assets/
+log-format: '$remote_addr "$request" $status $http_user_agent'
+log-file: ./ozva-cloud.log
+compress: low
+tls-cert: tests/data/cert.pem
+tls-key: tests/data/key_pkcs1.pem
+
+

Customize UI

+

ozva-cloud allows users to customize the UI with your own assets.

+
ozva-cloud --assets my-assets-dir/
+
diff --git a/README.md b/README.md deleted file mode 100644 index 62ddbfe..0000000 --- a/README.md +++ /dev/null @@ -1,423 +0,0 @@ -# Dufs - -[![CI](https://github.com/sigoden/dufs/actions/workflows/ci.yaml/badge.svg)](https://github.com/sigoden/dufs/actions/workflows/ci.yaml) -[![Crates](https://img.shields.io/crates/v/dufs.svg)](https://crates.io/crates/dufs) -[![Docker Pulls](https://img.shields.io/docker/pulls/sigoden/dufs)](https://hub.docker.com/r/sigoden/dufs) - -Dufs is a distinctive utility file server that supports static serving, uploading, searching, accessing control, webdav... - -![demo](https://user-images.githubusercontent.com/4012553/220513063-ff0f186b-ac54-4682-9af4-47a9781dee0d.png) - -## Features - -- Serve static files -- Download folder as zip file -- Upload files and folders (Drag & Drop) -- Create/Edit/Search files -- Resumable/partial uploads/downloads -- Access control -- Support https -- Support webdav -- Easy to use with curl - -## Install - -### With cargo - -``` -cargo install dufs -``` - -### With docker - -``` -docker run -v `pwd`:/data -p 5000:5000 --rm sigoden/dufs /data -A -``` - -### With [Homebrew](https://brew.sh) - -``` -brew install dufs -``` - -### Binaries on macOS, Linux, Windows - -Download from [Github Releases](https://github.com/sigoden/dufs/releases), unzip and add dufs to your $PATH. - -## CLI - -``` -Dufs is a distinctive utility file server - https://github.com/sigoden/dufs - -Usage: dufs [OPTIONS] [serve-path] - -Arguments: - [serve-path] Specific path to serve [default: .] - -Options: - -c, --config Specify configuration file - -b, --bind Specify bind address or unix socket - -p, --port Specify port to listen on [default: 5000] - --path-prefix Specify a path prefix - --hidden Hide paths from directory listings, e.g. tmp,*.log,*.lock - -a, --auth Add auth roles, e.g. user:pass@/dir1:rw,/dir2 - -A, --allow-all Allow all operations - --allow-upload Allow upload files/folders - --allow-delete Allow delete files/folders - --allow-search Allow search files/folders - --allow-symlink Allow symlink to files/folders outside root directory - --allow-archive Allow download folders as archive file - --enable-cors Enable CORS, sets `Access-Control-Allow-Origin: *` - --render-index Serve index.html when requesting a directory, returns 404 if not found index.html - --render-try-index Serve index.html when requesting a directory, returns directory listing if not found index.html - --render-spa Serve SPA(Single Page Application) - --assets Set the path to the assets directory for overriding the built-in assets - --log-format Customize http log format - --log-file Specify the file to save logs to, other than stdout/stderr - --compress Set zip compress level [default: low] [possible values: none, low, medium, high] - --completions Print shell completion script for [possible values: bash, elvish, fish, powershell, zsh] - --tls-cert Path to an SSL/TLS certificate to serve with HTTPS - --tls-key Path to the SSL/TLS certificate's private key - -h, --help Print help - -V, --version Print version -``` - -## Examples - -Serve current working directory in read-only mode - -``` -dufs -``` - -Allow all operations like upload/delete/search/create/edit... - -``` -dufs -A -``` - -Only allow upload operation - -``` -dufs --allow-upload -``` - -Serve a specific directory - -``` -dufs Downloads -``` - -Serve a single file - -``` -dufs linux-distro.iso -``` - -Serve a single-page application like react/vue - -``` -dufs --render-spa -``` - -Serve a static website with index.html - -``` -dufs --render-index -``` - -Require username/password - -``` -dufs -a admin:123@/:rw -``` - -Listen on specific host:ip - -``` -dufs -b 127.0.0.1 -p 80 -``` - -Listen on unix socket -``` -dufs -b /tmp/dufs.socket -``` - -Use https - -``` -dufs --tls-cert my.crt --tls-key my.key -``` - -## API - -Upload a file - -```sh -curl -T path-to-file http://127.0.0.1:5000/new-path/path-to-file -``` - -Download a file -```sh -curl http://127.0.0.1:5000/path-to-file # download the file -curl http://127.0.0.1:5000/path-to-file?hash # retrieve the sha256 hash of the file -``` - -Download a folder as zip file - -```sh -curl -o path-to-folder.zip http://127.0.0.1:5000/path-to-folder?zip -``` - -Delete a file/folder - -```sh -curl -X DELETE http://127.0.0.1:5000/path-to-file-or-folder -``` - -Create a directory - -```sh -curl -X MKCOL http://127.0.0.1:5000/path-to-folder -``` - -Move the file/folder to the new path - -```sh -curl -X MOVE http://127.0.0.1:5000/path -H "Destination: http://127.0.0.1:5000/new-path" -``` - -List/search directory contents - -```sh -curl http://127.0.0.1:5000?q=Dockerfile # search for files, similar to `find -name Dockerfile` -curl http://127.0.0.1:5000?simple # output names only, similar to `ls -1` -curl http://127.0.0.1:5000?json # output paths in json format -``` - -With authorization (Both basic or digest auth works) - -```sh -curl http://127.0.0.1:5000/file --user user:pass # basic auth -curl http://127.0.0.1:5000/file --user user:pass --digest # digest auth -``` - -Resumable downloads - -```sh -curl -C- -o file http://127.0.0.1:5000/file -``` - -Resumable uploads - -```sh -upload_offset=$(curl -I -s http://127.0.0.1:5000/file | tr -d '\r' | sed -n 's/content-length: //p') -dd skip=$upload_offset if=file status=none ibs=1 | \ - curl -X PATCH -H "X-Update-Range: append" --data-binary @- http://127.0.0.1:5000/file -``` - -Health checks - -```sh -curl http://127.0.0.1:5000/__dufs__/health -``` - -
-

Advanced Topics

- -### Access Control - -Dufs supports account based access control. You can control who can do what on which path with `--auth`/`-a`. - -``` -dufs -a admin:admin@/:rw -a guest:guest@/ -dufs -a user:pass@/:rw,/dir1 -a @/ -``` - -1. Use `@` to separate the account and paths. No account means anonymous user. -2. Use `:` to separate the username and password of the account. -3. Use `,` to separate paths. -4. Use path suffix `:rw`/`:ro` set permissions: `read-write`/`read-only`. `:ro` can be omitted. - -- `-a admin:admin@/:rw`: `admin` has complete permissions for all paths. -- `-a guest:guest@/`: `guest` has read-only permissions for all paths. -- `-a user:pass@/:rw,/dir1`: `user` has read-write permissions for `/*`, has read-only permissions for `/dir1/*`. -- `-a @/`: All paths is publicly accessible, everyone can view/download it. - -**Auth permissions are restricted by dufs global permissions.** If dufs does not enable upload permissions via `--allow-upload`, then the account will not have upload permissions even if it is granted `read-write`(`:rw`) permissions. - -#### Hashed Password - -DUFS supports the use of sha-512 hashed password. - -Create hashed password: - -```sh -$ openssl passwd -6 123456 # or `mkpasswd -m sha-512 123456` -$6$tWMB51u6Kb2ui3wd$5gVHP92V9kZcMwQeKTjyTRgySsYJu471Jb1I6iHQ8iZ6s07GgCIO69KcPBRuwPE5tDq05xMAzye0NxVKuJdYs/ -``` - -Use hashed password: - -```sh -dufs -a 'admin:$6$tWMB51u6Kb2ui3wd$5gVHP92V9kZcMwQeKTjyTRgySsYJu471Jb1I6iHQ8iZ6s07GgCIO69KcPBRuwPE5tDq05xMAzye0NxVKuJdYs/@/:rw' -``` -> The hashed password contains `$6`, which can expand to a variable in some shells, so you have to use **single quotes** to wrap it. - -Two important things for hashed passwords: - -1. Dufs only supports sha-512 hashed passwords, so ensure that the password string always starts with `$6$`. -2. Digest authentication does not function properly with hashed passwords. - - -### Hide Paths - -Dufs supports hiding paths from directory listings via option `--hidden ,...`. - -``` -dufs --hidden .git,.DS_Store,tmp -``` - -> The glob used in --hidden only matches file and directory names, not paths. So `--hidden dir1/file` is invalid. - -```sh -dufs --hidden '.*' # hidden dotfiles -dufs --hidden '*/' # hidden all folders -dufs --hidden '*.log,*.lock' # hidden by exts -dufs --hidden '*.log' --hidden '*.lock' -``` - -### Log Format - -Dufs supports customize http log format with option `--log-format`. - -The log format can use following variables. - -| variable | description | -| ------------ | ------------------------------------------------------------------------- | -| $remote_addr | client address | -| $remote_user | user name supplied with authentication | -| $request | full original request line | -| $status | response status | -| $http_ | arbitrary request header field. examples: $http_user_agent, $http_referer | - - -The default log format is `'$remote_addr "$request" $status'`. -``` -2022-08-06T06:59:31+08:00 INFO - 127.0.0.1 "GET /" 200 -``` - -Disable http log -``` -dufs --log-format='' -``` - -Log user-agent -``` -dufs --log-format '$remote_addr "$request" $status $http_user_agent' -``` -``` -2022-08-06T06:53:55+08:00 INFO - 127.0.0.1 "GET /" 200 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36 -``` - -Log remote-user -``` -dufs --log-format '$remote_addr $remote_user "$request" $status' -a /@admin:admin -a /folder1@user1:pass1 -``` -``` -2022-08-06T07:04:37+08:00 INFO - 127.0.0.1 admin "GET /" 200 -``` - -## Environment variables - -All options can be set using environment variables prefixed with `DUFS_`. - -``` -[serve-path] DUFS_SERVE_PATH="." - --config DUFS_CONFIG=config.yaml --b, --bind DUFS_BIND=0.0.0.0 --p, --port DUFS_PORT=5000 - --path-prefix DUFS_PATH_PREFIX=/dufs - --hidden DUFS_HIDDEN=tmp,*.log,*.lock --a, --auth DUFS_AUTH="admin:admin@/:rw|@/" --A, --allow-all DUFS_ALLOW_ALL=true - --allow-upload DUFS_ALLOW_UPLOAD=true - --allow-delete DUFS_ALLOW_DELETE=true - --allow-search DUFS_ALLOW_SEARCH=true - --allow-symlink DUFS_ALLOW_SYMLINK=true - --allow-archive DUFS_ALLOW_ARCHIVE=true - --enable-cors DUFS_ENABLE_CORS=true - --render-index DUFS_RENDER_INDEX=true - --render-try-index DUFS_RENDER_TRY_INDEX=true - --render-spa DUFS_RENDER_SPA=true - --assets DUFS_ASSETS=./assets - --log-format DUFS_LOG_FORMAT="" - --log-file DUFS_LOG_FILE=./dufs.log - --compress DUFS_COMPRESS=low - --tls-cert DUFS_TLS_CERT=cert.pem - --tls-key DUFS_TLS_KEY=key.pem -``` - -## Configuration File - -You can specify and use the configuration file by selecting the option `--config `. - -The following are the configuration items: - -```yaml -serve-path: '.' -bind: 0.0.0.0 -port: 5000 -path-prefix: /dufs -hidden: - - tmp - - '*.log' - - '*.lock' -auth: - - admin:admin@/:rw - - user:pass@/src:rw,/share - - '@/' # According to the YAML spec, quoting is required. -allow-all: false -allow-upload: true -allow-delete: true -allow-search: true -allow-symlink: true -allow-archive: true -enable-cors: true -render-index: true -render-try-index: true -render-spa: true -assets: ./assets/ -log-format: '$remote_addr "$request" $status $http_user_agent' -log-file: ./dufs.log -compress: low -tls-cert: tests/data/cert.pem -tls-key: tests/data/key_pkcs1.pem -``` - -### Customize UI - -Dufs allows users to customize the UI with your own assets. - -``` -dufs --assets my-assets-dir/ -``` - -> If you only need to make slight adjustments to the current UI, you copy dufs's [assets](https://github.com/sigoden/dufs/tree/main/assets) directory and modify it accordingly. The current UI doesn't use any frameworks, just plain HTML/JS/CSS. As long as you have some basic knowledge of web development, it shouldn't be difficult to modify. - -Your assets folder must contains a `index.html` file. - -`index.html` can use the following placeholder variables to retrieve internal data. - -- `__INDEX_DATA__`: directory listing data -- `__ASSETS_PREFIX__`: assets url prefix - -
- -## License - -Copyright (c) 2022-2024 dufs-developers. - -dufs is made available under the terms of either the MIT License or the Apache License 2.0, at your option. - -See the LICENSE-APACHE and LICENSE-MIT files for license details. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 861c70b..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,21 +0,0 @@ -# Security Policy - -## Supported Versions - -The latest release of *dufs* is supported. The fixes for any security issues found will be included -in the next release. - - -## Reporting a Vulnerability - -Please [use *dufs*'s security advisory reporting tool provided by -GitHub](https://github.com/sigoden/dufs/security/advisories/new) to report security issues. - -We strive to fix security issues as quickly as possible. Across the industry, often the developers' -slowness in developing and releasing a fix is the biggest delay in the process; we take pride in -minimizing this delay as much as we practically can. We encourage you to also minimize the delay -between when you find an issue and when you contact us. You do not need to convince us to take your -report seriously. You don't need to create a PoC or a patch if that would slow down your reporting. -You don't need an elaborate write-up. A short, informal note about the issue is good. We can always -communicate later to fill in any details we need after that first note is shared with us. - diff --git a/assets/index.css b/assets/index.css index d2bb8d7..4e64927 100644 --- a/assets/index.css +++ b/assets/index.css @@ -1,6 +1,7 @@ :root { --lm-color: #004088; --dm-color: #004088; + --grid-size: 150px; } html { @@ -20,6 +21,7 @@ body { } .head { + z-index:3; display: flex; flex-wrap: wrap; align-items: center; @@ -36,7 +38,7 @@ body { } .breadcrumb>a { - color: #0366d6; + color: #0044aa; text-decoration: none; } @@ -303,6 +305,120 @@ body { background-color: rgba(3, 47, 98, 0.2); } +.thumbnail-preview { + display: inline-block; + vertical-align: top; + font-style: italic; + color: rgba(3, 47, 98, 0.2); +} + +.thumbnail { + display: none; + position: absolute; + margin-left: -170px; + margin-top: -200px; + width: 200px; + height: 200px; + object-fit: contain; +} + +.thumbnail-preview:hover > .thumbnail { + display: block; +} + +.grid-mode { + display: block; + width: 100%; +} + +.grid-mode .path a { + position: relative; + width: calc(var(--grid-size) - 10px); + min-width: var(--grid-size); + height: 25px; + margin-left: 10px; + padding-top: var(--grid-size); + display: inline-block; + z-index: 1; +} + +.grid-mode > thead { + display: none; +} +.grid-mode > tbody { + display: block; +} +.grid-mode > tbody > tr { + display: inline-block; +} +.grid-mode > tbody > tr > td { + display: block; +} +.grid-mode > tbody > tr { + width: var(--grid-size); + height: calc(var(--grid-size) + 25px); + display: inline-block; +} +.grid-mode > tbody > tr > td:not(.cell-name, .cell-icon) { + display: none !important; +} +.grid-mode > tbody > tr > td.cell-name { + width: var(--grid-size); + height: calc(var(--grid-size) + 25px); + display: block; + margin-top: calc(var(--grid-size)*-1); +} +.grid-mode > tbody > tr > td.cell-name > * { + width: var(--grid-size); + height: calc(var(--grid-size) + 25px); + margin-bottom: calc(-1 * (var(--grid-size) + 25px)); + margin-right: calc(var(--grid-size)*-1); +} +.grid-mode > tbody > tr > td.cell-name > .dropcopy { + display: none; +} +.grid-mode > tbody > tr > td.cell-name > .dropcopy { + display: none; +} +.grid-mode > tbody > tr > td.cell-name > .dropmove { + position: relative; + height: calc(var(--grid-size) + 25px); + color: rgba(3, 47, 98, 0.0); + border: 2px solid rgba(3, 47, 98, 0.0); + border-radius: 4px; + background-color: rgba(3, 47, 98, 0); +} +.grid-mode > tbody > tr > td.cell-name > .dropmove.dragging { + z-index:2; +} +.grid-mode > tbody > tr > td.cell-name > .dropmove.dragging.dragover { + background-color: rgba(3, 47, 98, 0.2); +} +.grid-mode > tbody > tr > td.cell-icon { + display: block; + width: var(--grid-size); + height: var(--grid-size); +} +.grid-mode > tbody > tr > td.cell-icon.has-preview { + opacity: 0; +} +.grid-mode > tbody > tr > td.cell-icon > svg { + width: var(--grid-size); + height: var(--grid-size); +} +.grid-mode > tbody > tr > td > .thumbnail-preview { +} +.grid-mode > tbody > tr > td > .thumbnail-preview > span { + display: none; +} +.grid-mode > tbody > tr > td > .thumbnail-preview > img { + width: var(--grid-size); + height: var(--grid-size); + display: block; + position: static; + margin: 0; +} + @media (min-width: 768px) { .path a { min-width: 400px; @@ -358,3 +474,18 @@ body { color: white; } } + +@media print { + .path a { + color: #24292e; + } + .main { + padding: 2em; + } + .paths-table { + width: 100%; + } + .head, #filedrop, .cell-actions, th > a > span { + display: none !important; + } +} diff --git a/assets/index.html b/assets/index.html index de4e464..a3e9c0d 100644 --- a/assets/index.html +++ b/assets/index.html @@ -62,6 +62,14 @@ d="M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5L14 4.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h-2z" /> +