mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
add proxy option
This commit is contained in:
parent
0843863a40
commit
6239b0cab7
9 changed files with 742 additions and 29 deletions
481
Cargo.lock
generated
481
Cargo.lock
generated
|
|
@ -81,6 +81,24 @@ 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.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-buffer"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bollard"
|
name = "bollard"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
|
@ -104,7 +122,7 @@ dependencies = [
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util 0.7.3",
|
||||||
"url",
|
"url",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
@ -130,12 +148,28 @@ dependencies = [
|
||||||
"regex-automata",
|
"regex-automata",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "buf_redux"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"safemem",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.10.0"
|
version = "3.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
|
@ -174,6 +208,15 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpufeatures"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
|
|
@ -183,6 +226,16 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crypto-common"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
"typenum",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling"
|
name = "darling"
|
||||||
version = "0.13.4"
|
version = "0.13.4"
|
||||||
|
|
@ -218,6 +271,25 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "digest"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "digest"
|
||||||
|
version = "0.10.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer 0.10.2",
|
||||||
|
"crypto-common",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "directories-next"
|
name = "directories-next"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
|
|
@ -266,6 +338,15 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
|
||||||
|
dependencies = [
|
||||||
|
"instant",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
|
|
@ -311,6 +392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
|
checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -350,12 +432,23 @@ checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-macro",
|
"futures-macro",
|
||||||
|
"futures-sink",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generic-array"
|
||||||
|
version = "0.14.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
|
||||||
|
dependencies = [
|
||||||
|
"typenum",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
|
@ -388,7 +481,7 @@ dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"slab",
|
"slab",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util 0.7.3",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -420,7 +513,35 @@ dependencies = [
|
||||||
"tar",
|
"tar",
|
||||||
"termion",
|
"termion",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tokio-stream",
|
||||||
"toml",
|
"toml",
|
||||||
|
"warp",
|
||||||
|
"warp-reverse-proxy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 0.10.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "headers-core"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
|
||||||
|
dependencies = [
|
||||||
|
"http",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -505,6 +626,19 @@ dependencies = [
|
||||||
"want",
|
"want",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper-rustls"
|
||||||
|
version = "0.23.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac"
|
||||||
|
dependencies = [
|
||||||
|
"http",
|
||||||
|
"hyper",
|
||||||
|
"rustls",
|
||||||
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyperlocal"
|
name = "hyperlocal"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
|
@ -545,6 +679,15 @@ dependencies = [
|
||||||
"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 = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
|
@ -657,6 +800,16 @@ version = "0.3.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
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]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
|
|
@ -678,6 +831,24 @@ dependencies = [
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "multipart"
|
||||||
|
version = "0.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "00dec633863867f29cb39df64a397cdf4a6354708ddd7759f70c7fb51c5f9182"
|
||||||
|
dependencies = [
|
||||||
|
"buf_redux",
|
||||||
|
"httparse",
|
||||||
|
"log",
|
||||||
|
"mime",
|
||||||
|
"mime_guess",
|
||||||
|
"quick-error",
|
||||||
|
"rand",
|
||||||
|
"safemem",
|
||||||
|
"tempfile",
|
||||||
|
"twoway",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_cpus"
|
name = "num_cpus"
|
||||||
version = "1.13.1"
|
version = "1.13.1"
|
||||||
|
|
@ -709,6 +880,12 @@ version = "1.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
|
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "opaque-debug"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "opener"
|
name = "opener"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
@ -839,6 +1016,12 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-error"
|
||||||
|
version = "1.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
|
|
@ -930,6 +1113,15 @@ version = "0.6.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "remove_dir_all"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.11.11"
|
version = "0.11.11"
|
||||||
|
|
@ -945,6 +1137,7 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
"hyper",
|
"hyper",
|
||||||
|
"hyper-rustls",
|
||||||
"ipnet",
|
"ipnet",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|
@ -952,30 +1145,92 @@ dependencies = [
|
||||||
"mime",
|
"mime",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"rustls",
|
||||||
|
"rustls-pemfile",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
"webpki-roots",
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[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",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.21"
|
version = "0.1.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||||
|
|
||||||
|
[[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.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55"
|
||||||
|
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 = "safemem"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scoped-tls"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||||
|
|
||||||
|
[[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.142"
|
version = "1.0.142"
|
||||||
|
|
@ -1041,12 +1296,45 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sha-1"
|
||||||
|
version = "0.9.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer 0.9.0",
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures",
|
||||||
|
"digest 0.9.0",
|
||||||
|
"opaque-debug",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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 0.10.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shell-words"
|
name = "shell-words"
|
||||||
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 = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
||||||
|
|
||||||
|
[[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.7"
|
version = "0.4.7"
|
||||||
|
|
@ -1072,6 +1360,12 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spin"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
|
@ -1175,6 +1469,20 @@ dependencies = [
|
||||||
"xattr",
|
"xattr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"fastrand",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"remove_dir_all",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "terminal_size"
|
name = "terminal_size"
|
||||||
version = "0.1.17"
|
version = "0.1.17"
|
||||||
|
|
@ -1266,6 +1574,7 @@ 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",
|
||||||
|
|
@ -1282,6 +1591,55 @@ 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.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-tungstenite"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8"
|
||||||
|
dependencies = [
|
||||||
|
"futures-util",
|
||||||
|
"log",
|
||||||
|
"pin-project",
|
||||||
|
"tokio",
|
||||||
|
"tungstenite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-util"
|
||||||
|
version = "0.6.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
"log",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-util"
|
name = "tokio-util"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
|
|
@ -1318,6 +1676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"
|
checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"log",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
]
|
]
|
||||||
|
|
@ -1337,6 +1696,49 @@ 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 = "tungstenite"
|
||||||
|
version = "0.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
"byteorder",
|
||||||
|
"bytes",
|
||||||
|
"http",
|
||||||
|
"httparse",
|
||||||
|
"log",
|
||||||
|
"rand",
|
||||||
|
"sha-1 0.9.8",
|
||||||
|
"thiserror",
|
||||||
|
"url",
|
||||||
|
"utf-8",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "twoway"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[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-bidi"
|
name = "unicode-bidi"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
|
|
@ -1379,6 +1781,12 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||||
|
|
||||||
|
[[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"
|
||||||
|
|
@ -1391,6 +1799,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf-8"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
|
@ -1407,6 +1821,50 @@ dependencies = [
|
||||||
"try-lock",
|
"try-lock",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "warp"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3cef4e1e9114a4b7f1ac799f16ce71c14de5778500c5450ec6b7b920c55b587e"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-util",
|
||||||
|
"headers",
|
||||||
|
"http",
|
||||||
|
"hyper",
|
||||||
|
"log",
|
||||||
|
"mime",
|
||||||
|
"mime_guess",
|
||||||
|
"multipart",
|
||||||
|
"percent-encoding",
|
||||||
|
"pin-project",
|
||||||
|
"scoped-tls",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"serde_urlencoded",
|
||||||
|
"tokio",
|
||||||
|
"tokio-stream",
|
||||||
|
"tokio-tungstenite",
|
||||||
|
"tokio-util 0.6.10",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "warp-reverse-proxy"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "21bb86f4c86d0fb386acf34fa5360ea0e8a082835e05296da2286c38a3316283"
|
||||||
|
dependencies = [
|
||||||
|
"hyper",
|
||||||
|
"once_cell",
|
||||||
|
"reqwest",
|
||||||
|
"thiserror",
|
||||||
|
"unicase",
|
||||||
|
"warp",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
|
@ -1489,6 +1947,25 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"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 = "webpki-roots"
|
||||||
|
version = "0.22.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1c760f0d366a6c24a02ed7816e23e691f5d92291f94d15e836006fd11b04daf"
|
||||||
|
dependencies = [
|
||||||
|
"webpki",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ description = "Easy setup and management of Nextcloud test instances using docke
|
||||||
bollard = "0.13.0"
|
bollard = "0.13.0"
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
camino = { version = "1.0.9", features = ["serde1"] }
|
camino = { version = "1.0.9", features = ["serde1"] }
|
||||||
tokio = { version = "1.20.1", features = ["fs", "macros"] }
|
tokio = { version = "1.20.1", features = ["fs", "macros", "signal"] }
|
||||||
parse-display = "0.5.5"
|
parse-display = "0.5.5"
|
||||||
futures-util = "0.3.21"
|
futures-util = "0.3.21"
|
||||||
termion = "1.5.6"
|
termion = "1.5.6"
|
||||||
|
|
@ -27,6 +27,9 @@ async-trait = "0.1.57"
|
||||||
enum_dispatch = "0.3.8"
|
enum_dispatch = "0.3.8"
|
||||||
miette = { version = "5.2.0", features = ["fancy"] }
|
miette = { version = "5.2.0", features = ["fancy"] }
|
||||||
shell-words = "1.1.0"
|
shell-words = "1.1.0"
|
||||||
|
warp = "0.3"
|
||||||
|
warp-reverse-proxy = { version = "0.5.0", default_features = false, features = ["rustls-tls"] }
|
||||||
|
tokio-stream = { version = "0.1.9", features = ["net"] }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|
|
||||||
41
flake.nix
41
flake.nix
|
|
@ -52,6 +52,10 @@
|
||||||
server_id_path = cfg.blackfire.serverIdPath;
|
server_id_path = cfg.blackfire.serverIdPath;
|
||||||
server_token_path = cfg.blackfire.serverTokenPath;
|
server_token_path = cfg.blackfire.serverTokenPath;
|
||||||
};
|
};
|
||||||
|
}) // (if (cfg.proxy == null) then {} else {
|
||||||
|
proxy = {
|
||||||
|
inherit (cfg.proxy) listen https address;
|
||||||
|
};
|
||||||
}));
|
}));
|
||||||
pkg = self.defaultPackage.${pkgs.system};
|
pkg = self.defaultPackage.${pkgs.system};
|
||||||
in {
|
in {
|
||||||
|
|
@ -131,11 +135,48 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
proxy = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = types.nullOr (types.submodule {
|
||||||
|
options = {
|
||||||
|
listen = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Listen address or socket path to listen to";
|
||||||
|
};
|
||||||
|
address = mkOption {
|
||||||
|
default = "";
|
||||||
|
type = types.str;
|
||||||
|
description = "Base address served by a reverse proxy to the haze proxy, instaces will be servered on subdomain of this address";
|
||||||
|
};
|
||||||
|
https = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = "Whether the reverse proxy accepts https connections";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
xdg.configFile."haze/haze.toml".source = configFile;
|
xdg.configFile."haze/haze.toml".source = configFile;
|
||||||
home.packages = [pkg];
|
home.packages = [pkg];
|
||||||
|
|
||||||
|
systemd.user.services.haze = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Haze reverse proxy";
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
ExecStart = "${pkg}/bin/haze proxy";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 10;
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = optional (cfg.proxy.listen != "") "default.target";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ pub enum HazeArgs {
|
||||||
Unpin {
|
Unpin {
|
||||||
filter: Option<String>,
|
filter: Option<String>,
|
||||||
},
|
},
|
||||||
|
Proxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
|
|
@ -210,6 +211,7 @@ impl HazeArgs {
|
||||||
}
|
}
|
||||||
HazeCommand::Pin => Ok(HazeArgs::Pin { filter }),
|
HazeCommand::Pin => Ok(HazeArgs::Pin { filter }),
|
||||||
HazeCommand::Unpin => Ok(HazeArgs::Unpin { filter }),
|
HazeCommand::Unpin => Ok(HazeArgs::Unpin { filter }),
|
||||||
|
HazeCommand::Proxy => Ok(HazeArgs::Proxy),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -231,6 +233,7 @@ pub enum HazeCommand {
|
||||||
Shell,
|
Shell,
|
||||||
Pin,
|
Pin,
|
||||||
Unpin,
|
Unpin,
|
||||||
|
Proxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for HazeCommand {
|
impl FromStr for HazeCommand {
|
||||||
|
|
@ -254,6 +257,7 @@ impl FromStr for HazeCommand {
|
||||||
"shell" => Ok(HazeCommand::Shell),
|
"shell" => Ok(HazeCommand::Shell),
|
||||||
"pin" => Ok(HazeCommand::Pin),
|
"pin" => Ok(HazeCommand::Pin),
|
||||||
"unpin" => Ok(HazeCommand::Unpin),
|
"unpin" => Ok(HazeCommand::Unpin),
|
||||||
|
"proxy" => Ok(HazeCommand::Proxy),
|
||||||
_ => Err(Report::msg(format!("Unknown command: {}", s))),
|
_ => Err(Report::msg(format!("Unknown command: {}", s))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +281,7 @@ impl HazeCommand {
|
||||||
HazeCommand::Shell => false,
|
HazeCommand::Shell => false,
|
||||||
HazeCommand::Pin => true,
|
HazeCommand::Pin => true,
|
||||||
HazeCommand::Unpin => true,
|
HazeCommand::Unpin => true,
|
||||||
|
HazeCommand::Proxy => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
32
src/cloud.rs
32
src/cloud.rs
|
|
@ -158,6 +158,7 @@ pub struct Cloud {
|
||||||
pub workdir: Utf8PathBuf,
|
pub workdir: Utf8PathBuf,
|
||||||
pub services: Vec<Service>,
|
pub services: Vec<Service>,
|
||||||
pub pinned: bool,
|
pub pinned: bool,
|
||||||
|
pub address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cloud {
|
impl Cloud {
|
||||||
|
|
@ -373,6 +374,14 @@ impl Cloud {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let clean_id = id.strip_prefix("haze-").unwrap_or(&id);
|
||||||
|
|
||||||
|
let address = match (&config.proxy.address, config.proxy.https) {
|
||||||
|
(public, true) if !public.is_empty() => format!("https://{clean_id}.{public}"),
|
||||||
|
(public, false) if !public.is_empty() => format!("http://{clean_id}.{public}"),
|
||||||
|
_ => format!("http://{ip}"),
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Cloud {
|
Ok(Cloud {
|
||||||
id,
|
id,
|
||||||
network,
|
network,
|
||||||
|
|
@ -383,6 +392,7 @@ impl Cloud {
|
||||||
workdir,
|
workdir,
|
||||||
services: options.services,
|
services: options.services,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
|
address,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -451,7 +461,7 @@ impl Cloud {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list(
|
pub async fn list(
|
||||||
docker: &mut Docker,
|
docker: &Docker,
|
||||||
filter: Option<String>,
|
filter: Option<String>,
|
||||||
config: &HazeConfig,
|
config: &HazeConfig,
|
||||||
) -> Result<Vec<Cloud>> {
|
) -> Result<Vec<Cloud>> {
|
||||||
|
|
@ -514,6 +524,21 @@ impl Cloud {
|
||||||
% 2)
|
% 2)
|
||||||
== 1;
|
== 1;
|
||||||
|
|
||||||
|
let ip = network_info.ip_address.as_ref()?.parse().ok();
|
||||||
|
|
||||||
|
let clean_id = id.strip_prefix("haze-").unwrap_or(&id);
|
||||||
|
|
||||||
|
let address = match (&config.proxy.address, config.proxy.https, ip) {
|
||||||
|
(public, true, Some(_)) if !public.is_empty() => {
|
||||||
|
format!("https://{clean_id}.{public}")
|
||||||
|
}
|
||||||
|
(public, false, Some(_)) if !public.is_empty() => {
|
||||||
|
format!("http://{clean_id}.{public}")
|
||||||
|
}
|
||||||
|
(_, _, Some(ip)) => format!("http://{ip}"),
|
||||||
|
_ => "Not running".into(),
|
||||||
|
};
|
||||||
|
|
||||||
service_ids.push(id.clone());
|
service_ids.push(id.clone());
|
||||||
Some((
|
Some((
|
||||||
cloud.created.unwrap_or_default(),
|
cloud.created.unwrap_or_default(),
|
||||||
|
|
@ -523,10 +548,11 @@ impl Cloud {
|
||||||
db,
|
db,
|
||||||
php,
|
php,
|
||||||
containers: service_ids,
|
containers: service_ids,
|
||||||
ip: network_info.ip_address.as_ref()?.parse().ok(),
|
ip,
|
||||||
workdir,
|
workdir,
|
||||||
services: found_services,
|
services: found_services,
|
||||||
pinned,
|
pinned,
|
||||||
|
address,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
@ -541,7 +567,7 @@ impl Cloud {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_by_filter(
|
pub async fn get_by_filter(
|
||||||
docker: &mut Docker,
|
docker: &Docker,
|
||||||
filter: Option<String>,
|
filter: Option<String>,
|
||||||
config: &HazeConfig,
|
config: &HazeConfig,
|
||||||
) -> Result<Cloud> {
|
) -> Result<Cloud> {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ pub struct HazeConfig {
|
||||||
pub auto_setup: HazeAutoSetupConfig,
|
pub auto_setup: HazeAutoSetupConfig,
|
||||||
pub volume: Vec<HazeVolumeConfig>,
|
pub volume: Vec<HazeVolumeConfig>,
|
||||||
pub blackfire: Option<HazeBlackfireConfig>,
|
pub blackfire: Option<HazeBlackfireConfig>,
|
||||||
|
pub proxy: ProxyConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
@ -27,6 +28,8 @@ pub struct RawHazeConfig {
|
||||||
pub volume: Vec<HazeVolumeConfig>,
|
pub volume: Vec<HazeVolumeConfig>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub blackfire: Option<HazeBlackfireConfig>,
|
pub blackfire: Option<HazeBlackfireConfig>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub proxy: ProxyConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RawHazeConfig> for HazeConfig {
|
impl From<RawHazeConfig> for HazeConfig {
|
||||||
|
|
@ -46,6 +49,7 @@ impl From<RawHazeConfig> for HazeConfig {
|
||||||
auto_setup: raw.auto_setup,
|
auto_setup: raw.auto_setup,
|
||||||
volume: raw.volume,
|
volume: raw.volume,
|
||||||
blackfire: raw.blackfire,
|
blackfire: raw.blackfire,
|
||||||
|
proxy: raw.proxy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +151,15 @@ fn load_secret(name: &str, path: Option<String>, raw: Option<String>) -> Result<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Deserialize, Debug)]
|
||||||
|
pub struct ProxyConfig {
|
||||||
|
pub listen: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub address: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub https: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl HazeConfig {
|
impl HazeConfig {
|
||||||
pub fn load() -> Result<Self> {
|
pub fn load() -> Result<Self> {
|
||||||
let dirs = ProjectDirs::from("nl", "icewind", "haze").unwrap();
|
let dirs = ProjectDirs::from("nl", "icewind", "haze").unwrap();
|
||||||
|
|
|
||||||
39
src/main.rs
39
src/main.rs
|
|
@ -4,6 +4,7 @@ use crate::config::HazeConfig;
|
||||||
use crate::exec::container_logs;
|
use crate::exec::container_logs;
|
||||||
use crate::network::clear_networks;
|
use crate::network::clear_networks;
|
||||||
use crate::php::PhpVersion;
|
use crate::php::PhpVersion;
|
||||||
|
use crate::proxy::proxy;
|
||||||
use crate::service::Service;
|
use crate::service::Service;
|
||||||
use crate::service::ServiceTrait;
|
use crate::service::ServiceTrait;
|
||||||
use bollard::Docker;
|
use bollard::Docker;
|
||||||
|
|
@ -19,6 +20,7 @@ mod image;
|
||||||
mod mapping;
|
mod mapping;
|
||||||
mod network;
|
mod network;
|
||||||
mod php;
|
mod php;
|
||||||
|
mod proxy;
|
||||||
mod service;
|
mod service;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
@ -49,23 +51,14 @@ async fn main() -> Result<()> {
|
||||||
services.push(cloud.db.name());
|
services.push(cloud.db.name());
|
||||||
let services = services.join(", ");
|
let services = services.join(", ");
|
||||||
let pin = if cloud.pinned { "*" } else { "" };
|
let pin = if cloud.pinned { "*" } else { "" };
|
||||||
match cloud.ip {
|
println!(
|
||||||
Some(ip) => println!(
|
"Cloud {}{}, {}, {}, running on {}",
|
||||||
"Cloud {}{}, {}, {}, running on http://{}",
|
cloud.id,
|
||||||
cloud.id,
|
pin,
|
||||||
pin,
|
cloud.php.name(),
|
||||||
cloud.php.name(),
|
services,
|
||||||
services,
|
cloud.address
|
||||||
ip
|
);
|
||||||
),
|
|
||||||
None => println!(
|
|
||||||
"Cloud {}{}, {}, {}, not running",
|
|
||||||
cloud.id,
|
|
||||||
pin,
|
|
||||||
cloud.php.name(),
|
|
||||||
services
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HazeArgs::Start { options } => {
|
HazeArgs::Start { options } => {
|
||||||
|
|
@ -294,6 +287,9 @@ async fn main() -> Result<()> {
|
||||||
let cloud = Cloud::get_by_filter(&mut docker, filter, &config).await?;
|
let cloud = Cloud::get_by_filter(&mut docker, filter, &config).await?;
|
||||||
cloud.unpin(&mut docker).await?;
|
cloud.unpin(&mut docker).await?;
|
||||||
}
|
}
|
||||||
|
HazeArgs::Proxy => {
|
||||||
|
proxy(docker, config).await?;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -301,7 +297,8 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
async fn setup(docker: &mut Docker, options: CloudOptions, config: &HazeConfig) -> Result<Cloud> {
|
async fn setup(docker: &mut Docker, options: CloudOptions, config: &HazeConfig) -> Result<Cloud> {
|
||||||
let cloud = Cloud::create(docker, options, &config).await?;
|
let cloud = Cloud::create(docker, options, &config).await?;
|
||||||
println!("http://{}", cloud.ip.unwrap());
|
println!("{}", cloud.address);
|
||||||
|
let host = cloud.address.split_once("://").expect("no address?").1;
|
||||||
if config.auto_setup.enabled {
|
if config.auto_setup.enabled {
|
||||||
println!("Waiting for servers to start");
|
println!("Waiting for servers to start");
|
||||||
cloud.wait_for_start(docker).await?;
|
cloud.wait_for_start(docker).await?;
|
||||||
|
|
@ -328,7 +325,7 @@ async fn setup(docker: &mut Docker, options: CloudOptions, config: &HazeConfig)
|
||||||
"config:system:set",
|
"config:system:set",
|
||||||
"overwrite.cli.url",
|
"overwrite.cli.url",
|
||||||
"--value",
|
"--value",
|
||||||
&format!("http://{}", cloud.ip.unwrap()),
|
&cloud.address,
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
@ -336,12 +333,12 @@ async fn setup(docker: &mut Docker, options: CloudOptions, config: &HazeConfig)
|
||||||
cloud
|
cloud
|
||||||
.occ(
|
.occ(
|
||||||
docker,
|
docker,
|
||||||
vec!["config:system:set", "overwritehost", "--value", &ip_str],
|
vec!["config:system:set", "overwritehost", "--value", host],
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let domains = [ip_str.as_str(), "cloud", &cloud.id];
|
let domains = [ip_str.as_str(), "cloud", &cloud.id, host];
|
||||||
for (i, domain) in domains.iter().enumerate() {
|
for (i, domain) in domains.iter().enumerate() {
|
||||||
cloud
|
cloud
|
||||||
.occ(
|
.occ(
|
||||||
|
|
|
||||||
|
|
@ -155,14 +155,14 @@ impl PhpVersion {
|
||||||
ip.ok_or(Report::msg("Container not running"))?
|
ip.ok_or(Report::msg("Container not running"))?
|
||||||
))
|
))
|
||||||
.into_diagnostic()?;
|
.into_diagnostic()?;
|
||||||
timeout(Duration::from_secs(5), async {
|
timeout(Duration::from_secs(15), async {
|
||||||
while !client.get(url.clone()).send().await.is_ok() {
|
while !client.get(url.clone()).send().await.is_ok() {
|
||||||
sleep(Duration::from_millis(100)).await
|
sleep(Duration::from_millis(100)).await
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.into_diagnostic()
|
.into_diagnostic()
|
||||||
.wrap_err("Timeout after 5 seconds")
|
.wrap_err("Timeout after 15 seconds")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
151
src/proxy.rs
Normal file
151
src/proxy.rs
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
use crate::Result;
|
||||||
|
use crate::{Cloud, HazeConfig};
|
||||||
|
use bollard::Docker;
|
||||||
|
use futures_util::future::Either;
|
||||||
|
use futures_util::FutureExt;
|
||||||
|
use miette::{miette, Context, IntoDiagnostic};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::fs::{create_dir_all, remove_file, set_permissions};
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use tokio::net::UnixListener;
|
||||||
|
use tokio::signal::ctrl_c;
|
||||||
|
use tokio_stream::wrappers::UnixListenerStream;
|
||||||
|
use warp::host::Authority;
|
||||||
|
use warp::http::{HeaderMap, HeaderValue, Method};
|
||||||
|
use warp::hyper::body::Bytes;
|
||||||
|
use warp::path::FullPath;
|
||||||
|
use warp::Filter;
|
||||||
|
use warp_reverse_proxy::{
|
||||||
|
extract_request_data_filter, proxy_to_and_forward_response, QueryParameters,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ActiveInstances {
|
||||||
|
known: Mutex<HashMap<String, IpAddr>>,
|
||||||
|
docker: Docker,
|
||||||
|
config: HazeConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveInstances {
|
||||||
|
pub fn new(docker: Docker, config: HazeConfig) -> Self {
|
||||||
|
ActiveInstances {
|
||||||
|
known: Mutex::default(),
|
||||||
|
docker,
|
||||||
|
config,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get(&self, name: &str) -> Option<IpAddr> {
|
||||||
|
if let Some(ip) = self.known.lock().unwrap().get(name).cloned() {
|
||||||
|
return Some(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
let cloud = Cloud::get_by_filter(&self.docker, Some(name.into()), &self.config)
|
||||||
|
.await
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
|
if let Some(ip) = cloud.ip {
|
||||||
|
println!("{name} => {ip}");
|
||||||
|
|
||||||
|
self.known.lock().unwrap().insert(name.into(), ip);
|
||||||
|
return Some(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn proxy(docker: Docker, config: HazeConfig) -> Result<()> {
|
||||||
|
if config.proxy.listen.is_empty() {
|
||||||
|
return Err(miette!("Proxy not configured"));
|
||||||
|
}
|
||||||
|
let listen = config.proxy.listen.clone();
|
||||||
|
|
||||||
|
let instances = ActiveInstances::new(docker, config);
|
||||||
|
serve(instances, listen).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn serve(instances: ActiveInstances, listen: String) -> Result<()> {
|
||||||
|
let instances = Arc::new(instances);
|
||||||
|
let instances = warp::any().map(move || instances.clone());
|
||||||
|
|
||||||
|
let proxy = warp::any()
|
||||||
|
.and(warp::filters::host::optional())
|
||||||
|
.and(instances)
|
||||||
|
.and_then(
|
||||||
|
move |host: Option<Authority>, instances: Arc<ActiveInstances>| async move {
|
||||||
|
let host = match host {
|
||||||
|
Some(host) => host,
|
||||||
|
None => return Err(warp::reject::not_found()),
|
||||||
|
};
|
||||||
|
let requested_instance = host.as_str().split('.').next().unwrap();
|
||||||
|
if let Some(ip) = instances.get(requested_instance).await {
|
||||||
|
Ok((format!("http://{}", ip), host.to_string()))
|
||||||
|
} else {
|
||||||
|
eprintln!("Error {} has no known ip", requested_instance);
|
||||||
|
Err(warp::reject::not_found())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.untuple_one()
|
||||||
|
.and(extract_request_data_filter())
|
||||||
|
.and_then(
|
||||||
|
move |proxy_address: String,
|
||||||
|
host: String,
|
||||||
|
uri: FullPath,
|
||||||
|
params: QueryParameters,
|
||||||
|
method: Method,
|
||||||
|
mut headers: HeaderMap,
|
||||||
|
body: Bytes| {
|
||||||
|
headers.insert("host", HeaderValue::from_str(&host).unwrap());
|
||||||
|
proxy_to_and_forward_response(
|
||||||
|
proxy_address,
|
||||||
|
String::new(),
|
||||||
|
uri,
|
||||||
|
params,
|
||||||
|
method,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
let cancel = async {
|
||||||
|
ctrl_c().await.ok();
|
||||||
|
};
|
||||||
|
|
||||||
|
let warp_server = warp::serve(proxy);
|
||||||
|
|
||||||
|
let server = if !listen.starts_with('/') {
|
||||||
|
let listen = SocketAddr::from_str(&listen)
|
||||||
|
.into_diagnostic()
|
||||||
|
.wrap_err("Failed to parse proxy listen address")?;
|
||||||
|
Either::Left(warp_server.bind_with_graceful_shutdown(listen, cancel).1)
|
||||||
|
} else {
|
||||||
|
let listen: PathBuf = listen.into();
|
||||||
|
if let Some(parent) = listen.parent() {
|
||||||
|
if !parent.exists() {
|
||||||
|
create_dir_all(&parent).into_diagnostic()?;
|
||||||
|
set_permissions(&parent, PermissionsExt::from_mode(0o755)).into_diagnostic()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remove_file(&listen).ok();
|
||||||
|
|
||||||
|
let listener = UnixListener::bind(&listen).into_diagnostic()?;
|
||||||
|
set_permissions(&listen, PermissionsExt::from_mode(0o666)).into_diagnostic()?;
|
||||||
|
let stream = UnixListenerStream::new(listener);
|
||||||
|
Either::Right(
|
||||||
|
warp_server
|
||||||
|
.serve_incoming_with_graceful_shutdown(stream, cancel)
|
||||||
|
.map(move |_| {
|
||||||
|
remove_file(&listen).ok();
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
server.await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue