version = "0.19.0"
edition = "2021"
authors = ["sigoden <sigoden@gmail.com>"]
-description = "Dufs is a simple file server."
+description = "Dufs is a distinctive utility file server"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/sigoden/dufs"
repository = "https://github.com/sigoden/dufs"
keywords = ["static", "file", "server", "webdav", "cli"]
[dependencies]
-clap = { version = "3", default-features = false, features = ["std"] }
+clap = { version = "3", default-features = false, features = ["std", "wrap_help"] }
chrono = "0.4"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "io-util", "signal"]}
tokio-rustls = "0.23"
[](https://github.com/sigoden/dufs/actions/workflows/ci.yaml)
[](https://crates.io/crates/dufs)
-Dufs is a simple file server. Support static serve, search, upload, webdav...
+Dufs is a distinctive utility file server that supports static serving, uploading, searching, accessing control, webdav...

## CLI
```
-Dufs is a simple file server. - https://github.com/sigoden/dufs
+Dufs is a distinctive utility file server - https://github.com/sigoden/dufs
USAGE:
dufs [OPTIONS] [--] [path]
ARGS:
- <path> Path to a root directory for serving files [default: .]
+ <path> Specific path to serve [default: .]
OPTIONS:
-b, --bind <addr>... Specify bind address
-p, --port <port> Specify port to listen on [default: 5000]
- --path-prefix <path> Specify an url path prefix
+ --path-prefix <path> Specify an path prefix
-a, --auth <rule>... Add auth for path
- --auth-method <value> Select auth method [default: digest] [possible values: basic,
- digest]
+ --auth-method <value> Select auth method [default: digest] [possible values: basic, digest]
-A, --allow-all Allow all operations
--allow-upload Allow upload files/folders
--allow-delete Allow delete files/folders
--allow-symlink Allow symlink to files/folders outside root directory
--enable-cors Enable CORS, sets `Access-Control-Allow-Origin: *`
- --render-index Render index.html when requesting a directory
- --render-try-index Render index.html if it exists when requesting a directory
- --render-spa Render for single-page application
+ --render-index Serve index.html when requesting a directory, returns 404 if not found index.html
+ --render-try-index Serve index.html when requesting a directory, returns file listing if not found index.html
+ --render-spa Serve SPA(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
-h, --help Print help information
## Examples
-Serve current working directory, no upload/delete
+Serve current working directory
```
dufs
```
-Allow upload/delete
+Explicitly allow all operations including upload/delete
```
dufs -A
```
-Listen on a specific port
+Only allow upload operation
```
-dufs -p 80
+dufs --allow-upload
+```
+
+Serve a directory
+
+```
+dufs Downloads
+```
+
+Serve a single file
+
+```
+dufs linux-distro.iso
```
-For a single page application (SPA)
+Serve index.html when requesting a directory
+
+```
+dufs --render-index
+```
+
+Serve SPA(Single Page Application)
```
dufs --render-spa
```
+Require username/password
+
+```
+dufs -a /@admin:123
+```
+
+Listen on a specific port
+
+```
+dufs -p 80
+```
+
Use https
```
curl -X DELETE http://127.0.0.1:5000/path-to-file
```
-## Details
-
-<details>
-<summary>
-
-#### 1. Control render logic
-
-</summary>
-
-
-The default render logic is:
-
-- If request for a folder, rendering the directory listing.
-- If request for a file, rendering the file.
-- If request target does not exist, returns 404.
+## Access Control
-The `--render-*` options change the render logic:
-
-- `--render-index`: If request for a folder, rendering index.html in the folder. If the index.html file does not exist, return 404.
-- `--render-try-index`: Like `--render-index`, rendering the directory listing if the index.html file does not exist, other than return 404.
-- `--render-spa`: If request target does not exist, rendering `/index.html`
-
-</details>
-
-<details>
-<summary>
-
-#### 2. Path level access control
-
-</summary>
+Dufs implements path level access control through http authentication.
```
dufs -a <path>@<readwrite>[@<readonly>]
- Account `admin:pass` can upload/delete/download any files/folders.
- Account `designer:pass1` can upload/delete/download any files/folders in the `ui` folder.
-Curl with digest auth:
-
-```
-curl --digest -u designer:pass1 http://127.0.0.1:5000/ui/path-to-file
-```
-
-</details>
-
## License
Copyright (c) 2022 dufs-developers.
Arg::new("path")
.default_value(".")
.allow_invalid_utf8(true)
- .help("Path to a root directory for serving files"),
+ .help("Specific path to serve"),
)
.arg(
Arg::new("path-prefix")
.long("path-prefix")
.value_name("path")
- .help("Specify an url path prefix"),
+ .help("Specify an path prefix"),
)
.arg(
Arg::new("auth")
.arg(
Arg::new("render-index")
.long("render-index")
- .help("Render index.html when requesting a directory"),
+ .help("Serve index.html when requesting a directory, returns 404 if not found index.html"),
)
.arg(
Arg::new("render-try-index")
.long("render-try-index")
- .help("Render index.html if it exists when requesting a directory"),
+ .help("Serve index.html when requesting a directory, returns file listing if not found index.html"),
)
.arg(
Arg::new("render-spa")
.long("render-spa")
- .help("Render for single-page application"),
+ .help("Serve SPA(Single Page Application)"),
)
.arg(
Arg::new("tls-cert")
app().get_matches()
}
-#[derive(Debug, Clone)]
+#[derive(Debug)]
pub struct Args {
pub addrs: Vec<IpAddr>,
pub port: u16,