mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 09:09:03 +03:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0b413ef30 | ||
|
|
fc13d41c17 | ||
|
|
882a9ae716 | ||
|
|
5578ee9190 | ||
|
|
916602ae2d | ||
|
|
2f40313a54 | ||
|
|
05155aa532 | ||
|
|
4605701366 | ||
|
|
b7c550e09b | ||
|
|
fff8fc3ac5 | ||
|
|
0616602659 | ||
|
|
0a64762df4 | ||
|
|
f103e15e15 | ||
|
|
9dda55b7c8 | ||
|
|
c3dd0f0ec5 | ||
|
|
4167e5c07e | ||
|
|
f66e129985 | ||
|
|
7c3970480e | ||
|
|
34bc8d411a | ||
|
|
51cedf2f8a | ||
|
|
48c3c7ded6 | ||
|
|
4491a74b34 | ||
|
|
7c2449cb1a | ||
|
|
0a3d9c391f | ||
|
|
07f4e7d0f2 | ||
|
|
c50f97925c | ||
|
|
ecb3984edc | ||
|
|
24f885164a | ||
|
|
201afa6725 | ||
|
|
e2d7f996c7 | ||
|
|
97978719b3 | ||
|
|
9aa16d3a10 | ||
|
|
d208b5cb6b | ||
|
|
605c6c56c4 | ||
|
|
8718562889 | ||
|
|
830d3343f4 | ||
|
|
1fe391f9d9 | ||
|
|
b88381167b | ||
|
|
35ed4394df | ||
|
|
f43d0b646d | ||
|
|
a9294f602c | ||
|
|
584d33940a | ||
|
|
fc090b6930 | ||
|
|
19d7b36462 | ||
|
|
755554d3f2 | ||
|
|
6a097e0496 | ||
|
|
412d42e338 | ||
|
|
ec60752ba2 | ||
|
|
ed7f5e425a | ||
|
|
3032052923 | ||
|
|
be3ae2fe00 | ||
|
|
fb03f7ddb8 | ||
|
|
54df4633e1 | ||
|
|
6b293c0f2e | ||
|
|
62696b45fd | ||
|
|
d9547ad00b | ||
|
|
8fbc742c52 | ||
|
|
d8d5aae898 | ||
|
|
a263d18963 | ||
|
|
10aabcb2f2 | ||
|
|
06ce7b0175 | ||
|
|
4841ebb76d | ||
|
|
586b209c89 | ||
|
|
2eba975066 | ||
|
|
c8a25b54ab | ||
|
|
8900dde7e7 | ||
|
|
06d2b81824 | ||
|
|
3673a64ec7 | ||
|
|
d9a917176a | ||
|
|
cdb7b5fc87 | ||
|
|
76569581dd | ||
|
|
ae11a39804 | ||
|
|
63e6906393 | ||
|
|
e6ea7e4f75 | ||
|
|
8db039c53b |
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Directories
|
||||||
|
/.git/
|
||||||
|
/.github/
|
||||||
|
/target/
|
||||||
|
/examples/
|
||||||
|
/docs/
|
||||||
|
/benches/
|
||||||
|
/tmp/
|
||||||
|
|
||||||
|
# Files
|
||||||
|
.gitignore
|
||||||
|
*.md
|
||||||
|
LICENSE*
|
||||||
43
.github/workflows/release.yaml
vendored
43
.github/workflows/release.yaml
vendored
@@ -6,8 +6,10 @@ on:
|
|||||||
- v[0-9]+.[0-9]+.[0-9]+*
|
- v[0-9]+.[0-9]+.[0-9]+*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
all:
|
release:
|
||||||
name: All
|
name: Publish to Github Reelases
|
||||||
|
outputs:
|
||||||
|
rc: ${{ steps.check-tag.outputs.rc }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -124,3 +126,40 @@ jobs:
|
|||||||
prerelease: ${{ steps.check-tag.outputs.rc == 'true' }}
|
prerelease: ${{ steps.check-tag.outputs.rc == 'true' }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
docker:
|
||||||
|
name: Publish to Docker Hub
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: ${{ needs.release.outputs.rc == 'false' }}
|
||||||
|
tags: sigoden/duf:latest, sigoden/duf:${{ github.ref_name }}
|
||||||
|
|
||||||
|
publish-crate:
|
||||||
|
name: Publish to crates.io
|
||||||
|
if: ${{ needs.release.outputs.rc == 'false' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
- name: Publish
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
|
||||||
|
run: cargo publish
|
||||||
199
CHANGELOG.md
Normal file
199
CHANGELOG.md
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.13.0] - 2022-06-05
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Ctrl+c not exit sometimes
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Implement more webdav methods ([#13](https://github.com/sigoden/duf/issues/13))
|
||||||
|
- Use digest auth ([#14](https://github.com/sigoden/duf/issues/14))
|
||||||
|
- Add webdav proppatch handler ([#18](https://github.com/sigoden/duf/issues/18))
|
||||||
|
|
||||||
|
## [0.12.1] - 2022-06-04
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Support webdav ([#10](https://github.com/sigoden/duf/issues/10))
|
||||||
|
- Remove unzip uploaded feature ([#11](https://github.com/sigoden/duf/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
|
||||||
|
|
||||||
|
<!-- generated by git-cliff -->
|
||||||
806
Cargo.lock
generated
806
Cargo.lock
generated
@@ -2,6 +2,105 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-channel"
|
||||||
|
version = "1.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319"
|
||||||
|
dependencies = [
|
||||||
|
"concurrent-queue",
|
||||||
|
"event-listener",
|
||||||
|
"futures-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-compression"
|
||||||
|
version = "0.3.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "345fd392ab01f746c717b1357165b76f0b67a60192007b234058c9045fdcf695"
|
||||||
|
dependencies = [
|
||||||
|
"bzip2",
|
||||||
|
"flate2",
|
||||||
|
"futures-core",
|
||||||
|
"memchr",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
"xz2",
|
||||||
|
"zstd",
|
||||||
|
"zstd-safe",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-fs"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2"
|
||||||
|
dependencies = [
|
||||||
|
"async-lock",
|
||||||
|
"blocking",
|
||||||
|
"futures-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-lock"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6"
|
||||||
|
dependencies = [
|
||||||
|
"event-listener",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-task"
|
||||||
|
version = "4.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-walkdir"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "826d88d73e87e7504b635b6e427561faa6a65f4a2f59e75efcbfa51a0876bb90"
|
||||||
|
dependencies = [
|
||||||
|
"async-fs",
|
||||||
|
"futures-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async_io_utilities"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0248112abfeab682c97306bc1e180ee957260107a55a437cedf9a3acca92135e"
|
||||||
|
dependencies = [
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async_zip"
|
||||||
|
version = "0.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0a5c419dca9559f15d04befbf9ff01c39ca16d4c0abd56f60daaf87a386b929"
|
||||||
|
dependencies = [
|
||||||
|
"async-compression",
|
||||||
|
"async_io_utilities",
|
||||||
|
"chrono",
|
||||||
|
"crc32fast",
|
||||||
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic-waker"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -20,18 +119,102 @@ version = "1.3.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-buffer"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "blocking"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc"
|
||||||
|
dependencies = [
|
||||||
|
"async-channel",
|
||||||
|
"async-task",
|
||||||
|
"atomic-waker",
|
||||||
|
"fastrand",
|
||||||
|
"futures-lite",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bzip2"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0"
|
||||||
|
dependencies = [
|
||||||
|
"bzip2-sys",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bzip2-sys"
|
||||||
|
version = "0.1.11+1.0.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "c_linked_list"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cache-padded"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.73"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||||
|
dependencies = [
|
||||||
|
"jobserver",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"time",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "3.1.18"
|
version = "3.1.18"
|
||||||
@@ -55,18 +238,105 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "duf"
|
name = "concurrent-queue"
|
||||||
version = "0.1.0"
|
version = "1.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cache-padded",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpufeatures"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc32fast"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crypto-common"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
"typenum",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "digest"
|
||||||
|
version = "0.10.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer",
|
||||||
|
"crypto-common",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "duf"
|
||||||
|
version = "0.13.0"
|
||||||
|
dependencies = [
|
||||||
|
"async-walkdir",
|
||||||
|
"async_zip",
|
||||||
"base64",
|
"base64",
|
||||||
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"futures",
|
"futures",
|
||||||
|
"get_if_addrs",
|
||||||
|
"headers",
|
||||||
"hyper",
|
"hyper",
|
||||||
|
"lazy_static",
|
||||||
|
"md5",
|
||||||
|
"mime_guess",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
|
"rustls",
|
||||||
|
"rustls-pemfile",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
|
"tokio-stream",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener"
|
||||||
|
version = "2.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "1.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
|
||||||
|
dependencies = [
|
||||||
|
"instant",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flate2"
|
||||||
|
version = "1.0.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crc32fast",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -123,6 +393,21 @@ version = "0.3.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
|
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-lite"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
|
||||||
|
dependencies = [
|
||||||
|
"fastrand",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"memchr",
|
||||||
|
"parking",
|
||||||
|
"pin-project-lite",
|
||||||
|
"waker-fn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-macro"
|
name = "futures-macro"
|
||||||
version = "0.3.21"
|
version = "0.3.21"
|
||||||
@@ -164,12 +449,86 @@ dependencies = [
|
|||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gcc"
|
||||||
|
version = "0.3.55"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generic-array"
|
||||||
|
version = "0.14.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803"
|
||||||
|
dependencies = [
|
||||||
|
"typenum",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "get_if_addrs"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7"
|
||||||
|
dependencies = [
|
||||||
|
"c_linked_list",
|
||||||
|
"get_if_addrs-sys",
|
||||||
|
"libc",
|
||||||
|
"winapi 0.2.8",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "get_if_addrs-sys"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48"
|
||||||
|
dependencies = [
|
||||||
|
"gcc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.11.2"
|
version = "0.11.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "headers"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4cff78e5788be1e0ab65b04d306b2ed5092c815ec97ec70f4ebd5aee158aa55d"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
"bitflags",
|
||||||
|
"bytes",
|
||||||
|
"headers-core",
|
||||||
|
"http",
|
||||||
|
"httpdate",
|
||||||
|
"mime",
|
||||||
|
"sha-1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "headers-core"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
|
||||||
|
dependencies = [
|
||||||
|
"http",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.19"
|
version = "0.1.19"
|
||||||
@@ -215,9 +574,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper"
|
name = "hyper"
|
||||||
version = "0.14.18"
|
version = "0.14.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2"
|
checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
@@ -238,20 +597,47 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.8.1"
|
version = "1.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
|
checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "instant"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
|
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jobserver"
|
||||||
|
version = "0.1.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.57"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -273,12 +659,54 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lzma-sys"
|
||||||
|
version = "0.1.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bdb4b7c3eddad11d3af9e86c487607d2d2442d185d848575365c4856ba96d619"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "md5"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[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.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||||
|
dependencies = [
|
||||||
|
"mime",
|
||||||
|
"unicase",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
|
||||||
|
dependencies = [
|
||||||
|
"adler",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
@@ -287,10 +715,29 @@ checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-integer"
|
||||||
|
version = "0.1.45"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_cpus"
|
name = "num_cpus"
|
||||||
version = "1.13.1"
|
version = "1.13.1"
|
||||||
@@ -313,6 +760,12 @@ version = "6.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
|
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@@ -331,6 +784,18 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkg-config"
|
||||||
|
version = "0.3.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.39"
|
version = "1.0.39"
|
||||||
@@ -349,12 +814,88 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.6.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ring"
|
||||||
|
version = "0.16.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
"spin",
|
||||||
|
"untrusted",
|
||||||
|
"web-sys",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls"
|
||||||
|
version = "0.20.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"ring",
|
||||||
|
"sct",
|
||||||
|
"webpki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-pemfile"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7522c9de787ff061458fe9a829dc790a3f5b22dc571694fc5883f448b94d9a9"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.10"
|
version = "1.0.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
|
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sct"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
|
||||||
|
dependencies = [
|
||||||
|
"ring",
|
||||||
|
"untrusted",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.137"
|
version = "1.0.137"
|
||||||
@@ -386,6 +927,26 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha-1"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "signal-hook-registry"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
@@ -399,9 +960,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
|
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"winapi",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spin"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.95"
|
version = "1.0.95"
|
||||||
@@ -419,6 +986,37 @@ version = "0.15.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "1.0.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "1.0.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.44"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.18.2"
|
version = "1.18.2"
|
||||||
@@ -432,9 +1030,10 @@ dependencies = [
|
|||||||
"num_cpus",
|
"num_cpus",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"winapi",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -448,6 +1047,28 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-rustls"
|
||||||
|
version = "0.23.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
|
||||||
|
dependencies = [
|
||||||
|
"rustls",
|
||||||
|
"tokio",
|
||||||
|
"webpki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-stream"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
@@ -506,12 +1127,55 @@ version = "0.2.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
|
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typenum"
|
||||||
|
version = "1.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicase"
|
||||||
|
version = "2.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "untrusted"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c6d5d669b51467dcf7b2f1a796ce0f955f05f01cafda6c19d6e95f730df29238"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"rand",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "waker-fn"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "want"
|
name = "want"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@@ -522,12 +1186,98 @@ dependencies = [
|
|||||||
"try-lock",
|
"try-lock",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.80"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.80"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.80"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.80"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.80"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.57"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "webpki"
|
||||||
|
version = "0.22.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
|
||||||
|
dependencies = [
|
||||||
|
"ring",
|
||||||
|
"untrusted",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.2.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -592,3 +1342,41 @@ name = "windows_x86_64_msvc"
|
|||||||
version = "0.36.1"
|
version = "0.36.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xz2"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c179869f34fc7c01830d3ce7ea2086bc3a07e0d35289b667d0a8bf910258926c"
|
||||||
|
dependencies = [
|
||||||
|
"lzma-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zstd"
|
||||||
|
version = "0.11.2+zstd.1.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
|
||||||
|
dependencies = [
|
||||||
|
"zstd-safe",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zstd-safe"
|
||||||
|
version = "5.0.2+zstd.1.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"zstd-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zstd-sys"
|
||||||
|
version = "2.0.1+zstd.1.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|||||||
23
Cargo.toml
23
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "duf"
|
name = "duf"
|
||||||
version = "0.1.0"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["sigoden <sigoden@gmail.com>"]
|
authors = ["sigoden <sigoden@gmail.com>"]
|
||||||
description = "Duf is a simple file server."
|
description = "Duf is a simple file server."
|
||||||
@@ -9,18 +9,31 @@ homepage = "https://github.com/sigoden/duf"
|
|||||||
repository = "https://github.com/sigoden/duf"
|
repository = "https://github.com/sigoden/duf"
|
||||||
autotests = false
|
autotests = false
|
||||||
categories = ["command-line-utilities", "web-programming::http-server"]
|
categories = ["command-line-utilities", "web-programming::http-server"]
|
||||||
keywords = ["static", "file", "server", "upload", "http", "cli"]
|
keywords = ["static", "file", "server", "webdav", "cli"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3", default-features = false, features = ["std", "cargo"] }
|
clap = { version = "3", default-features = false, features = ["std", "cargo"] }
|
||||||
tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "io-util"]}
|
chrono = "0.4"
|
||||||
|
tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "io-util", "signal"]}
|
||||||
|
tokio-rustls = "0.23"
|
||||||
|
tokio-stream = { version = "0.1", features = ["net"] }
|
||||||
|
tokio-util = { version = "0.7", features = ["codec", "io-util"] }
|
||||||
hyper = { version = "0.14", features = ["http1", "server", "tcp", "stream"] }
|
hyper = { version = "0.14", features = ["http1", "server", "tcp", "stream"] }
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
tokio-util = { version = "0.7", features = ["codec", "io-util"] }
|
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
base64 = "0.13.0"
|
base64 = "0.13"
|
||||||
|
async_zip = "0.0.7"
|
||||||
|
async-walkdir = "0.2.0"
|
||||||
|
headers = "0.3.7"
|
||||||
|
mime_guess = "2.0.4"
|
||||||
|
get_if_addrs = "0.5.3"
|
||||||
|
rustls = { version = "0.20", default-features = false, features = ["tls12"] }
|
||||||
|
rustls-pemfile = "1"
|
||||||
|
md5 = "0.7.0"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
uuid = { version = "1.1.1", features = ["v4", "fast-rng"] }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|||||||
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM rust:1.61 as builder
|
||||||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y musl-tools
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
RUN cargo build --target x86_64-unknown-linux-musl --release
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/duf /bin/
|
||||||
|
ENTRYPOINT ["/bin/duf"]
|
||||||
83
README.md
83
README.md
@@ -3,15 +3,20 @@
|
|||||||
[](https://github.com/sigoden/duf/actions/workflows/ci.yaml)
|
[](https://github.com/sigoden/duf/actions/workflows/ci.yaml)
|
||||||
[](https://crates.io/crates/duf)
|
[](https://crates.io/crates/duf)
|
||||||
|
|
||||||
Duf is a simple file server.
|
Duf is a simple file server. Support static serve, search, upload, webdav...
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Serve static files
|
- Serve static files
|
||||||
- Upload/Delete files
|
- Download folder as zip file
|
||||||
- Support basic auth
|
- Upload files and folders (Drag & Drop)
|
||||||
|
- Search files
|
||||||
|
- Partial responses (Parallel/Resume download)
|
||||||
|
- Authentication
|
||||||
|
- Support https
|
||||||
|
- Support webdav
|
||||||
- Easy to use with curl
|
- Easy to use with curl
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
@@ -22,11 +27,47 @@ Duf is a simple file server.
|
|||||||
cargo install duf
|
cargo install duf
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### With docker
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -v /tmp:/tmp -p 5000:5000 --rm -it docker.io/sigoden/duf /tmp
|
||||||
|
```
|
||||||
|
|
||||||
### Binaries on macOS, Linux, Windows
|
### Binaries on macOS, Linux, Windows
|
||||||
|
|
||||||
Download from [Github Releases](https://github.com/sigoden/duf/releases), unzip and add duf to your $PATH.
|
Download from [Github Releases](https://github.com/sigoden/duf/releases), unzip and add duf to your $PATH.
|
||||||
|
|
||||||
## Usage
|
## CLI
|
||||||
|
|
||||||
|
```
|
||||||
|
Duf is a simple file server.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
duf [OPTIONS] [path]
|
||||||
|
|
||||||
|
ARGS:
|
||||||
|
<path> Path to a root directory for serving files [default: .]
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
-a, --auth <user:pass> Use HTTP authentication
|
||||||
|
--no-auth-access Not required auth when access static files
|
||||||
|
-A, --allow-all Allow all operations
|
||||||
|
--allow-delete Allow delete files/folders
|
||||||
|
--allow-symlink Allow symlink to files/folders outside root directory
|
||||||
|
--allow-upload Allow upload files/folders
|
||||||
|
-b, --bind <address> Specify bind address [default: 0.0.0.0]
|
||||||
|
--cors Enable CORS, sets `Access-Control-Allow-Origin: *`
|
||||||
|
-h, --help Print help information
|
||||||
|
-p, --port <port> Specify port to listen on [default: 5000]
|
||||||
|
--path-prefix <path> Specify an url path prefix
|
||||||
|
--render-index Render index.html when requesting a directory
|
||||||
|
--render-spa Render for single-page application
|
||||||
|
--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
|
||||||
|
-V, --version Print version information
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
You can run this command to start serving your current working directory on 127.0.0.1:5000 by default.
|
You can run this command to start serving your current working directory on 127.0.0.1:5000 by default.
|
||||||
|
|
||||||
@@ -34,23 +75,47 @@ You can run this command to start serving your current working directory on 127.
|
|||||||
duf
|
duf
|
||||||
```
|
```
|
||||||
|
|
||||||
...or specify which folder you want to serve:
|
...or specify which folder you want to serve.
|
||||||
|
|
||||||
```
|
```
|
||||||
duf folder_name
|
duf folder_name
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, run this command to see a list of all available option
|
Allow all operations such as upload, delete
|
||||||
|
|
||||||
|
```sh
|
||||||
|
duf --allow-all
|
||||||
|
```
|
||||||
|
|
||||||
|
Only allow upload operation
|
||||||
|
|
||||||
## Curl
|
```
|
||||||
|
duf --allow-upload
|
||||||
|
```
|
||||||
|
|
||||||
|
Serve a single page application (SPA)
|
||||||
|
|
||||||
|
```
|
||||||
|
duf --render-spa
|
||||||
|
```
|
||||||
|
|
||||||
|
Use https
|
||||||
|
|
||||||
|
```
|
||||||
|
duf --tls-cert my.crt --tls-key my.key
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
Download a file
|
Download a file
|
||||||
```
|
```
|
||||||
curl http://127.0.0.1:5000/some-file
|
curl http://127.0.0.1:5000/some-file
|
||||||
|
```
|
||||||
|
|
||||||
curl -o some-file.zip http://127.0.0.1:5000/some-file.zip
|
Download a folder as zip file
|
||||||
|
|
||||||
|
```
|
||||||
|
curl -o some-folder.zip http://127.0.0.1:5000/some-folder?zip
|
||||||
```
|
```
|
||||||
|
|
||||||
Upload a file
|
Upload a file
|
||||||
|
|||||||
@@ -4,16 +4,21 @@ html {
|
|||||||
color: #24292e;
|
color: #24292e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.head {
|
body {
|
||||||
display: flex;
|
width: 700px;
|
||||||
align-items: baseline;
|
|
||||||
padding: 1em 1em 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.head input {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.head {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
padding: 1em 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
.breadcrumb {
|
.breadcrumb {
|
||||||
font-size: 1.25em;
|
font-size: 1.25em;
|
||||||
}
|
}
|
||||||
@@ -44,42 +49,91 @@ html {
|
|||||||
padding-left: 0.5em;
|
padding-left: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toolbox {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchbar {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
width: 246px;
|
||||||
|
height: 22px;
|
||||||
|
background-color: #fafafa;
|
||||||
|
transition: all .15s;
|
||||||
|
border: 1px #ddd solid;
|
||||||
|
border-radius: 15px;
|
||||||
|
margin: 0 0 2px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchbar #search {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 16px;
|
||||||
|
padding: 1px;
|
||||||
|
font-family: helvetica neue,luxi sans,Tahoma,hiragino sans gb,STHeiti,sans-serif;
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchbar .icon {
|
||||||
|
color: #9a9a9a;
|
||||||
|
padding: 3px 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.upload-control {
|
.upload-control {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding-left: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-control input {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
padding: 0 1em;
|
padding: 0 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main th {
|
.uploaders-table th,
|
||||||
|
.paths-table th {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-weight: unset;
|
font-weight: unset;
|
||||||
color: #5c5c5c;
|
color: #5c5c5c;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main td {
|
.uploaders-table td,
|
||||||
|
.paths-table td {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main .cell-name {
|
.uploaders-table .cell-name,
|
||||||
width: 300px;
|
.paths-table .cell-name {
|
||||||
|
width: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main .cell-mtime {
|
.uploaders-table .cell-status {
|
||||||
width: 150px;
|
width: 80px;
|
||||||
padding-left: 0.6em;
|
padding-left: 0.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main .cell-size {
|
.paths-table .cell-actions {
|
||||||
|
width: 60px;
|
||||||
|
display: flex;
|
||||||
|
padding-left: 0.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paths-table .cell-mtime {
|
||||||
|
width: 120px;
|
||||||
|
padding-left: 0.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paths-table .cell-size {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
width: 100px;
|
width: 70px;
|
||||||
padding-left: 0.6em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main .cell-actions {
|
|
||||||
width: 100px;
|
|
||||||
padding-left: 0.6em;
|
padding-left: 0.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,9 +162,11 @@ html {
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uploaders {
|
.action-btn {
|
||||||
display: flex;
|
padding-left: 0.4em;
|
||||||
flex-wrap: wrap;
|
}
|
||||||
|
|
||||||
|
.uploaders-table {
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
59
assets/index.html
Normal file
59
assets/index.html
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
__SLOT__
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="head">
|
||||||
|
<div class="breadcrumb"></div>
|
||||||
|
<div class="toolbox">
|
||||||
|
<div>
|
||||||
|
<a href="?zip" title="Download folder as a .zip file">
|
||||||
|
<svg width="16" height="16" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/></svg>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="upload-control hidden" title="Upload files">
|
||||||
|
<label for="file">
|
||||||
|
<svg width="16" height="16" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/><path d="M7.646 1.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 2.707V11.5a.5.5 0 0 1-1 0V2.707L5.354 4.854a.5.5 0 1 1-.708-.708l3-3z"/></svg>
|
||||||
|
</label>
|
||||||
|
<input type="file" id="file" name="file" multiple>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form class="searchbar">
|
||||||
|
<div class="icon">
|
||||||
|
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>
|
||||||
|
</div>
|
||||||
|
<input id="search" name="q" type="text" maxlength="128" autocomplete="off" tabindex="1">
|
||||||
|
<input type="submit" hidden />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="main">
|
||||||
|
<table class="uploaders-table hidden">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="cell-name">Name</th>
|
||||||
|
<th class="cell-status">Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
<table class="paths-table hidden">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="cell-name">Name</th>
|
||||||
|
<th class="cell-mtime">Date modify</th>
|
||||||
|
<th class="cell-size">Size</th>
|
||||||
|
<th class="cell-actions">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
window.addEventListener("DOMContentLoaded", ready);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
298
assets/index.js
Normal file
298
assets/index.js
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
/**
|
||||||
|
* @typedef {object} PathItem
|
||||||
|
* @property {"Dir"|"SymlinkDir"|"File"|"SymlinkFile"} path_type
|
||||||
|
* @property {boolean} is_symlink
|
||||||
|
* @property {string} name
|
||||||
|
* @property {number} mtime
|
||||||
|
* @property {number} size
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type Element
|
||||||
|
*/
|
||||||
|
let $pathsTable, $pathsTableBody, $uploadersTable;
|
||||||
|
/**
|
||||||
|
* @type string
|
||||||
|
*/
|
||||||
|
let baseDir;
|
||||||
|
|
||||||
|
class Uploader {
|
||||||
|
/**
|
||||||
|
* @type number
|
||||||
|
*/
|
||||||
|
idx;
|
||||||
|
/**
|
||||||
|
* @type File
|
||||||
|
*/
|
||||||
|
file;
|
||||||
|
/**
|
||||||
|
* @type string
|
||||||
|
*/
|
||||||
|
name;
|
||||||
|
/**
|
||||||
|
* @type Element
|
||||||
|
*/
|
||||||
|
$uploadStatus;
|
||||||
|
static globalIdx = 0;
|
||||||
|
constructor(file, dirs) {
|
||||||
|
this.name = [...dirs, file.name].join("/");
|
||||||
|
this.idx = Uploader.globalIdx++;
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
upload() {
|
||||||
|
const { file, idx, name } = this;
|
||||||
|
let url = getUrl(name);
|
||||||
|
$uploadersTable.insertAdjacentHTML("beforeend", `
|
||||||
|
<tr id="upload${idx}" class="uploader">
|
||||||
|
<td class="path cell-name">
|
||||||
|
<div>${getSvg("File")}</div>
|
||||||
|
<a href="${url}">${name}</a>
|
||||||
|
</td>
|
||||||
|
<td class="cell-status" id="uploadStatus${idx}"></td>
|
||||||
|
</tr>`);
|
||||||
|
$uploadersTable.classList.remove("hidden");
|
||||||
|
this.$uploadStatus = document.getElementById(`uploadStatus${idx}`);
|
||||||
|
|
||||||
|
const ajax = new XMLHttpRequest();
|
||||||
|
ajax.upload.addEventListener("progress", e => this.progress(e), false);
|
||||||
|
ajax.addEventListener("readystatechange", () => {
|
||||||
|
if(ajax.readyState === 4) {
|
||||||
|
if (ajax.status >= 200 && ajax.status < 300) {
|
||||||
|
this.complete();
|
||||||
|
} else {
|
||||||
|
this.fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ajax.addEventListener("error", () => this.fail(), false);
|
||||||
|
ajax.addEventListener("abort", () => this.fail(), false);
|
||||||
|
ajax.open("PUT", url);
|
||||||
|
ajax.send(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
progress(event) {
|
||||||
|
const percent = (event.loaded / event.total) * 100;
|
||||||
|
this.$uploadStatus.innerHTML = `${percent.toFixed(2)}%`;
|
||||||
|
}
|
||||||
|
|
||||||
|
complete() {
|
||||||
|
this.$uploadStatus.innerHTML = `✓`;
|
||||||
|
}
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
this.$uploadStatus.innerHTML = `✗`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add breadcrumb
|
||||||
|
* @param {string} value
|
||||||
|
*/
|
||||||
|
function addBreadcrumb(value) {
|
||||||
|
const $breadcrumb = document.querySelector(".breadcrumb");
|
||||||
|
const parts = value.split("/").filter(v => !!v);
|
||||||
|
const len = parts.length;
|
||||||
|
let path = "";
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const name = parts[i];
|
||||||
|
if (i > 0) {
|
||||||
|
path += "/" + name;
|
||||||
|
}
|
||||||
|
if (i === len - 1) {
|
||||||
|
$breadcrumb.insertAdjacentHTML("beforeend", `<b>${name}</b>`);
|
||||||
|
baseDir = name;
|
||||||
|
} else if (i === 0) {
|
||||||
|
$breadcrumb.insertAdjacentHTML("beforeend", `<a href="/"><b>${name}</b></a>`);
|
||||||
|
} else {
|
||||||
|
$breadcrumb.insertAdjacentHTML("beforeend", `<a href="${encodeURI(path)}">${name}</a>`);
|
||||||
|
}
|
||||||
|
$breadcrumb.insertAdjacentHTML("beforeend", `<span class="separator">/</span>`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add pathitem
|
||||||
|
* @param {PathItem} file
|
||||||
|
* @param {number} index
|
||||||
|
*/
|
||||||
|
function addPath(file, index) {
|
||||||
|
const url = getUrl(file.name)
|
||||||
|
let actionDelete = "";
|
||||||
|
let actionDownload = "";
|
||||||
|
if (file.path_type.endsWith("Dir")) {
|
||||||
|
actionDownload = `
|
||||||
|
<div class="action-btn">
|
||||||
|
<a href="${url}?zip" title="Download folder as a .zip file">
|
||||||
|
<svg width="16" height="16" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/></svg>
|
||||||
|
</a>
|
||||||
|
</div>`;
|
||||||
|
} else {
|
||||||
|
actionDownload = `
|
||||||
|
<div class="action-btn" >
|
||||||
|
<a href="${url}" title="Download file" download>
|
||||||
|
<svg width="16" height="16" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/></svg>
|
||||||
|
</a>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
if (DATA.allow_delete) {
|
||||||
|
actionDelete = `
|
||||||
|
<div onclick="deletePath(${index})" class="action-btn" id="deleteBtn${index}" title="Delete ${file.name}">
|
||||||
|
<svg width="16" height="16" fill="currentColor"viewBox="0 0 16 16"><path d="M6.854 7.146a.5.5 0 1 0-.708.708L7.293 9l-1.147 1.146a.5.5 0 0 0 .708.708L8 9.707l1.146 1.147a.5.5 0 0 0 .708-.708L8.707 9l1.147-1.146a.5.5 0 0 0-.708-.708L8 8.293 6.854 7.146z"/><path d="M14 14V4.5L9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2zM9.5 3A1.5 1.5 0 0 0 11 4.5h2V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h5.5v2z"/></svg>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
let actionCell = `
|
||||||
|
<td class="cell-actions">
|
||||||
|
${actionDownload}
|
||||||
|
${actionDelete}
|
||||||
|
</td>`
|
||||||
|
|
||||||
|
$pathsTableBody.insertAdjacentHTML("beforeend", `
|
||||||
|
<tr id="addPath${index}">
|
||||||
|
<td class="path cell-name">
|
||||||
|
<div>${getSvg(file.path_type)}</div>
|
||||||
|
<a href="${url}" title="${file.name}">${file.name}</a>
|
||||||
|
</td>
|
||||||
|
<td class="cell-mtime">${formatMtime(file.mtime)}</td>
|
||||||
|
<td class="cell-size">${formatSize(file.size)}</td>
|
||||||
|
${actionCell}
|
||||||
|
</tr>`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete pathitem
|
||||||
|
* @param {number} index
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async function deletePath(index) {
|
||||||
|
const file = DATA.paths[index];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
if (!confirm(`Delete \`${file.name}\`?`)) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch(getUrl(file.name), {
|
||||||
|
method: "DELETE",
|
||||||
|
});
|
||||||
|
if (res.status >= 200 && res.status < 300) {
|
||||||
|
document.getElementById(`addPath${index}`).remove();
|
||||||
|
DATA.paths[index] = null;
|
||||||
|
if (!DATA.paths.find(v => !!v)) {
|
||||||
|
$pathsTable.classList.add("hidden");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error(await res.text())
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
alert(`Cannot delete \`${file.name}\`, ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropzone() {
|
||||||
|
["drag", "dragstart", "dragend", "dragover", "dragenter", "dragleave", "drop"].forEach(name => {
|
||||||
|
document.addEventListener(name, e => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
document.addEventListener("drop", e => {
|
||||||
|
if (!e.dataTransfer.items[0].webkitGetAsEntry) {
|
||||||
|
const files = e.dataTransfer.files.filter(v => v.size > 0);
|
||||||
|
for (const file of files) {
|
||||||
|
new Uploader(file, []).upload();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const entries = [];
|
||||||
|
const len = e.dataTransfer.items.length;
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
entries.push(e.dataTransfer.items[i].webkitGetAsEntry());
|
||||||
|
}
|
||||||
|
addFileEntries(entries, [])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addFileEntries(entries, dirs) {
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (entry.isFile) {
|
||||||
|
entry.file(file => {
|
||||||
|
new Uploader(file, dirs).upload();
|
||||||
|
});
|
||||||
|
} else if (entry.isDirectory) {
|
||||||
|
const dirReader = entry.createReader()
|
||||||
|
dirReader.readEntries(entries => addFileEntries(entries, [...dirs, entry.name]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getUrl(name) {
|
||||||
|
let url = location.href.split('?')[0];
|
||||||
|
if (!url.endsWith("/")) url += "/";
|
||||||
|
url += encodeURI(name);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSvg(path_type) {
|
||||||
|
switch (path_type) {
|
||||||
|
case "Dir":
|
||||||
|
return `<svg height="16" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM6 4H1V3h5v1z"></path></svg>`;
|
||||||
|
case "File":
|
||||||
|
return `<svg height="16" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>`;
|
||||||
|
case "SymlinkDir":
|
||||||
|
return `<svg height="16" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM1 3h5v1H1V3zm6 9v-2c-.98-.02-1.84.22-2.55.7-.71.48-1.19 1.25-1.45 2.3.02-1.64.39-2.88 1.13-3.73C4.86 8.43 5.82 8 7.01 8V6l4 3-4 3H7z"></path></svg>`;
|
||||||
|
default:
|
||||||
|
return `<svg height="16" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M8.5 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V4.5L8.5 1zM11 14H1V2h7l3 3v9zM6 4.5l4 3-4 3v-2c-.98-.02-1.84.22-2.55.7-.71.48-1.19 1.25-1.45 2.3.02-1.64.39-2.88 1.13-3.73.73-.84 1.69-1.27 2.88-1.27v-2H6z"></path></svg>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatMtime(mtime) {
|
||||||
|
if (!mtime) return ""
|
||||||
|
const date = new Date(mtime);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = padZero(date.getMonth() + 1, 2);
|
||||||
|
const day = padZero(date.getDate(), 2);
|
||||||
|
const hours = padZero(date.getHours(), 2);
|
||||||
|
const minutes = padZero(date.getMinutes(), 2);
|
||||||
|
return `${year}/${month}/${day} ${hours}:${minutes}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function padZero(value, size) {
|
||||||
|
return ("0".repeat(size) + value).slice(-1 * size)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatSize(size) {
|
||||||
|
if (!size) return ""
|
||||||
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
|
if (size == 0) return '0 Byte';
|
||||||
|
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
|
||||||
|
return Math.round(size / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
function ready() {
|
||||||
|
$pathsTable = document.querySelector(".paths-table")
|
||||||
|
$pathsTableBody = document.querySelector(".paths-table tbody");
|
||||||
|
$uploadersTable = document.querySelector(".uploaders-table");
|
||||||
|
|
||||||
|
addBreadcrumb(DATA.breadcrumb);
|
||||||
|
if (Array.isArray(DATA.paths)) {
|
||||||
|
const len = DATA.paths.length;
|
||||||
|
if (len > 0) {
|
||||||
|
$pathsTable.classList.remove("hidden");
|
||||||
|
}
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
addPath(DATA.paths[i], i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (DATA.allow_upload) {
|
||||||
|
dropzone();
|
||||||
|
document.querySelector(".upload-control").classList.remove("hidden");
|
||||||
|
document.getElementById("file").addEventListener("change", e => {
|
||||||
|
const files = e.target.files;
|
||||||
|
for (let file of files) {
|
||||||
|
new Uploader(file, []).upload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
228
src/args.rs
228
src/args.rs
@@ -1,52 +1,108 @@
|
|||||||
use clap::crate_description;
|
use clap::crate_description;
|
||||||
use clap::{Arg, ArgMatches};
|
use clap::{Arg, ArgMatches};
|
||||||
use std::env;
|
use rustls::{Certificate, PrivateKey};
|
||||||
use std::fs::canonicalize;
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::{env, fs, io};
|
||||||
|
|
||||||
|
use crate::auth::parse_auth;
|
||||||
use crate::BoxResult;
|
use crate::BoxResult;
|
||||||
|
|
||||||
const ABOUT: &str = concat!("\n", crate_description!()); // Add extra newline.
|
const ABOUT: &str = concat!("\n", crate_description!()); // Add extra newline.
|
||||||
|
|
||||||
fn app() -> clap::Command<'static> {
|
fn app() -> clap::Command<'static> {
|
||||||
let arg_port = Arg::new("port")
|
clap::command!()
|
||||||
|
.about(ABOUT)
|
||||||
|
.arg(
|
||||||
|
Arg::new("address")
|
||||||
|
.short('b')
|
||||||
|
.long("bind")
|
||||||
|
.default_value("0.0.0.0")
|
||||||
|
.help("Specify bind address")
|
||||||
|
.value_name("address"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("port")
|
||||||
.short('p')
|
.short('p')
|
||||||
.long("port")
|
.long("port")
|
||||||
.default_value("5000")
|
.default_value("5000")
|
||||||
.help("Specify port to listen on")
|
.help("Specify port to listen on")
|
||||||
.value_name("port");
|
.value_name("port"),
|
||||||
|
)
|
||||||
let arg_address = Arg::new("address")
|
.arg(
|
||||||
.short('b')
|
Arg::new("path")
|
||||||
.long("bind")
|
|
||||||
.default_value("127.0.0.1")
|
|
||||||
.help("Specify bind address")
|
|
||||||
.value_name("address");
|
|
||||||
|
|
||||||
let arg_path = Arg::new("path")
|
|
||||||
.default_value(".")
|
.default_value(".")
|
||||||
.allow_invalid_utf8(true)
|
.allow_invalid_utf8(true)
|
||||||
.help("Path to a directory for serving files");
|
.help("Path to a root directory for serving files"),
|
||||||
|
)
|
||||||
let arg_readonly = Arg::new("readonly")
|
.arg(
|
||||||
.short('r')
|
Arg::new("path-prefix")
|
||||||
.long("readonly")
|
.long("path-prefix")
|
||||||
.help("Only serve static files, no operations like upload and delete");
|
.value_name("path")
|
||||||
|
.help("Specify an url path prefix"),
|
||||||
let arg_auth = Arg::new("auth")
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("allow-all")
|
||||||
|
.short('A')
|
||||||
|
.long("allow-all")
|
||||||
|
.help("Allow all operations"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("allow-upload")
|
||||||
|
.long("allow-upload")
|
||||||
|
.help("Allow upload files/folders"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("allow-delete")
|
||||||
|
.long("allow-delete")
|
||||||
|
.help("Allow delete files/folders"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("allow-symlink")
|
||||||
|
.long("allow-symlink")
|
||||||
|
.help("Allow symlink to files/folders outside root directory"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("render-index")
|
||||||
|
.long("render-index")
|
||||||
|
.help("Render index.html when requesting a directory"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("render-spa")
|
||||||
|
.long("render-spa")
|
||||||
|
.help("Render for single-page application"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("auth")
|
||||||
.short('a')
|
.short('a')
|
||||||
|
.display_order(1)
|
||||||
.long("auth")
|
.long("auth")
|
||||||
.help("Authenticate with user and pass")
|
.help("Use HTTP authentication")
|
||||||
.value_name("user:pass");
|
.value_name("user:pass"),
|
||||||
|
)
|
||||||
clap::command!()
|
.arg(
|
||||||
.about(ABOUT)
|
Arg::new("no-auth-access")
|
||||||
.arg(arg_address)
|
.display_order(1)
|
||||||
.arg(arg_port)
|
.long("no-auth-access")
|
||||||
.arg(arg_path)
|
.help("Not required auth when access static files"),
|
||||||
.arg(arg_readonly)
|
)
|
||||||
.arg(arg_auth)
|
.arg(
|
||||||
|
Arg::new("cors")
|
||||||
|
.long("cors")
|
||||||
|
.help("Enable CORS, sets `Access-Control-Allow-Origin: *`"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("tls-cert")
|
||||||
|
.long("tls-cert")
|
||||||
|
.value_name("path")
|
||||||
|
.help("Path to an SSL/TLS certificate to serve with HTTPS"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("tls-key")
|
||||||
|
.long("tls-key")
|
||||||
|
.value_name("path")
|
||||||
|
.help("Path to the SSL/TLS certificate's private key"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn matches() -> ArgMatches {
|
pub fn matches() -> ArgMatches {
|
||||||
@@ -58,8 +114,17 @@ pub struct Args {
|
|||||||
pub address: String,
|
pub address: String,
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub readonly: bool,
|
pub path_prefix: String,
|
||||||
pub auth: Option<String>,
|
pub uri_prefix: String,
|
||||||
|
pub auth: Option<(String, String)>,
|
||||||
|
pub no_auth_access: bool,
|
||||||
|
pub allow_upload: bool,
|
||||||
|
pub allow_delete: bool,
|
||||||
|
pub allow_symlink: bool,
|
||||||
|
pub render_index: bool,
|
||||||
|
pub render_spa: bool,
|
||||||
|
pub cors: bool,
|
||||||
|
pub tls: Option<(Vec<Certificate>, PrivateKey)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl Args {
|
||||||
@@ -70,17 +135,51 @@ impl Args {
|
|||||||
pub fn parse(matches: ArgMatches) -> BoxResult<Args> {
|
pub fn parse(matches: ArgMatches) -> BoxResult<Args> {
|
||||||
let address = matches.value_of("address").unwrap_or_default().to_owned();
|
let address = matches.value_of("address").unwrap_or_default().to_owned();
|
||||||
let port = matches.value_of_t::<u16>("port")?;
|
let port = matches.value_of_t::<u16>("port")?;
|
||||||
let path = matches.value_of_os("path").unwrap_or_default();
|
let path = Args::parse_path(matches.value_of_os("path").unwrap_or_default())?;
|
||||||
let path = Args::parse_path(path)?;
|
let path_prefix = matches
|
||||||
let readonly = matches.is_present("readonly");
|
.value_of("path-prefix")
|
||||||
let auth = matches.value_of("auth").map(|v| v.to_owned());
|
.map(|v| v.trim_matches('/').to_owned())
|
||||||
|
.unwrap_or_default();
|
||||||
|
let uri_prefix = if path_prefix.is_empty() {
|
||||||
|
"/".to_owned()
|
||||||
|
} else {
|
||||||
|
format!("/{}/", &path_prefix)
|
||||||
|
};
|
||||||
|
let cors = matches.is_present("cors");
|
||||||
|
let auth = match matches.value_of("auth") {
|
||||||
|
Some(auth) => Some(parse_auth(auth)?),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
let no_auth_access = matches.is_present("no-auth-access");
|
||||||
|
let allow_upload = matches.is_present("allow-all") || matches.is_present("allow-upload");
|
||||||
|
let allow_delete = matches.is_present("allow-all") || matches.is_present("allow-delete");
|
||||||
|
let allow_symlink = matches.is_present("allow-all") || matches.is_present("allow-symlink");
|
||||||
|
let render_index = matches.is_present("render-index");
|
||||||
|
let render_spa = matches.is_present("render-spa");
|
||||||
|
let tls = match (matches.value_of("tls-cert"), matches.value_of("tls-key")) {
|
||||||
|
(Some(certs_file), Some(key_file)) => {
|
||||||
|
let certs = load_certs(certs_file)?;
|
||||||
|
let key = load_private_key(key_file)?;
|
||||||
|
Some((certs, key))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Args {
|
Ok(Args {
|
||||||
address,
|
address,
|
||||||
port,
|
port,
|
||||||
path,
|
path,
|
||||||
readonly,
|
path_prefix,
|
||||||
|
uri_prefix,
|
||||||
auth,
|
auth,
|
||||||
|
no_auth_access,
|
||||||
|
cors,
|
||||||
|
allow_delete,
|
||||||
|
allow_upload,
|
||||||
|
allow_symlink,
|
||||||
|
render_index,
|
||||||
|
render_spa,
|
||||||
|
tls,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,34 +187,53 @@ impl Args {
|
|||||||
fn parse_path<P: AsRef<Path>>(path: P) -> BoxResult<PathBuf> {
|
fn parse_path<P: AsRef<Path>>(path: P) -> BoxResult<PathBuf> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
bail!("error: path \"{}\" doesn't exist", path.display());
|
return Err(format!("Path `{}` doesn't exist", path.display()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
env::current_dir()
|
env::current_dir()
|
||||||
.and_then(|mut p| {
|
.and_then(|mut p| {
|
||||||
p.push(path); // If path is absolute, it replaces the current path.
|
p.push(path); // If path is absolute, it replaces the current path.
|
||||||
canonicalize(p)
|
std::fs::canonicalize(p)
|
||||||
})
|
|
||||||
.or_else(|err| {
|
|
||||||
bail!(
|
|
||||||
"error: failed to access path \"{}\": {}",
|
|
||||||
path.display(),
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
.map_err(|err| format!("Failed to access path `{}`: {}", path.display(), err,).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct socket address from arguments.
|
/// Construct socket address from arguments.
|
||||||
pub fn address(&self) -> BoxResult<SocketAddr> {
|
pub fn address(&self) -> BoxResult<SocketAddr> {
|
||||||
format!("{}:{}", self.address, self.port)
|
format!("{}:{}", self.address, self.port)
|
||||||
.parse()
|
.parse()
|
||||||
.or_else(|err| {
|
.map_err(|_| format!("Invalid bind address `{}:{}`", self.address, self.port).into())
|
||||||
bail!(
|
|
||||||
"error: invalid address {}:{} : {}",
|
|
||||||
self.address,
|
|
||||||
self.port,
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load public certificate from file.
|
||||||
|
pub fn load_certs(filename: &str) -> BoxResult<Vec<Certificate>> {
|
||||||
|
// Open certificate file.
|
||||||
|
let certfile =
|
||||||
|
fs::File::open(&filename).map_err(|e| format!("Failed to open {}: {}", &filename, e))?;
|
||||||
|
let mut reader = io::BufReader::new(certfile);
|
||||||
|
|
||||||
|
// Load and return certificate.
|
||||||
|
let certs = rustls_pemfile::certs(&mut reader).map_err(|_| "Failed to load certificate")?;
|
||||||
|
if certs.is_empty() {
|
||||||
|
return Err("Expected at least one certificate".into());
|
||||||
|
}
|
||||||
|
Ok(certs.into_iter().map(Certificate).collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load private key from file.
|
||||||
|
pub fn load_private_key(filename: &str) -> BoxResult<PrivateKey> {
|
||||||
|
// Open keyfile.
|
||||||
|
let keyfile =
|
||||||
|
fs::File::open(&filename).map_err(|e| format!("Failed to open {}: {}", &filename, e))?;
|
||||||
|
let mut reader = io::BufReader::new(keyfile);
|
||||||
|
|
||||||
|
// Load and return a single private key.
|
||||||
|
let keys = rustls_pemfile::rsa_private_keys(&mut reader)
|
||||||
|
.map_err(|e| format!("There was a problem with reading private key: {:?}", e))?;
|
||||||
|
|
||||||
|
if keys.len() != 1 {
|
||||||
|
return Err("Expected a single private key".into());
|
||||||
|
}
|
||||||
|
Ok(PrivateKey(keys[0].to_owned()))
|
||||||
|
}
|
||||||
|
|||||||
209
src/auth.rs
Normal file
209
src/auth.rs
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
use headers::HeaderValue;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use md5::Context;
|
||||||
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::BoxResult;
|
||||||
|
|
||||||
|
const REALM: &str = "DUF";
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref NONCESTARTHASH: Context = {
|
||||||
|
let mut h = Context::new();
|
||||||
|
h.consume(Uuid::new_v4().as_bytes());
|
||||||
|
h.consume(std::process::id().to_be_bytes());
|
||||||
|
h
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate_www_auth(stale: bool) -> String {
|
||||||
|
let str_stale = if stale { "stale=true," } else { "" };
|
||||||
|
format!(
|
||||||
|
"Digest realm=\"{}\",nonce=\"{}\",{}qop=\"auth\",algorithm=\"MD5\"",
|
||||||
|
REALM,
|
||||||
|
create_nonce(),
|
||||||
|
str_stale
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_auth(auth: &str) -> BoxResult<(String, String)> {
|
||||||
|
let p: Vec<&str> = auth.trim().split(':').collect();
|
||||||
|
let err = "Invalid auth value";
|
||||||
|
if p.len() != 2 {
|
||||||
|
return Err(err.into());
|
||||||
|
}
|
||||||
|
let user = p[0];
|
||||||
|
let pass = p[1];
|
||||||
|
let mut h = Context::new();
|
||||||
|
h.consume(format!("{}:{}:{}", user, REALM, pass).as_bytes());
|
||||||
|
Ok((user.to_owned(), format!("{:x}", h.compute())))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn valid_digest(
|
||||||
|
header_value: &HeaderValue,
|
||||||
|
method: &str,
|
||||||
|
auth_user: &str,
|
||||||
|
auth_pass: &str,
|
||||||
|
) -> Option<()> {
|
||||||
|
let digest_value = strip_prefix(header_value.as_bytes(), b"Digest ")?;
|
||||||
|
let user_vals = to_headermap(digest_value).ok()?;
|
||||||
|
if let (Some(username), Some(nonce), Some(user_response)) = (
|
||||||
|
user_vals
|
||||||
|
.get(b"username".as_ref())
|
||||||
|
.and_then(|b| std::str::from_utf8(*b).ok()),
|
||||||
|
user_vals.get(b"nonce".as_ref()),
|
||||||
|
user_vals.get(b"response".as_ref()),
|
||||||
|
) {
|
||||||
|
match validate_nonce(nonce) {
|
||||||
|
Ok(true) => {}
|
||||||
|
_ => return None,
|
||||||
|
}
|
||||||
|
if auth_user != username {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let mut ha = Context::new();
|
||||||
|
ha.consume(method);
|
||||||
|
ha.consume(b":");
|
||||||
|
if let Some(uri) = user_vals.get(b"uri".as_ref()) {
|
||||||
|
ha.consume(uri);
|
||||||
|
}
|
||||||
|
let ha = format!("{:x}", ha.compute());
|
||||||
|
let mut correct_response = None;
|
||||||
|
if let Some(qop) = user_vals.get(b"qop".as_ref()) {
|
||||||
|
if qop == &b"auth".as_ref() || qop == &b"auth-int".as_ref() {
|
||||||
|
correct_response = Some({
|
||||||
|
let mut c = Context::new();
|
||||||
|
c.consume(&auth_pass);
|
||||||
|
c.consume(b":");
|
||||||
|
c.consume(nonce);
|
||||||
|
c.consume(b":");
|
||||||
|
if let Some(nc) = user_vals.get(b"nc".as_ref()) {
|
||||||
|
c.consume(nc);
|
||||||
|
}
|
||||||
|
c.consume(b":");
|
||||||
|
if let Some(cnonce) = user_vals.get(b"cnonce".as_ref()) {
|
||||||
|
c.consume(cnonce);
|
||||||
|
}
|
||||||
|
c.consume(b":");
|
||||||
|
c.consume(qop);
|
||||||
|
c.consume(b":");
|
||||||
|
c.consume(&*ha);
|
||||||
|
format!("{:x}", c.compute())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let correct_response = match correct_response {
|
||||||
|
Some(r) => r,
|
||||||
|
None => {
|
||||||
|
let mut c = Context::new();
|
||||||
|
c.consume(&auth_pass);
|
||||||
|
c.consume(b":");
|
||||||
|
c.consume(nonce);
|
||||||
|
c.consume(b":");
|
||||||
|
c.consume(&*ha);
|
||||||
|
format!("{:x}", c.compute())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if correct_response.as_bytes() == *user_response {
|
||||||
|
// grant access
|
||||||
|
return Some(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a nonce is still valid.
|
||||||
|
/// Return an error if it was never valid
|
||||||
|
fn validate_nonce(nonce: &[u8]) -> Result<bool, ()> {
|
||||||
|
if nonce.len() != 34 {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
//parse hex
|
||||||
|
if let Ok(n) = std::str::from_utf8(nonce) {
|
||||||
|
//get time
|
||||||
|
if let Ok(secs_nonce) = u32::from_str_radix(&n[..8], 16) {
|
||||||
|
//check time
|
||||||
|
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||||
|
let secs_now = now.as_secs() as u32;
|
||||||
|
|
||||||
|
if let Some(dur) = secs_now.checked_sub(secs_nonce) {
|
||||||
|
//check hash
|
||||||
|
let mut h = NONCESTARTHASH.clone();
|
||||||
|
h.consume(secs_nonce.to_be_bytes());
|
||||||
|
let h = format!("{:x}", h.compute());
|
||||||
|
if h[..26] == n[8..34] {
|
||||||
|
return Ok(dur < 300); // from the last 5min
|
||||||
|
//Authentication-Info ?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn strip_prefix<'a>(search: &'a [u8], prefix: &[u8]) -> Option<&'a [u8]> {
|
||||||
|
let l = prefix.len();
|
||||||
|
if search.len() < l {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if &search[..l] == prefix {
|
||||||
|
Some(&search[l..])
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_headermap(header: &[u8]) -> Result<HashMap<&[u8], &[u8]>, ()> {
|
||||||
|
let mut sep = Vec::new();
|
||||||
|
let mut asign = Vec::new();
|
||||||
|
let mut i: usize = 0;
|
||||||
|
let mut esc = false;
|
||||||
|
for c in header {
|
||||||
|
match (c, esc) {
|
||||||
|
(b'=', false) => asign.push(i),
|
||||||
|
(b',', false) => sep.push(i),
|
||||||
|
(b'"', false) => esc = true,
|
||||||
|
(b'"', true) => esc = false,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
sep.push(i); // same len for both Vecs
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
let mut ret = HashMap::new();
|
||||||
|
for (&k, &a) in sep.iter().zip(asign.iter()) {
|
||||||
|
while header[i] == b' ' {
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
if a <= i || k <= 1 + a {
|
||||||
|
//keys and vals must contain one char
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
let key = &header[i..a];
|
||||||
|
let val = if header[1 + a] == b'"' && header[k - 1] == b'"' {
|
||||||
|
//escaped
|
||||||
|
&header[2 + a..k - 1]
|
||||||
|
} else {
|
||||||
|
//not escaped
|
||||||
|
&header[1 + a..k]
|
||||||
|
};
|
||||||
|
i = 1 + k;
|
||||||
|
ret.insert(key, val);
|
||||||
|
}
|
||||||
|
Ok(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_nonce() -> String {
|
||||||
|
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||||
|
let secs = now.as_secs() as u32;
|
||||||
|
let mut h = NONCESTARTHASH.clone();
|
||||||
|
h.consume(secs.to_be_bytes());
|
||||||
|
|
||||||
|
let n = format!("{:08x}{:032x}", secs, h.compute());
|
||||||
|
n[..34].to_string()
|
||||||
|
}
|
||||||
210
src/index.html
210
src/index.html
@@ -1,210 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width" />
|
|
||||||
<title>Duf</title>
|
|
||||||
__STYLE__
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="head">
|
|
||||||
<div class="breadcrumb"></div>
|
|
||||||
</div>
|
|
||||||
<div class="main">
|
|
||||||
<div class="uploaders">
|
|
||||||
</div>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="cell-name">Name</th>
|
|
||||||
<th class="cell-mtime">Date modify</th>
|
|
||||||
<th class="cell-size">Size</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
const $head = document.querySelector(".head");
|
|
||||||
const $tbody = document.querySelector(".main tbody");
|
|
||||||
const $breadcrumb = document.querySelector(".breadcrumb");
|
|
||||||
const $uploaders = document.querySelector(".uploaders");
|
|
||||||
const $uploadControl = document.querySelector(".upload-control");
|
|
||||||
const { breadcrumb, paths, readonly } = __DATA__;
|
|
||||||
let uploaderIdx = 0;
|
|
||||||
|
|
||||||
class Uploader {
|
|
||||||
idx = 0;
|
|
||||||
file;
|
|
||||||
path;
|
|
||||||
$elem;
|
|
||||||
constructor(idx, file) {
|
|
||||||
this.idx = idx;
|
|
||||||
this.file = file;
|
|
||||||
this.path = location.pathname + "/" + file.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
upload() {
|
|
||||||
const { file, idx, path } = this;
|
|
||||||
$uploaders.insertAdjacentHTML("beforeend", `
|
|
||||||
<div class="uploader path">
|
|
||||||
<div><svg height="16" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg></div>
|
|
||||||
<a href="${path}" id="file${idx}">${file.name} (0%)</a>
|
|
||||||
</div>`);
|
|
||||||
this.$elem = document.getElementById(`file${idx}`);
|
|
||||||
|
|
||||||
const ajax = new XMLHttpRequest();
|
|
||||||
ajax.upload.addEventListener("progress", e => this.progress(e), false);
|
|
||||||
ajax.addEventListener("load", e => this.complete(e), false);
|
|
||||||
ajax.addEventListener("error", e => this.error(e), false);
|
|
||||||
ajax.addEventListener("abort", e => this.abort(e), false);
|
|
||||||
ajax.open("PUT", path);
|
|
||||||
ajax.send(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
progress(event) {
|
|
||||||
const percent = (event.loaded / event.total) * 100;
|
|
||||||
this.$elem.innerHTML = `${this.file.name} (${percent.toFixed(2)}%)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
complete(event) {
|
|
||||||
this.$elem.innerHTML = `${this.file.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
error(event) {
|
|
||||||
this.$elem.innerHTML = `${this.file.name} (x)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
abort(event) {
|
|
||||||
this.$elem.innerHTML = `${this.file.name} (x)`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addBreadcrumb(value) {
|
|
||||||
const parts = value.split("/").filter(v => !!v);
|
|
||||||
const len = parts.length;
|
|
||||||
let path = "";
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
const name = parts[i];
|
|
||||||
if (i > 0) {
|
|
||||||
path += "/" + name;
|
|
||||||
}
|
|
||||||
if (i === len - 1) {
|
|
||||||
$breadcrumb.insertAdjacentHTML("beforeend", `<b>${name}</b>`);
|
|
||||||
} else if (i === 0) {
|
|
||||||
$breadcrumb.insertAdjacentHTML("beforeend", `<a href="/"><b>${name}</b></a>`);
|
|
||||||
} else {
|
|
||||||
$breadcrumb.insertAdjacentHTML("beforeend", `<a href="${encodeURI(path)}">${name}</a>`);
|
|
||||||
}
|
|
||||||
$breadcrumb.insertAdjacentHTML("beforeend", `<span class="separator">/</span>`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addPath(file, index) {
|
|
||||||
const actionTd = readonly ? "" : `
|
|
||||||
<td class="cell-actions">
|
|
||||||
<div onclick="deletePath(${index})" class="delete-btn" id="deleteBtn${index}" title="Delete ${file.name}">
|
|
||||||
<svg width="18" height="18" viewBox="0 0 40 40"><path d="M28,40H11.8c-3.3,0-5.9-2.7-5.9-5.9V16c0-0.6,0.4-1,1-1s1,0.4,1,1v18.1c0,2.2,1.8,3.9,3.9,3.9H28c2.2,0,3.9-1.8,3.9-3.9V16 c0-0.6,0.4-1,1-1s1,0.4,1,1v18.1C33.9,37.3,31.2,40,28,40z"/></g><g><path d="M33.3,4.9h-7.6C25.2,2.1,22.8,0,19.9,0s-5.3,2.1-5.8,4.9H6.5c-2.3,0-4.1,1.8-4.1,4.1S4.2,13,6.5,13h26.9 c2.3,0,4.1-1.8,4.1-4.1S35.6,4.9,33.3,4.9z M19.9,2c1.8,0,3.3,1.2,3.7,2.9h-7.5C16.6,3.2,18.1,2,19.9,2z M33.3,11H6.5 c-1.1,0-2.1-0.9-2.1-2.1c0-1.1,0.9-2.1,2.1-2.1h26.9c1.1,0,2.1,0.9,2.1,2.1C35.4,10.1,34.5,11,33.3,11z"/></g><g><path d="M12.9,35.1c-0.6,0-1-0.4-1-1V17.4c0-0.6,0.4-1,1-1s1,0.4,1,1v16.7C13.9,34.6,13.4,35.1,12.9,35.1z"/></g><g><path d="M26.9,35.1c-0.6,0-1-0.4-1-1V17.4c0-0.6,0.4-1,1-1s1,0.4,1,1v16.7C27.9,34.6,27.4,35.1,26.9,35.1z"/></g><g><path d="M19.9,35.1c-0.6,0-1-0.4-1-1V17.4c0-0.6,0.4-1,1-1s1,0.4,1,1v16.7C20.9,34.6,20.4,35.1,19.9,35.1z"/></svg>
|
|
||||||
</div>
|
|
||||||
</td>`
|
|
||||||
|
|
||||||
$tbody.insertAdjacentHTML("beforeend", `
|
|
||||||
<tr id="addPath${index}">
|
|
||||||
<td class="path cell-name">
|
|
||||||
<div>${getSvg(file.path_type)}</div>
|
|
||||||
<a href="${encodeURI(file.path)}" title="${file.name}">${file.name}</a>
|
|
||||||
</td>
|
|
||||||
<td class="cell-mtime">${formatMtime(file.mtime)}</td>
|
|
||||||
<td class="cell-size">${formatSize(file.size)}</td>
|
|
||||||
${actionTd}
|
|
||||||
</tr>`)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function deletePath(index) {
|
|
||||||
const file = paths[index];
|
|
||||||
if (!file) return;
|
|
||||||
try {
|
|
||||||
const res = await fetch(encodeURI(file.path), {
|
|
||||||
method: "DELETE",
|
|
||||||
});
|
|
||||||
if (res.status !== 200) {
|
|
||||||
const text = await res.text();
|
|
||||||
throw new Error(text);
|
|
||||||
}
|
|
||||||
document.getElementById(`addPath${index}`).remove();
|
|
||||||
} catch (err) {
|
|
||||||
alert(`Failed to delete ${file.name}, ${err.message}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addUploadControl() {
|
|
||||||
$head.insertAdjacentHTML("beforeend", `
|
|
||||||
<div class="upload-control" title="Upload file">
|
|
||||||
<label for="file">
|
|
||||||
<svg viewBox="0 0 384.97 384.97" width="14" height="14"><path d="M372.939,264.641c-6.641,0-12.03,5.39-12.03,12.03v84.212H24.061v-84.212c0-6.641-5.39-12.03-12.03-12.03 S0,270.031,0,276.671v96.242c0,6.641,5.39,12.03,12.03,12.03h360.909c6.641,0,12.03-5.39,12.03-12.03v-96.242 C384.97,270.019,379.58,264.641,372.939,264.641z"></path><path d="M117.067,103.507l63.46-62.558v235.71c0,6.641,5.438,12.03,12.151,12.03c6.713,0,12.151-5.39,12.151-12.03V40.95 l63.46,62.558c4.74,4.704,12.439,4.704,17.179,0c4.74-4.704,4.752-12.319,0-17.011l-84.2-82.997 c-4.692-4.656-12.584-4.608-17.191,0L99.888,86.496c-4.752,4.704-4.74,12.319,0,17.011 C104.628,108.211,112.327,108.211,117.067,103.507z"></path></svg>
|
|
||||||
</label>
|
|
||||||
<input type="file" id="file" name="file" multiple>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSvg(path_type) {
|
|
||||||
switch (path_type) {
|
|
||||||
case "Dir":
|
|
||||||
return `<svg height="16" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM6 4H1V3h5v1z"></path></svg>`;
|
|
||||||
case "File":
|
|
||||||
return `<svg height="16" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>`;
|
|
||||||
case "SymlinkDir":
|
|
||||||
return `<svg height="16" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM1 3h5v1H1V3zm6 9v-2c-.98-.02-1.84.22-2.55.7-.71.48-1.19 1.25-1.45 2.3.02-1.64.39-2.88 1.13-3.73C4.86 8.43 5.82 8 7.01 8V6l4 3-4 3H7z"></path></svg>`;
|
|
||||||
default:
|
|
||||||
return `<svg height="16" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M8.5 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V4.5L8.5 1zM11 14H1V2h7l3 3v9zM6 4.5l4 3-4 3v-2c-.98-.02-1.84.22-2.55.7-.71.48-1.19 1.25-1.45 2.3.02-1.64.39-2.88 1.13-3.73.73-.84 1.69-1.27 2.88-1.27v-2H6z"></path></svg>`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatMtime(mtime) {
|
|
||||||
if (!mtime) return ""
|
|
||||||
const date = new Date(mtime);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const month = padZero(date.getMonth() + 1, 2);
|
|
||||||
const day = padZero(date.getDate(), 2);
|
|
||||||
const hours = padZero(date.getHours(), 2);
|
|
||||||
const minutes = padZero(date.getMinutes(), 2);
|
|
||||||
return `${year}/${month}/${day} ${hours}:${minutes}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function padZero(value, size) {
|
|
||||||
return ("0".repeat(size) + value).slice(-1 * size)
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatSize(size) {
|
|
||||||
if (!size) return ""
|
|
||||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
||||||
if (size == 0) return '0 Byte';
|
|
||||||
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
|
|
||||||
return Math.round(size / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
addBreadcrumb(breadcrumb);
|
|
||||||
paths.forEach((file, index) => addPath(file, index));
|
|
||||||
if (!readonly) {
|
|
||||||
addUploadControl();
|
|
||||||
document.querySelector(".main thead tr").insertAdjacentHTML("beforeend", `<th class="cell-actions">Actions</th>`);
|
|
||||||
document.getElementById("file").addEventListener("change", e => {
|
|
||||||
const files = e.target.files;
|
|
||||||
for (const file of files) {
|
|
||||||
uploaderIdx += 1;
|
|
||||||
const uploader = new Uploader(uploaderIdx, file);
|
|
||||||
uploader.upload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
33
src/main.rs
33
src/main.rs
@@ -1,10 +1,5 @@
|
|||||||
macro_rules! bail {
|
|
||||||
($($tt:tt)*) => {
|
|
||||||
return Err(From::from(format!($($tt)*)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod args;
|
mod args;
|
||||||
|
mod auth;
|
||||||
mod server;
|
mod server;
|
||||||
|
|
||||||
pub type BoxResult<T> = Result<T, Box<dyn std::error::Error>>;
|
pub type BoxResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||||
@@ -14,14 +9,28 @@ use crate::server::serve;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
Args::parse(matches())
|
run().await.unwrap_or_else(handle_err)
|
||||||
.map(serve)
|
}
|
||||||
.unwrap_or_else(handle_err)
|
|
||||||
.await
|
async fn run() -> BoxResult<()> {
|
||||||
.unwrap_or_else(handle_err);
|
let args = Args::parse(matches())?;
|
||||||
|
tokio::select! {
|
||||||
|
ret = serve(args) => {
|
||||||
|
ret
|
||||||
|
},
|
||||||
|
_ = shutdown_signal() => {
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_err<T>(err: Box<dyn std::error::Error>) -> T {
|
fn handle_err<T>(err: Box<dyn std::error::Error>) -> T {
|
||||||
eprintln!("Server error: {}", err);
|
eprintln!("error: {}", err);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn shutdown_signal() {
|
||||||
|
tokio::signal::ctrl_c()
|
||||||
|
.await
|
||||||
|
.expect("Failed to install CTRL+C signal handler")
|
||||||
|
}
|
||||||
|
|||||||
1026
src/server.rs
1026
src/server.rs
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user