Make axum-dual-protocol a non-feature. Fix build issues.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-08-15 02:35:19 +00:00
parent 17a54bc4f8
commit 43300ea41e
7 changed files with 66 additions and 139 deletions

147
Cargo.lock generated
View file

@ -275,29 +275,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "axum-server"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ad46c3ec4e12f4a4b6835e173ba21c25e484c9d02b49770bf006ce5367c036"
dependencies = [
"arc-swap",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"hyper",
"hyper-util",
"pin-project-lite",
"rustls 0.21.12",
"rustls-pemfile",
"tokio",
"tokio-rustls 0.24.1",
"tower 0.4.13",
"tower-service",
]
[[package]] [[package]]
name = "axum-server" name = "axum-server"
version = "0.7.1" version = "0.7.1"
@ -317,24 +294,25 @@ dependencies = [
"rustls-pemfile", "rustls-pemfile",
"rustls-pki-types", "rustls-pki-types",
"tokio", "tokio",
"tokio-rustls 0.26.0", "tokio-rustls",
"tower 0.4.13", "tower 0.4.13",
"tower-service", "tower-service",
] ]
[[package]] [[package]]
name = "axum-server-dual-protocol" name = "axum-server-dual-protocol"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ea4cd08ae2a5f075d28fa31190163c8106a1d2d3189442494bae22b39040a0d" checksum = "2164551db024e87f20316d164eab9f5ad342d8188b08051ceb15ca92a60ea7b7"
dependencies = [ dependencies = [
"axum-server 0.6.0", "axum-server",
"bytes", "bytes",
"http", "http",
"http-body-util", "http-body-util",
"pin-project", "pin-project",
"rustls 0.23.12",
"tokio", "tokio",
"tokio-rustls 0.24.1", "tokio-rustls",
"tokio-util", "tokio-util",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
@ -500,9 +478,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.11" version = "1.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fb8dd288a69fc53a1996d7ecfbf4a20d59065bff137ce7e56bbd620de191189" checksum = "68064e60dbf1f17005c2fde4d07c16d8baa506fd7ffed8ccab702d93617975c7"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@ -561,9 +539,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.15" version = "4.5.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -599,9 +577,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]] [[package]]
name = "cmake" name = "cmake"
version = "0.1.50" version = "0.1.51"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a"
dependencies = [ dependencies = [
"cc", "cc",
] ]
@ -769,7 +747,7 @@ version = "0.4.6"
dependencies = [ dependencies = [
"axum", "axum",
"axum-client-ip", "axum-client-ip",
"axum-server 0.7.1", "axum-server",
"axum-server-dual-protocol", "axum-server-dual-protocol",
"bytes", "bytes",
"conduit_admin", "conduit_admin",
@ -1715,7 +1693,7 @@ dependencies = [
"rustls-native-certs", "rustls-native-certs",
"rustls-pki-types", "rustls-pki-types",
"tokio", "tokio",
"tokio-rustls 0.26.0", "tokio-rustls",
"tower-service", "tower-service",
"webpki-roots", "webpki-roots",
] ]
@ -1997,9 +1975,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.155" version = "0.2.156"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -2940,7 +2918,7 @@ dependencies = [
"serde_urlencoded", "serde_urlencoded",
"sync_wrapper 1.0.1", "sync_wrapper 1.0.1",
"tokio", "tokio",
"tokio-rustls 0.26.0", "tokio-rustls",
"tokio-socks", "tokio-socks",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
@ -2980,7 +2958,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.10.1" version = "0.10.1"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -3002,7 +2980,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3014,7 +2992,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.18.0" version = "0.18.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -3037,7 +3015,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.13.0" version = "0.13.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -3067,7 +3045,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.28.1" version = "0.28.1"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.4.0", "indexmap 2.4.0",
@ -3084,15 +3062,22 @@ dependencies = [
"thiserror", "thiserror",
"tracing", "tracing",
"url", "url",
"web-time 1.1.0",
"wildmatch", "wildmatch",
] ]
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"bytes",
"http",
"httparse",
"js_int", "js_int",
"memchr",
"mime",
"rand",
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"serde", "serde",
@ -3102,7 +3087,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.9.5" version = "0.9.5"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror", "thiserror",
@ -3111,7 +3096,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identity-service-api" name = "ruma-identity-service-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3121,7 +3106,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.13.0" version = "0.13.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"proc-macro-crate", "proc-macro-crate",
@ -3136,7 +3121,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -3148,7 +3133,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-server-util" name = "ruma-server-util"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"headers", "headers",
"http", "http",
@ -3161,7 +3146,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.15.0" version = "0.15.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",
@ -3177,7 +3162,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.11.0" version = "0.11.0"
source = "git+https://github.com/girlbossceo/ruwuma?rev=40bf9965ac30118d2f85547f2ce6b7463025841a#40bf9965ac30118d2f85547f2ce6b7463025841a" source = "git+https://github.com/girlbossceo/ruwuma?rev=d23a8412bd8f875cf81bbd7e20cefa03263fcd0e#d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
dependencies = [ dependencies = [
"itertools 0.12.1", "itertools 0.12.1",
"js_int", "js_int",
@ -3263,18 +3248,6 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "rustls"
version = "0.21.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
dependencies = [
"log",
"ring",
"rustls-webpki 0.101.7",
"sct",
]
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.22.4" version = "0.22.4"
@ -3284,7 +3257,7 @@ dependencies = [
"log", "log",
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
"rustls-webpki 0.102.6", "rustls-webpki",
"subtle", "subtle",
"zeroize", "zeroize",
] ]
@ -3300,7 +3273,7 @@ dependencies = [
"once_cell", "once_cell",
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
"rustls-webpki 0.102.6", "rustls-webpki",
"subtle", "subtle",
"zeroize", "zeroize",
] ]
@ -3334,16 +3307,6 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0"
[[package]]
name = "rustls-webpki"
version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
version = "0.102.6" version = "0.102.6"
@ -3408,16 +3371,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sct"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "sd-notify" name = "sd-notify"
version = "0.4.2" version = "0.4.2"
@ -3590,18 +3543,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.207" version = "1.0.208"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.207" version = "1.0.208"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3623,9 +3576,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.124" version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr", "memchr",
@ -4127,16 +4080,6 @@ dependencies = [
"tokio-stream", "tokio-stream",
] ]
[[package]]
name = "tokio-rustls"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [
"rustls 0.21.12",
"tokio",
]
[[package]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.26.0" version = "0.26.0"

View file

@ -103,6 +103,10 @@ version = "0.7.1"
default-features = false default-features = false
features = ["tls-rustls"] features = ["tls-rustls"]
# to listen on both HTTP and HTTPS if listening on TLS dierctly from conduwuit for complement or sytest
[workspace.dependencies.axum-server-dual-protocol]
version = "0.7"
[workspace.dependencies.axum-client-ip] [workspace.dependencies.axum-client-ip]
version = "0.6.0" version = "0.6.0"
@ -307,7 +311,7 @@ version = "0.1.2"
[workspace.dependencies.ruma] [workspace.dependencies.ruma]
git = "https://github.com/girlbossceo/ruwuma" git = "https://github.com/girlbossceo/ruwuma"
#branch = "conduwuit-changes" #branch = "conduwuit-changes"
rev = "40bf9965ac30118d2f85547f2ce6b7463025841a" rev = "d23a8412bd8f875cf81bbd7e20cefa03263fcd0e"
features = [ features = [
"compat", "compat",
"rand", "rand",
@ -347,10 +351,6 @@ features = [
"bzip2", "bzip2",
] ]
# to listen on both HTTP and HTTPS if listening on TLS dierctly from conduwuit for complement or sytest
[workspace.dependencies.axum-server-dual-protocol]
version = "0.6"
# optional SHA256 media keys feature # optional SHA256 media keys feature
[workspace.dependencies.sha2] [workspace.dependencies.sha2]
version = "0.10.8" version = "0.10.8"

View file

@ -368,8 +368,6 @@ pub struct TlsConfig {
pub key: String, pub key: String,
#[serde(default)] #[serde(default)]
/// Whether to listen and allow for HTTP and HTTPS connections (insecure!) /// Whether to listen and allow for HTTP and HTTPS connections (insecure!)
/// Only works / does something if the `axum_dual_protocol` feature flag was
/// built
pub dual_protocol: bool, pub dual_protocol: bool,
} }

View file

@ -48,9 +48,6 @@ default = [
"zstd_compression", "zstd_compression",
] ]
axum_dual_protocol = [
"conduit-router/axum_dual_protocol",
]
brotli_compression = [ brotli_compression = [
"conduit-api/brotli_compression", "conduit-api/brotli_compression",
"conduit-core/brotli_compression", "conduit-core/brotli_compression",

View file

@ -41,13 +41,9 @@ brotli_compression = [
systemd = [ systemd = [
"dep:sd-notify", "dep:sd-notify",
] ]
axum_dual_protocol = [
"dep:axum-server-dual-protocol"
]
[dependencies] [dependencies]
axum-client-ip.workspace = true axum-client-ip.workspace = true
axum-server-dual-protocol.optional = true
axum-server-dual-protocol.workspace = true axum-server-dual-protocol.workspace = true
axum-server.workspace = true axum-server.workspace = true
axum.workspace = true axum.workspace = true

View file

@ -16,9 +16,9 @@ use tower::ServiceBuilder;
use tower_http::{ use tower_http::{
catch_panic::CatchPanicLayer, catch_panic::CatchPanicLayer,
cors::{self, CorsLayer}, cors::{self, CorsLayer},
sensitive_headers::SetSensitiveHeadersLayer,
set_header::SetResponseHeaderLayer, set_header::SetResponseHeaderLayer,
trace::{DefaultOnFailure, DefaultOnRequest, DefaultOnResponse, TraceLayer}, trace::{DefaultOnFailure, DefaultOnRequest, DefaultOnResponse, TraceLayer},
ServiceBuilderExt as _,
}; };
use tracing::Level; use tracing::Level;
@ -47,7 +47,7 @@ pub(crate) fn build(services: &Arc<Services>) -> Result<(Router, Guard)> {
let layers = layers.layer(compression_layer(server)); let layers = layers.layer(compression_layer(server));
let layers = layers let layers = layers
.sensitive_headers([header::AUTHORIZATION]) .layer(SetSensitiveHeadersLayer::new([header::AUTHORIZATION]))
.layer(axum::middleware::from_fn_with_state(Arc::clone(services), request::spawn)) .layer(axum::middleware::from_fn_with_state(Arc::clone(services), request::spawn))
.layer( .layer(
TraceLayer::new_for_http() TraceLayer::new_for_http()

View file

@ -1,9 +1,11 @@
use std::{net::SocketAddr, sync::Arc}; use std::{net::SocketAddr, sync::Arc};
use axum::Router; use axum::Router;
use axum_server::{bind_rustls, tls_rustls::RustlsConfig, Handle as ServerHandle}; use axum_server::Handle as ServerHandle;
#[cfg(feature = "axum_dual_protocol")] use axum_server_dual_protocol::{
use axum_server_dual_protocol::ServerExt; axum_server::{bind_rustls, tls_rustls::RustlsConfig},
ServerExt,
};
use conduit::{Result, Server}; use conduit::{Result, Server};
use tokio::task::JoinSet; use tokio::task::JoinSet;
use tracing::{debug, info, warn}; use tracing::{debug, info, warn};
@ -13,27 +15,18 @@ pub(super) async fn serve(
) -> Result<()> { ) -> Result<()> {
let config = &server.config; let config = &server.config;
let tls = config.tls.as_ref().expect("TLS configuration"); let tls = config.tls.as_ref().expect("TLS configuration");
let certs = &tls.certs;
let key = &tls.key;
debug!( debug!("Using direct TLS. Certificate path {certs} and certificate private key path {key}",);
"Using direct TLS. Certificate path {} and certificate private key path {}",
&tls.certs, &tls.key
);
info!( info!(
"Note: It is strongly recommended that you use a reverse proxy instead of running conduwuit directly with TLS." "Note: It is strongly recommended that you use a reverse proxy instead of running conduwuit directly with TLS."
); );
let conf = RustlsConfig::from_pem_file(&tls.certs, &tls.key).await?; let conf = RustlsConfig::from_pem_file(certs, key).await?;
if cfg!(feature = "axum_dual_protocol") {
info!(
"conduwuit was built with axum_dual_protocol feature to listen on both HTTP and HTTPS. This will only \
take effect if `dual_protocol` is enabled in `[global.tls]`"
);
}
let mut join_set = JoinSet::new(); let mut join_set = JoinSet::new();
let app = app.into_make_service_with_connect_info::<SocketAddr>(); let app = app.into_make_service_with_connect_info::<SocketAddr>();
if cfg!(feature = "axum_dual_protocol") && tls.dual_protocol { if tls.dual_protocol {
#[cfg(feature = "axum_dual_protocol")]
for addr in &addrs { for addr in &addrs {
join_set.spawn_on( join_set.spawn_on(
axum_server_dual_protocol::bind_dual_protocol(*addr, conf.clone()) axum_server_dual_protocol::bind_dual_protocol(*addr, conf.clone())
@ -54,13 +47,13 @@ pub(super) async fn serve(
} }
} }
if cfg!(feature = "axum_dual_protocol") && tls.dual_protocol { if tls.dual_protocol {
warn!( warn!(
"Listening on {:?} with TLS certificate {} and supporting plain text (HTTP) connections too (insecure!)", "Listening on {addrs:?} with TLS certificate {certs} and supporting plain text (HTTP) connections too \
addrs, &tls.certs (insecure!)",
); );
} else { } else {
info!("Listening on {:?} with TLS certificate {}", addrs, &tls.certs); info!("Listening on {addrs:?} with TLS certificate {certs}");
} }
while join_set.join_next().await.is_some() {} while join_set.join_next().await.is_some() {}