Switch to axum from warp
The warp repo hasn't seen any activity in over a year; project seems fairly dead.
This commit is contained in:
359
Cargo.lock
generated
359
Cargo.lock
generated
@@ -241,6 +241,83 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5"
|
||||
dependencies = [
|
||||
"axum-core",
|
||||
"bytes",
|
||||
"form_urlencoded",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"itoa",
|
||||
"matchit",
|
||||
"memchr",
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_path_to_error",
|
||||
"serde_urlencoded",
|
||||
"sync_wrapper",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-core"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"mime",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"sync_wrapper",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-extra"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-core",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"mime",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backon"
|
||||
version = "1.5.1"
|
||||
@@ -267,12 +344,6 @@ dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
@@ -290,12 +361,14 @@ name = "bebot"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
"chrono",
|
||||
"constant_time_eq 0.4.2",
|
||||
"dateparser",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"log",
|
||||
"matrix-sdk",
|
||||
"quick-xml",
|
||||
@@ -306,7 +379,6 @@ dependencies = [
|
||||
"serde_regex",
|
||||
"serde_yaml",
|
||||
"tokio",
|
||||
"warp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -587,12 +659,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
||||
|
||||
[[package]]
|
||||
name = "date_header"
|
||||
version = "1.0.5"
|
||||
@@ -992,25 +1058,6 @@ dependencies = [
|
||||
"xxhash-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http 0.2.12",
|
||||
"indexmap",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.4.11"
|
||||
@@ -1022,7 +1069,7 @@ dependencies = [
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"indexmap",
|
||||
"slab",
|
||||
"tokio",
|
||||
@@ -1038,14 +1085,14 @@ checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
||||
|
||||
[[package]]
|
||||
name = "headers"
|
||||
version = "0.3.9"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270"
|
||||
checksum = "b3314d5adb5d94bcdf56771f2e50dbbc80bb4bdf88967526706205ac9eff24eb"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"base64",
|
||||
"bytes",
|
||||
"headers-core",
|
||||
"http 0.2.12",
|
||||
"http",
|
||||
"httpdate",
|
||||
"mime",
|
||||
"sha1",
|
||||
@@ -1053,11 +1100,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "headers-core"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
|
||||
checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4"
|
||||
dependencies = [
|
||||
"http 0.2.12",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1090,17 +1137,6 @@ dependencies = [
|
||||
"match_token",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "1.3.1"
|
||||
@@ -1112,17 +1148,6 @@ dependencies = [
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http 0.2.12",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "1.0.1"
|
||||
@@ -1130,7 +1155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1141,8 +1166,8 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"http",
|
||||
"http-body",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
@@ -1158,30 +1183,6 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2 0.3.27",
|
||||
"http 0.2.12",
|
||||
"http-body 0.4.6",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"socket2 0.5.10",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.6.0"
|
||||
@@ -1191,10 +1192,11 @@ dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"h2 0.4.11",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
@@ -1208,8 +1210,8 @@ version = "0.27.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
|
||||
dependencies = [
|
||||
"http 1.3.1",
|
||||
"hyper 1.6.0",
|
||||
"http",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"rustls",
|
||||
"rustls-native-certs",
|
||||
@@ -1226,14 +1228,14 @@ version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"base64",
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"hyper 1.6.0",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"ipnet",
|
||||
"libc",
|
||||
"percent-encoding",
|
||||
@@ -1650,6 +1652,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
||||
|
||||
[[package]]
|
||||
name = "matrix-pickle"
|
||||
version = "0.2.1"
|
||||
@@ -1696,7 +1704,7 @@ dependencies = [
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"gloo-timers",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"imbl",
|
||||
"indexmap",
|
||||
"js_int",
|
||||
@@ -1783,7 +1791,7 @@ version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c2f3c5dfb6f61036290ee053f5cdc90ee672200e9254747b8eae922f00765f9"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"base64",
|
||||
"blake3",
|
||||
"chacha20poly1305",
|
||||
"hmac",
|
||||
@@ -1815,16 +1823,6 @@ version = "0.1.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbf6f36070878c42c5233846cd3de24cf9016828fd47bc22957a687298bb21fc"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
@@ -1845,24 +1843,6 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multer"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-util",
|
||||
"http 0.2.12",
|
||||
"httparse",
|
||||
"log",
|
||||
"memchr",
|
||||
"mime",
|
||||
"spin",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.6"
|
||||
@@ -1900,10 +1880,10 @@ version = "5.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"base64",
|
||||
"chrono",
|
||||
"getrandom 0.2.16",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"rand 0.8.5",
|
||||
"reqwest",
|
||||
"serde",
|
||||
@@ -2056,26 +2036,6 @@ dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
@@ -2442,16 +2402,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"base64 0.22.1",
|
||||
"base64",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2 0.4.11",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper 1.6.0",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-util",
|
||||
"js-sys",
|
||||
@@ -2544,7 +2504,7 @@ dependencies = [
|
||||
"assign",
|
||||
"bytes",
|
||||
"date_header",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"js_int",
|
||||
"js_option",
|
||||
"maplit",
|
||||
@@ -2565,11 +2525,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "387e1898e868d32ff7b205e7db327361d5dcf635c00a8ae5865068607595a9cf"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"base64 0.22.1",
|
||||
"base64",
|
||||
"bytes",
|
||||
"form_urlencoded",
|
||||
"getrandom 0.2.16",
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"indexmap",
|
||||
"js_int",
|
||||
"konst",
|
||||
@@ -2621,7 +2581,7 @@ version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb2a705c3911870782e036a3a8b676d0166c6c93800b84f6b8b23c981f78ef08"
|
||||
dependencies = [
|
||||
"http 1.3.1",
|
||||
"http",
|
||||
"js_int",
|
||||
"mime",
|
||||
"ruma-common",
|
||||
@@ -2771,12 +2731,6 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
@@ -3004,12 +2958,6 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "spki"
|
||||
version = "0.7.3"
|
||||
@@ -3277,18 +3225,6 @@ dependencies = [
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tungstenite"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
"tokio",
|
||||
"tungstenite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.15"
|
||||
@@ -3360,6 +3296,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3371,8 +3308,8 @@ dependencies = [
|
||||
"bitflags",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"http",
|
||||
"http-body",
|
||||
"iri-string",
|
||||
"pin-project-lite",
|
||||
"tower",
|
||||
@@ -3456,25 +3393,6 @@ version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"data-encoding",
|
||||
"http 1.3.1",
|
||||
"httparse",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
"sha1",
|
||||
"thiserror 1.0.69",
|
||||
"url",
|
||||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.18.0"
|
||||
@@ -3606,7 +3524,7 @@ checksum = "c022a277687e4e8685d72b95a7ca3ccfec907daa946678e715f8badaa650883d"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"arrayvec",
|
||||
"base64 0.22.1",
|
||||
"base64",
|
||||
"base64ct",
|
||||
"cbc",
|
||||
"chacha20poly1305",
|
||||
@@ -3637,35 +3555,6 @@ dependencies = [
|
||||
"try-lock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "warp"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"headers",
|
||||
"http 0.2.12",
|
||||
"hyper 0.14.32",
|
||||
"log",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"multer",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-tungstenite",
|
||||
"tokio-util",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
|
@@ -24,6 +24,8 @@ exclude = [
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
axum = "0.8.4"
|
||||
axum-extra = { version = "0.10.1", features = ["typed-header"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
constant_time_eq = "0.4"
|
||||
dateparser = "0.2"
|
||||
@@ -40,4 +42,3 @@ serde_json = "1"
|
||||
serde_regex = "1"
|
||||
serde_yaml = "0.9"
|
||||
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "macros", "time"] }
|
||||
warp = "0.3"
|
||||
|
@@ -16,13 +16,15 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{extract::State, routing::post, Json, Router};
|
||||
use axum_extra::{headers, TypedHeader};
|
||||
use constant_time_eq::constant_time_eq;
|
||||
use http::{HeaderName, HeaderValue, StatusCode};
|
||||
use matrix_sdk::{
|
||||
ruma::{events::room::message::RoomMessageEventContent, OwnedRoomOrAliasId},
|
||||
Client,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
use warp::{filters::BoxedFilter, http::StatusCode, reply::Reply, Filter};
|
||||
use tokio::sync::mpsc::{self, Sender};
|
||||
|
||||
use crate::{
|
||||
config::GitlabWebhookConfig,
|
||||
@@ -30,6 +32,42 @@ use crate::{
|
||||
matrix,
|
||||
};
|
||||
|
||||
static X_GITLAB_TOKEN: HeaderName = HeaderName::from_static("x-gitlab-token");
|
||||
|
||||
struct XGitlabToken(String);
|
||||
|
||||
impl headers::Header for XGitlabToken {
|
||||
fn name() -> &'static HeaderName {
|
||||
&X_GITLAB_TOKEN
|
||||
}
|
||||
|
||||
fn decode<'i, I>(values: &mut I) -> Result<Self, headers::Error>
|
||||
where
|
||||
Self: Sized,
|
||||
I: Iterator<Item = &'i http::HeaderValue>,
|
||||
{
|
||||
let value = values.next().ok_or_else(headers::Error::invalid)?;
|
||||
|
||||
if value.is_empty() {
|
||||
Err(headers::Error::invalid())
|
||||
} else {
|
||||
Ok(XGitlabToken(
|
||||
value.to_str().map_err(|_| headers::Error::invalid())?.to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn encode<E: Extend<http::HeaderValue>>(&self, values: &mut E) {
|
||||
values.extend(std::iter::once(HeaderValue::from_str(self.0.as_str()).unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct WebhookState {
|
||||
config: Arc<GitlabWebhookConfig>,
|
||||
event_tx: Sender<(GitlabEvent, OwnedRoomOrAliasId)>,
|
||||
}
|
||||
|
||||
pub fn build_gitlab_messages(event: &GitlabEvent) -> Vec<String> {
|
||||
let project = event.project();
|
||||
let refname = event.r#ref().map(parse_ref);
|
||||
@@ -62,7 +100,47 @@ pub async fn handle_gitlab_event(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn build_route(config: GitlabWebhookConfig, matrix_client: Client) -> anyhow::Result<BoxedFilter<(impl Reply,)>> {
|
||||
async fn handle_hooks_gitlab(
|
||||
State(state): State<WebhookState>,
|
||||
TypedHeader(token): TypedHeader<XGitlabToken>,
|
||||
Json(event): Json<GitlabEvent>,
|
||||
) -> (StatusCode, &'static str) {
|
||||
match event {
|
||||
GitlabEvent::Other => (StatusCode::BAD_REQUEST, "Unsupported Gitlab event type"),
|
||||
_ => {
|
||||
let project = event.project();
|
||||
let config_key = project.web_url.replace("http://", "").replace("https://", "");
|
||||
if let Some(repo_config) = state.config.repo_configs.get(&config_key) {
|
||||
if !constant_time_eq(token.0.as_bytes(), repo_config.token.as_bytes()) {
|
||||
warn!("Invalid token for repo '{config_key}'");
|
||||
(StatusCode::FORBIDDEN, "Invalid token")
|
||||
} else {
|
||||
debug!("payload: {event:?}");
|
||||
if let Some(room) = &repo_config.room.as_ref().or(state.config.default_room.as_ref()) {
|
||||
let publish_events = repo_config
|
||||
.publish_events
|
||||
.as_ref()
|
||||
.or(state.config.default_publish_events.as_ref());
|
||||
if publish_events.map(|ecs| event.should_publish(ecs)).unwrap_or(true) {
|
||||
if let Err(err) = state.event_tx.send((event, (*room).clone())).await {
|
||||
warn!("Failed to enqueue payload: {err}");
|
||||
}
|
||||
}
|
||||
(StatusCode::OK, "OK")
|
||||
} else {
|
||||
info!("Channel not configured for repo '{config_key}'");
|
||||
(StatusCode::NOT_FOUND, "Matrix room not configured for repo")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info!("Repo '{config_key}' unconfigured");
|
||||
(StatusCode::NOT_FOUND, "Repo not configured")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_route(config: GitlabWebhookConfig, matrix_client: Client) -> Router {
|
||||
let (event_tx, mut event_rx) = mpsc::channel::<(GitlabEvent, OwnedRoomOrAliasId)>(100);
|
||||
tokio::spawn(async move {
|
||||
while let Some((event, room)) = event_rx.recv().await {
|
||||
@@ -72,70 +150,16 @@ pub fn build_route(config: GitlabWebhookConfig, matrix_client: Client) -> anyhow
|
||||
}
|
||||
});
|
||||
|
||||
let gitlab_root_path = if let Some(url_prefix) = config.url_prefix.as_ref() {
|
||||
url_prefix.split('/').fold(warp::any().boxed(), |last, segment| {
|
||||
if segment.is_empty() {
|
||||
last
|
||||
} else {
|
||||
last.and(warp::path(segment.to_string())).boxed()
|
||||
}
|
||||
})
|
||||
let path = if let Some(url_prefix) = &config.url_prefix {
|
||||
format!("{url_prefix}/hooks/gitlab")
|
||||
} else {
|
||||
warp::any().boxed()
|
||||
"/hooks/gitlab".to_owned()
|
||||
};
|
||||
|
||||
let config = Arc::new(config);
|
||||
let gitlab = gitlab_root_path
|
||||
.and(warp::path!("hooks" / "gitlab"))
|
||||
.and(warp::post())
|
||||
.and(warp::header::<String>("x-gitlab-token"))
|
||||
.and(warp::body::json())
|
||||
.then(move |token: String, event: GitlabEvent| {
|
||||
let event_tx = event_tx.clone();
|
||||
let config = Arc::clone(&config);
|
||||
let state = WebhookState {
|
||||
config: Arc::new(config),
|
||||
event_tx,
|
||||
};
|
||||
|
||||
async move {
|
||||
match event {
|
||||
GitlabEvent::Other => {
|
||||
warp::reply::with_status("Unsupported Gitlab event type", StatusCode::BAD_REQUEST)
|
||||
}
|
||||
_ => {
|
||||
let project = event.project();
|
||||
let config_key = project.web_url.replace("http://", "").replace("https://", "");
|
||||
if let Some(repo_config) = config.repo_configs.get(&config_key) {
|
||||
if !constant_time_eq(token.as_bytes(), repo_config.token.as_bytes()) {
|
||||
warn!("Invalid token for repo '{config_key}'");
|
||||
warp::reply::with_status("Invalid token", StatusCode::FORBIDDEN)
|
||||
} else {
|
||||
debug!("payload: {event:?}");
|
||||
if let Some(room) = &repo_config.room.as_ref().or(config.default_room.as_ref()) {
|
||||
let publish_events = repo_config
|
||||
.publish_events
|
||||
.as_ref()
|
||||
.or(config.default_publish_events.as_ref());
|
||||
if publish_events.map(|ecs| event.should_publish(ecs)).unwrap_or(true) {
|
||||
if let Err(err) = event_tx.send((event, (*room).clone())).await {
|
||||
warn!("Failed to enqueue payload: {err}");
|
||||
}
|
||||
}
|
||||
warp::reply::with_status("OK", StatusCode::OK)
|
||||
} else {
|
||||
info!("Channel not configured for repo '{config_key}'");
|
||||
warp::reply::with_status(
|
||||
"Matrix room not configured for repo",
|
||||
StatusCode::NOT_FOUND,
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
info!("Repo '{config_key}' unconfigured");
|
||||
warp::reply::with_status("Repo not configured", StatusCode::NOT_FOUND)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.boxed();
|
||||
|
||||
Ok(gitlab)
|
||||
Router::new().route(&path, post(handle_hooks_gitlab)).with_state(state)
|
||||
}
|
||||
|
24
src/main.rs
24
src/main.rs
@@ -27,11 +27,11 @@ mod gitlab_webhook;
|
||||
mod mail_archive;
|
||||
mod matrix;
|
||||
|
||||
use std::{env, net::IpAddr, process::exit};
|
||||
use std::{env, process::exit};
|
||||
|
||||
use anyhow::Context;
|
||||
use futures::future::join_all;
|
||||
use warp::Filter;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
async fn run() -> anyhow::Result<()> {
|
||||
info!("{} v{} starting...", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
|
||||
@@ -50,18 +50,14 @@ async fn run() -> anyhow::Result<()> {
|
||||
};
|
||||
|
||||
if let Some(gitlab_webhook) = config.gitlab_webhook.take() {
|
||||
let gitlab = gitlab_webhook::build_route(gitlab_webhook, matrix_client.clone())?;
|
||||
let routes = gitlab.with(warp::log("bebot"));
|
||||
|
||||
let addr = config
|
||||
.bind_address
|
||||
.as_ref()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "127.0.0.1".to_string())
|
||||
.parse::<IpAddr>()
|
||||
.context("Failed to parse bind_address")?;
|
||||
let port = config.bind_port.unwrap_or(3000);
|
||||
warp::serve(routes).run((addr, port)).await;
|
||||
let gitlab = gitlab_webhook::build_route(gitlab_webhook, matrix_client.clone());
|
||||
let bind_addr = format!(
|
||||
"{}:{}",
|
||||
config.bind_address.as_deref().unwrap_or("127.0.0.1"),
|
||||
config.bind_port.unwrap_or(3000)
|
||||
);
|
||||
let listener = TcpListener::bind(bind_addr).await?;
|
||||
axum::serve(listener, gitlab).await?;
|
||||
}
|
||||
|
||||
join_all(handles).await;
|
||||
|
Reference in New Issue
Block a user