mirror of
https://github.com/Tim-Paik/srv.git
synced 2024-10-13 00:29:43 +00:00
Compare commits
5 Commits
v0.8.0-bet
...
v1.0.0-rc.
Author | SHA1 | Date | |
---|---|---|---|
12993018ab | |||
d59a3fc4a5 | |||
8db0f82d08 | |||
e407395080 | |||
d6e64db5c7 |
36
.github/workflows/release.yml
vendored
36
.github/workflows/release.yml
vendored
@ -14,8 +14,14 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
upload-assets-linux:
|
upload-assets:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: taiki-e/upload-rust-binary-action@v1
|
- uses: taiki-e/upload-rust-binary-action@v1
|
||||||
@ -25,29 +31,3 @@ jobs:
|
|||||||
zip: windows
|
zip: windows
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
upload-assets-macos:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: taiki-e/upload-rust-binary-action@v1
|
|
||||||
with:
|
|
||||||
bin: web
|
|
||||||
tar: unix
|
|
||||||
zip: windows
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
upload-assets-windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- run: vcpkg integrate install
|
|
||||||
- run: vcpkg install openssl:x64-windows-static-md
|
|
||||||
- uses: taiki-e/upload-rust-binary-action@v1
|
|
||||||
with:
|
|
||||||
bin: web
|
|
||||||
tar: unix
|
|
||||||
zip: windows
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
183
Cargo.lock
generated
183
Cargo.lock
generated
@ -33,10 +33,11 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"http",
|
"http",
|
||||||
"log",
|
"log",
|
||||||
"openssl",
|
"rustls",
|
||||||
"tokio-openssl",
|
"tokio-rustls",
|
||||||
"trust-dns-proto",
|
"trust-dns-proto",
|
||||||
"trust-dns-resolver",
|
"trust-dns-resolver",
|
||||||
|
"webpki",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -72,7 +73,7 @@ dependencies = [
|
|||||||
"actix-threadpool",
|
"actix-threadpool",
|
||||||
"actix-tls",
|
"actix-tls",
|
||||||
"actix-utils",
|
"actix-utils",
|
||||||
"base64",
|
"base64 0.13.0",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"brotli2",
|
"brotli2",
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
@ -214,8 +215,10 @@ dependencies = [
|
|||||||
"actix-service",
|
"actix-service",
|
||||||
"actix-utils",
|
"actix-utils",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"openssl",
|
"rustls",
|
||||||
"tokio-openssl",
|
"tokio-rustls",
|
||||||
|
"webpki",
|
||||||
|
"webpki-roots",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -266,9 +269,9 @@ dependencies = [
|
|||||||
"fxhash",
|
"fxhash",
|
||||||
"log",
|
"log",
|
||||||
"mime",
|
"mime",
|
||||||
"openssl",
|
|
||||||
"pin-project 1.0.8",
|
"pin-project 1.0.8",
|
||||||
"regex",
|
"regex",
|
||||||
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
@ -296,7 +299,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "0c3b11a07a3df3f7970fd8bd38cc66998b5549f507c54cc64c6e843bc82d6358"
|
checksum = "0c3b11a07a3df3f7970fd8bd38cc66998b5549f507c54cc64c6e843bc82d6358"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"base64",
|
"base64 0.13.0",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -353,16 +356,16 @@ dependencies = [
|
|||||||
"actix-http",
|
"actix-http",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-service",
|
"actix-service",
|
||||||
"base64",
|
"base64 0.13.0",
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"log",
|
"log",
|
||||||
"mime",
|
"mime",
|
||||||
"openssl",
|
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
@ -374,6 +377,12 @@ version = "0.2.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
|
checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@ -730,21 +739,6 @@ version = "1.0.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "foreign-types"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
|
||||||
dependencies = [
|
|
||||||
"foreign-types-shared",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "foreign-types-shared"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@ -1086,6 +1080,15 @@ version = "0.4.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.53"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e4bf49d50e2961077d9c99f4b7997d770a1114f087c3c2e0069b36c13fc2979d"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "kernel32-sys"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -1307,33 +1310,6 @@ version = "0.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "openssl"
|
|
||||||
version = "0.10.36"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"foreign-types",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"openssl-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "openssl-sys"
|
|
||||||
version = "0.9.66"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
"pkg-config",
|
|
||||||
"vcpkg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_str_bytes"
|
name = "os_str_bytes"
|
||||||
version = "3.1.0"
|
version = "3.1.0"
|
||||||
@ -1481,12 +1457,6 @@ 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.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.10"
|
version = "0.2.10"
|
||||||
@ -1670,6 +1640,21 @@ dependencies = [
|
|||||||
"quick-error",
|
"quick-error",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[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]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
@ -1688,6 +1673,19 @@ dependencies = [
|
|||||||
"semver 0.11.0",
|
"semver 0.11.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls"
|
||||||
|
version = "0.18.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81"
|
||||||
|
dependencies = [
|
||||||
|
"base64 0.12.3",
|
||||||
|
"log",
|
||||||
|
"ring",
|
||||||
|
"sct",
|
||||||
|
"webpki",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
@ -1709,6 +1707,16 @@ 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 = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sct"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce"
|
||||||
|
dependencies = [
|
||||||
|
"ring",
|
||||||
|
"untrusted",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@ -1870,6 +1878,12 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"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 = "standback"
|
name = "standback"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@ -2119,13 +2133,15 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-openssl"
|
name = "tokio-rustls"
|
||||||
version = "0.4.0"
|
version = "0.14.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c4b08c5f4208e699ede3df2520aca2e82401b2de33f45e96696a074480be594"
|
checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"openssl",
|
"futures-core",
|
||||||
|
"rustls",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"webpki",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2325,6 +2341,12 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "untrusted"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.2.2"
|
version = "2.2.2"
|
||||||
@ -2369,12 +2391,6 @@ dependencies = [
|
|||||||
"v_escape",
|
"v_escape",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vcpkg"
|
|
||||||
version = "0.2.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vec_map"
|
name = "vec_map"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
@ -2472,7 +2488,7 @@ checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web"
|
name = "web"
|
||||||
version = "0.8.0-beta"
|
version = "1.0.0-rc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-http",
|
"actix-http",
|
||||||
@ -2484,14 +2500,43 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"openssl",
|
|
||||||
"regex",
|
"regex",
|
||||||
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2",
|
"sha2",
|
||||||
"tera",
|
"tera",
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.53"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "224b2f6b67919060055ef1a67807367c2066ed520c3862cc013d26cf893a783c"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "webpki"
|
||||||
|
version = "0.21.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea"
|
||||||
|
dependencies = [
|
||||||
|
"ring",
|
||||||
|
"untrusted",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "webpki-roots"
|
||||||
|
version = "0.20.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f"
|
||||||
|
dependencies = [
|
||||||
|
"webpki",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "widestring"
|
name = "widestring"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
|
@ -3,12 +3,12 @@ authors = ["Tim_Paik <timpaikc@outlook.com>"]
|
|||||||
description = "simple http server written in rust"
|
description = "simple http server written in rust"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "web"
|
name = "web"
|
||||||
version = "0.8.0-beta"
|
version = "1.0.0-rc"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-files = "0.5"
|
actix-files = "0.5"
|
||||||
actix-http = "2.2"
|
actix-http = "2.2"
|
||||||
actix-web = {version = "3.3", features = ["openssl"]}
|
actix-web = {version = "3.3", features = ["rustls"]}
|
||||||
actix-web-httpauth = "0.5"
|
actix-web-httpauth = "0.5"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
clap = {version = "3.0.0-beta.4", features = ["wrap_help", "color"]}
|
clap = {version = "3.0.0-beta.4", features = ["wrap_help", "color"]}
|
||||||
@ -16,8 +16,8 @@ env_logger = "0.9"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime_guess = "2"
|
mime_guess = "2"
|
||||||
openssl = {version = "0.10", features = ["v110"]}
|
|
||||||
regex = "1.5"
|
regex = "1.5"
|
||||||
|
rustls = "0.18"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
sha2 = "0.9"
|
sha2 = "0.9"
|
||||||
tera = "1"
|
tera = "1"
|
||||||
|
204
src/main.rs
204
src/main.rs
@ -14,7 +14,7 @@ use sha2::Digest;
|
|||||||
use std::{
|
use std::{
|
||||||
env::{set_var, var},
|
env::{set_var, var},
|
||||||
fs::read_dir,
|
fs::read_dir,
|
||||||
io::{Error, ErrorKind, Read, Write},
|
io::{BufReader, Error, ErrorKind, Read, Write},
|
||||||
net::IpAddr,
|
net::IpAddr,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
@ -437,9 +437,13 @@ async fn main() -> std::io::Result<()> {
|
|||||||
set_var("DOTFILES", matches.is_present("dotfiles").to_string());
|
set_var("DOTFILES", matches.is_present("dotfiles").to_string());
|
||||||
set_var("NOCACHE", matches.is_present("nocache").to_string());
|
set_var("NOCACHE", matches.is_present("nocache").to_string());
|
||||||
set_var("COMPRESS", matches.is_present("compress").to_string());
|
set_var("COMPRESS", matches.is_present("compress").to_string());
|
||||||
set_var("QUIET", matches.is_present("quiet").to_string());
|
|
||||||
set_var("QUIETALL", matches.is_present("quietall").to_string());
|
|
||||||
|
|
||||||
|
if matches.is_present("quiet") {
|
||||||
|
set_var("RUST_LOG", "info,actix_web::middleware::logger=off");
|
||||||
|
}
|
||||||
|
if matches.is_present("quietall") {
|
||||||
|
set_var("RUST_LOG", "off");
|
||||||
|
}
|
||||||
if matches.is_present("nocolor") {
|
if matches.is_present("nocolor") {
|
||||||
set_var("RUST_LOG_STYLE", "never");
|
set_var("RUST_LOG_STYLE", "never");
|
||||||
}
|
}
|
||||||
@ -492,7 +496,13 @@ async fn main() -> std::io::Result<()> {
|
|||||||
std::process::Command::new("explorer").arg(url).spawn().ok();
|
std::process::Command::new("explorer").arg(url).spawn().ok();
|
||||||
} else if cfg!(target_os = "macos") {
|
} else if cfg!(target_os = "macos") {
|
||||||
std::process::Command::new("open").arg(url).spawn().ok();
|
std::process::Command::new("open").arg(url).spawn().ok();
|
||||||
} else if cfg!(target_os = "linux") {
|
} else if cfg!(target_os = "linux")
|
||||||
|
|| cfg!(target_os = "android")
|
||||||
|
|| cfg!(target_os = "freebsd")
|
||||||
|
|| cfg!(target_os = "dragonfly")
|
||||||
|
|| cfg!(target_os = "openbsd")
|
||||||
|
|| cfg!(target_os = "netbsd")
|
||||||
|
{
|
||||||
std::process::Command::new("xdg-open").arg(url).spawn().ok();
|
std::process::Command::new("xdg-open").arg(url).spawn().ok();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -501,87 +511,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
open_in_browser(&url);
|
open_in_browser(&url);
|
||||||
}
|
}
|
||||||
|
|
||||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
|
|
||||||
.format(|buf, record| {
|
|
||||||
if var("QUIETALL").unwrap_or("false".to_string()) == "true" {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let data = record.args().to_string();
|
|
||||||
let mut style = buf.style();
|
|
||||||
let blue = style.set_color(Color::Rgb(52, 152, 219));
|
|
||||||
let mut style = buf.style();
|
|
||||||
let red = style.set_color(Color::Rgb(231, 76, 60));
|
|
||||||
let mut style = buf.style();
|
|
||||||
let green = style.set_color(Color::Rgb(76, 175, 80));
|
|
||||||
if record.target() == "actix_web::middleware::logger" {
|
|
||||||
if var("QUIET").unwrap_or("false".to_string()) == "true" {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let data: Vec<&str> = data.splitn(5, "^").collect();
|
|
||||||
let time = blue.value(
|
|
||||||
chrono::NaiveDateTime::from_str(data[0])
|
|
||||||
.unwrap()
|
|
||||||
.format("%Y/%m/%d %H:%M:%S")
|
|
||||||
.to_string(),
|
|
||||||
);
|
|
||||||
let ipaddr = blue.value(data[1]);
|
|
||||||
let status_code = data[2].parse().unwrap_or(500);
|
|
||||||
let status_code = if status_code < 400 {
|
|
||||||
green.value(status_code)
|
|
||||||
} else {
|
|
||||||
red.value(status_code)
|
|
||||||
};
|
|
||||||
let process_time: Vec<&str> = data[3].splitn(2, ".").collect();
|
|
||||||
let process_time = process_time[0].to_string() + "ms";
|
|
||||||
let process_time = blue.value(if process_time.len() == 3 {
|
|
||||||
" ".to_string() + &process_time
|
|
||||||
} else if process_time.len() == 4 {
|
|
||||||
" ".to_string() + &process_time
|
|
||||||
} else {
|
|
||||||
process_time
|
|
||||||
});
|
|
||||||
let content = blue.value(data[4]);
|
|
||||||
return writeln!(
|
|
||||||
buf,
|
|
||||||
"\r[{}] {} | {} | {} | {}",
|
|
||||||
time, ipaddr, status_code, process_time, content
|
|
||||||
);
|
|
||||||
// Add '\r' to remove the input ^C
|
|
||||||
} else if record.target() == "actix_server::builder" {
|
|
||||||
if data.starts_with("SIGINT received, exiting") {
|
|
||||||
return writeln!(buf, "\r{}", green.value("[INFO] SIGINT received, exiting"));
|
|
||||||
} else {
|
|
||||||
let data = data.replace("actix-web-service-", "");
|
|
||||||
let re1 = regex::Regex::new("Starting (.*) workers").unwrap();
|
|
||||||
if re1.is_match(&data) {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let re2 = regex::Regex::new("Starting \"(.*)\" service on (.*)").unwrap();
|
|
||||||
if re2.is_match(&data) {
|
|
||||||
let addr = re2
|
|
||||||
.captures(&data)
|
|
||||||
.unwrap()
|
|
||||||
.get(1)
|
|
||||||
.map_or("", |m| m.as_str());
|
|
||||||
let data = format!(
|
|
||||||
"[INFO] Serving {} on {}",
|
|
||||||
var("ROOT").unwrap_or(".".to_string()),
|
|
||||||
addr
|
|
||||||
);
|
|
||||||
return writeln!(buf, "\r{}", green.value(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if data.starts_with("[ERROR]") {
|
|
||||||
writeln!(buf, "\r{}", red.value(data))
|
|
||||||
} else {
|
|
||||||
writeln!(buf, "\r{}", green.value(data))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.init();
|
|
||||||
|
|
||||||
let addr = if let Some(matches) = matches.subcommand_matches("doc") {
|
let addr = if let Some(matches) = matches.subcommand_matches("doc") {
|
||||||
info!("[INFO] Generating document (may take a while)");
|
|
||||||
let mut cargo_toml = match std::fs::File::open("./Cargo.toml") {
|
let mut cargo_toml = match std::fs::File::open("./Cargo.toml") {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -605,6 +535,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let crate_name = contents.package.name;
|
let crate_name = contents.package.name;
|
||||||
|
info!("[INFO] Generating document (may take a while)");
|
||||||
match std::process::Command::new("cargo").arg("doc").output() {
|
match std::process::Command::new("cargo").arg("doc").output() {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
let output = std::str::from_utf8(&output.stderr).unwrap_or("");
|
let output = std::str::from_utf8(&output.stderr).unwrap_or("");
|
||||||
@ -651,17 +582,97 @@ async fn main() -> std::io::Result<()> {
|
|||||||
open_in_browser(&url);
|
open_in_browser(&url);
|
||||||
}
|
}
|
||||||
if !matches.is_present("log") {
|
if !matches.is_present("log") {
|
||||||
set_var("QUIET", true.to_string());
|
set_var("RUST_LOG", "info,actix_web::middleware::logger=off");
|
||||||
|
}
|
||||||
|
if matches.is_present("quietall") {
|
||||||
|
set_var("RUST_LOG", "off");
|
||||||
}
|
}
|
||||||
if matches.is_present("nocolor") {
|
if matches.is_present("nocolor") {
|
||||||
set_var("RUST_LOG_STYLE", "never");
|
set_var("RUST_LOG_STYLE", "never");
|
||||||
}
|
}
|
||||||
set_var("QUIETALL", matches.is_present("quietall").to_string());
|
|
||||||
addr
|
addr
|
||||||
} else {
|
} else {
|
||||||
addr
|
addr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
env_logger::Builder::from_env(
|
||||||
|
env_logger::Env::default().default_filter_or("info"),
|
||||||
|
)
|
||||||
|
.format(|buf, record| {
|
||||||
|
let data = record.args().to_string();
|
||||||
|
let mut style = buf.style();
|
||||||
|
let blue = style.set_color(Color::Rgb(52, 152, 219));
|
||||||
|
let mut style = buf.style();
|
||||||
|
let red = style.set_color(Color::Rgb(231, 76, 60));
|
||||||
|
let mut style = buf.style();
|
||||||
|
let green = style.set_color(Color::Rgb(76, 175, 80));
|
||||||
|
if record.target() == "actix_web::middleware::logger" {
|
||||||
|
let data: Vec<&str> = data.splitn(5, "^").collect();
|
||||||
|
let time = blue.value(
|
||||||
|
chrono::NaiveDateTime::from_str(data[0])
|
||||||
|
.unwrap()
|
||||||
|
.format("%Y/%m/%d %H:%M:%S")
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
let ipaddr = blue.value(data[1]);
|
||||||
|
let status_code = data[2].parse().unwrap_or(500);
|
||||||
|
let status_code = if status_code < 400 {
|
||||||
|
green.value(status_code)
|
||||||
|
} else {
|
||||||
|
red.value(status_code)
|
||||||
|
};
|
||||||
|
let process_time: Vec<&str> = data[3].splitn(2, ".").collect();
|
||||||
|
let process_time = process_time[0].to_string() + "ms";
|
||||||
|
let process_time = blue.value(if process_time.len() == 3 {
|
||||||
|
" ".to_string() + &process_time
|
||||||
|
} else if process_time.len() == 4 {
|
||||||
|
" ".to_string() + &process_time
|
||||||
|
} else {
|
||||||
|
process_time
|
||||||
|
});
|
||||||
|
let content = blue.value(data[4]);
|
||||||
|
return writeln!(
|
||||||
|
buf,
|
||||||
|
"[{}] {} | {} | {} | {}",
|
||||||
|
time, ipaddr, status_code, process_time, content
|
||||||
|
);
|
||||||
|
} else if record.target() == "actix_server::builder" {
|
||||||
|
if data.starts_with("SIGINT received, exiting") {
|
||||||
|
return writeln!(buf, "\r{}", green.value("[INFO] SIGINT received, exiting"));
|
||||||
|
// Add '\r' to remove the input ^C
|
||||||
|
} else {
|
||||||
|
let data = data.replace("actix-web-service-", "");
|
||||||
|
let re1 = regex::Regex::new("Starting (.*) workers").unwrap();
|
||||||
|
if re1.is_match(&data) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let re2 = regex::Regex::new("Starting \"(.*)\" service on (.*)").unwrap();
|
||||||
|
if re2.is_match(&data) {
|
||||||
|
let addr = re2
|
||||||
|
.captures(&data)
|
||||||
|
.unwrap()
|
||||||
|
.get(1)
|
||||||
|
.map_or("", |m| m.as_str());
|
||||||
|
let data = format!(
|
||||||
|
"[INFO] Serving {} on {}",
|
||||||
|
var("ROOT").unwrap_or(".".to_string()),
|
||||||
|
addr
|
||||||
|
);
|
||||||
|
return writeln!(buf, "\r{}", green.value(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if data.starts_with("[ERROR]")
|
||||||
|
|| data.starts_with("TLS alert")
|
||||||
|
|| data.starts_with("Failed")
|
||||||
|
{
|
||||||
|
writeln!(buf, "\r{}", red.value(data))
|
||||||
|
} else {
|
||||||
|
writeln!(buf, "\r{}", green.value(data))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.init();
|
||||||
|
|
||||||
let server = HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
let compress = if var("COMPRESS").unwrap_or("false".to_string()) == "true" {
|
let compress = if var("COMPRESS").unwrap_or("false".to_string()) == "true" {
|
||||||
http::header::ContentEncoding::Auto
|
http::header::ContentEncoding::Auto
|
||||||
@ -737,16 +748,17 @@ async fn main() -> std::io::Result<()> {
|
|||||||
return app.service(files);
|
return app.service(files);
|
||||||
});
|
});
|
||||||
let server = if enable_tls {
|
let server = if enable_tls {
|
||||||
let cert = Path::new(matches.value_of("cert").unwrap());
|
let cert = &mut BufReader::new(
|
||||||
let key = Path::new(matches.value_of("key").unwrap());
|
std::fs::File::open(Path::new(matches.value_of("cert").unwrap())).unwrap(),
|
||||||
let mut builder =
|
);
|
||||||
openssl::ssl::SslAcceptor::mozilla_intermediate(openssl::ssl::SslMethod::tls())
|
let key = &mut BufReader::new(
|
||||||
.unwrap();
|
std::fs::File::open(Path::new(matches.value_of("key").unwrap())).unwrap(),
|
||||||
builder
|
);
|
||||||
.set_private_key_file(key, openssl::ssl::SslFiletype::PEM)
|
let mut config = rustls::ServerConfig::new(rustls::NoClientAuth::new());
|
||||||
.unwrap();
|
let cert_chain = rustls::internal::pemfile::certs(cert).unwrap();
|
||||||
builder.set_certificate_chain_file(cert).unwrap();
|
let mut keys = rustls::internal::pemfile::pkcs8_private_keys(key).unwrap();
|
||||||
server.bind_openssl(addr, builder)
|
config.set_single_cert(cert_chain, keys.remove(0)).unwrap();
|
||||||
|
server.bind_rustls(addr, config)
|
||||||
} else {
|
} else {
|
||||||
server.bind(addr)
|
server.bind(addr)
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#header,
|
#header,
|
||||||
#meta,
|
#meta,
|
||||||
#listing {
|
#listing {
|
||||||
|
font-family: sans-serif;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
@ -131,22 +132,37 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
html {
|
|
||||||
color: #444444;
|
html,
|
||||||
filter: invert(1);
|
body,
|
||||||
|
#header,
|
||||||
|
#meta,
|
||||||
|
#listing {
|
||||||
|
color: #cacaca;
|
||||||
|
background: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#listing a span {
|
#header nav span a {
|
||||||
filter: invert(1);
|
color: #cacaca;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header {
|
||||||
|
padding: 1.5rem 5% 1rem;
|
||||||
|
background-color: #0e0e0e;
|
||||||
|
}
|
||||||
|
|
||||||
|
#listing table {
|
||||||
|
border-top: 1px dashed #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#listing th,
|
||||||
|
#listing td {
|
||||||
|
border-bottom: 1px dashed #999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
#listing .goup svg,
|
#listing .goup svg,
|
||||||
#listing .file svg {
|
#listing .file svg {
|
||||||
fill: #444444;
|
fill: #cacaca;
|
||||||
}
|
|
||||||
|
|
||||||
#listing .dir svg {
|
|
||||||
filter: invert(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#header a,
|
#header a,
|
||||||
|
Reference in New Issue
Block a user