@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "conduwuit_router"
|
||||
name = "tuwunel_router"
|
||||
categories.workspace = true
|
||||
description.workspace = true
|
||||
edition.workspace = true
|
||||
@@ -18,10 +18,10 @@ crate-type = [
|
||||
|
||||
[features]
|
||||
brotli_compression = [
|
||||
"conduwuit-admin/brotli_compression",
|
||||
"conduwuit-api/brotli_compression",
|
||||
"conduwuit-core/brotli_compression",
|
||||
"conduwuit-service/brotli_compression",
|
||||
"tuwunel-admin/brotli_compression",
|
||||
"tuwunel-api/brotli_compression",
|
||||
"tuwunel-core/brotli_compression",
|
||||
"tuwunel-service/brotli_compression",
|
||||
"tower-http/compression-br",
|
||||
]
|
||||
direct_tls = [
|
||||
@@ -30,54 +30,54 @@ direct_tls = [
|
||||
"dep:axum-server-dual-protocol",
|
||||
]
|
||||
gzip_compression = [
|
||||
"conduwuit-admin/gzip_compression",
|
||||
"conduwuit-api/gzip_compression",
|
||||
"conduwuit-core/gzip_compression",
|
||||
"conduwuit-service/gzip_compression",
|
||||
"tuwunel-admin/gzip_compression",
|
||||
"tuwunel-api/gzip_compression",
|
||||
"tuwunel-core/gzip_compression",
|
||||
"tuwunel-service/gzip_compression",
|
||||
"tower-http/compression-gzip",
|
||||
]
|
||||
io_uring = [
|
||||
"conduwuit-admin/io_uring",
|
||||
"conduwuit-api/io_uring",
|
||||
"conduwuit-service/io_uring",
|
||||
"conduwuit-api/io_uring",
|
||||
"tuwunel-admin/io_uring",
|
||||
"tuwunel-api/io_uring",
|
||||
"tuwunel-service/io_uring",
|
||||
"tuwunel-api/io_uring",
|
||||
]
|
||||
jemalloc = [
|
||||
"conduwuit-admin/jemalloc",
|
||||
"conduwuit-api/jemalloc",
|
||||
"conduwuit-core/jemalloc",
|
||||
"conduwuit-service/jemalloc",
|
||||
"tuwunel-admin/jemalloc",
|
||||
"tuwunel-api/jemalloc",
|
||||
"tuwunel-core/jemalloc",
|
||||
"tuwunel-service/jemalloc",
|
||||
]
|
||||
jemalloc_conf = [
|
||||
"conduwuit-admin/jemalloc_conf",
|
||||
"conduwuit-api/jemalloc_conf",
|
||||
"conduwuit-core/jemalloc_conf",
|
||||
"conduwuit-service/jemalloc_conf",
|
||||
"tuwunel-admin/jemalloc_conf",
|
||||
"tuwunel-api/jemalloc_conf",
|
||||
"tuwunel-core/jemalloc_conf",
|
||||
"tuwunel-service/jemalloc_conf",
|
||||
]
|
||||
jemalloc_prof = [
|
||||
"conduwuit-admin/jemalloc_prof",
|
||||
"conduwuit-api/jemalloc_prof",
|
||||
"conduwuit-core/jemalloc_prof",
|
||||
"conduwuit-service/jemalloc_prof",
|
||||
"tuwunel-admin/jemalloc_prof",
|
||||
"tuwunel-api/jemalloc_prof",
|
||||
"tuwunel-core/jemalloc_prof",
|
||||
"tuwunel-service/jemalloc_prof",
|
||||
]
|
||||
jemalloc_stats = [
|
||||
"conduwuit-admin/jemalloc_stats",
|
||||
"conduwuit-api/jemalloc_stats",
|
||||
"conduwuit-core/jemalloc_stats",
|
||||
"conduwuit-service/jemalloc_stats",
|
||||
"tuwunel-admin/jemalloc_stats",
|
||||
"tuwunel-api/jemalloc_stats",
|
||||
"tuwunel-core/jemalloc_stats",
|
||||
"tuwunel-service/jemalloc_stats",
|
||||
]
|
||||
release_max_log_level = [
|
||||
"conduwuit-admin/release_max_log_level",
|
||||
"conduwuit-api/release_max_log_level",
|
||||
"conduwuit-core/release_max_log_level",
|
||||
"conduwuit-service/release_max_log_level",
|
||||
"tuwunel-admin/release_max_log_level",
|
||||
"tuwunel-api/release_max_log_level",
|
||||
"tuwunel-core/release_max_log_level",
|
||||
"tuwunel-service/release_max_log_level",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
]
|
||||
sentry_telemetry = [
|
||||
"conduwuit-core/sentry_telemetry",
|
||||
"tuwunel-core/sentry_telemetry",
|
||||
"dep:sentry",
|
||||
"dep:sentry-tracing",
|
||||
"dep:sentry-tower",
|
||||
@@ -86,9 +86,9 @@ systemd = [
|
||||
"dep:sd-notify",
|
||||
]
|
||||
zstd_compression = [
|
||||
"conduwuit-api/zstd_compression",
|
||||
"conduwuit-core/zstd_compression",
|
||||
"conduwuit-service/zstd_compression",
|
||||
"tuwunel-api/zstd_compression",
|
||||
"tuwunel-core/zstd_compression",
|
||||
"tuwunel-service/zstd_compression",
|
||||
"tower-http/compression-zstd",
|
||||
]
|
||||
|
||||
@@ -99,10 +99,6 @@ axum-server-dual-protocol.optional = true
|
||||
axum-server.workspace = true
|
||||
axum.workspace = true
|
||||
bytes.workspace = true
|
||||
conduwuit-admin.workspace = true
|
||||
conduwuit-api.workspace = true
|
||||
conduwuit-core.workspace = true
|
||||
conduwuit-service.workspace = true
|
||||
const-str.workspace = true
|
||||
futures.workspace = true
|
||||
http.workspace = true
|
||||
@@ -124,6 +120,10 @@ tokio.workspace = true
|
||||
tower.workspace = true
|
||||
tower-http.workspace = true
|
||||
tracing.workspace = true
|
||||
tuwunel-admin.workspace = true
|
||||
tuwunel-api.workspace = true
|
||||
tuwunel-core.workspace = true
|
||||
tuwunel-service.workspace = true
|
||||
|
||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||
sd-notify.workspace = true
|
||||
|
||||
@@ -5,9 +5,6 @@ use axum::{
|
||||
extract::{DefaultBodyLimit, MatchedPath},
|
||||
};
|
||||
use axum_client_ip::SecureClientIpSource;
|
||||
use conduwuit::{Result, Server, debug, error};
|
||||
use conduwuit_api::router::state::Guard;
|
||||
use conduwuit_service::Services;
|
||||
use http::{
|
||||
HeaderValue, Method, StatusCode,
|
||||
header::{self, HeaderName},
|
||||
@@ -22,10 +19,13 @@ use tower_http::{
|
||||
trace::{DefaultOnFailure, DefaultOnRequest, DefaultOnResponse, TraceLayer},
|
||||
};
|
||||
use tracing::Level;
|
||||
use tuwunel_api::router::state::Guard;
|
||||
use tuwunel_core::{Result, Server, debug, error};
|
||||
use tuwunel_service::Services;
|
||||
|
||||
use crate::{request, router};
|
||||
|
||||
const CONDUWUIT_CSP: &[&str; 5] = &[
|
||||
const TUWUNEL_CSP: &[&str; 5] = &[
|
||||
"default-src 'none'",
|
||||
"frame-ancestors 'none'",
|
||||
"form-action 'none'",
|
||||
@@ -33,7 +33,7 @@ const CONDUWUIT_CSP: &[&str; 5] = &[
|
||||
"sandbox",
|
||||
];
|
||||
|
||||
const CONDUWUIT_PERMISSIONS_POLICY: &[&str; 2] = &["interest-cohort=()", "browsing-topics=()"];
|
||||
const TUWUNEL_PERMISSIONS_POLICY: &[&str; 2] = &["interest-cohort=()", "browsing-topics=()"];
|
||||
|
||||
pub(crate) fn build(services: &Arc<Services>) -> Result<(Router, Guard)> {
|
||||
let server = &services.server;
|
||||
@@ -86,11 +86,11 @@ pub(crate) fn build(services: &Arc<Services>) -> Result<(Router, Guard)> {
|
||||
))
|
||||
.layer(SetResponseHeaderLayer::if_not_present(
|
||||
HeaderName::from_static("permissions-policy"),
|
||||
HeaderValue::from_str(&CONDUWUIT_PERMISSIONS_POLICY.join(","))?,
|
||||
HeaderValue::from_str(&TUWUNEL_PERMISSIONS_POLICY.join(","))?,
|
||||
))
|
||||
.layer(SetResponseHeaderLayer::if_not_present(
|
||||
header::CONTENT_SECURITY_POLICY,
|
||||
HeaderValue::from_str(&CONDUWUIT_CSP.join(";"))?,
|
||||
HeaderValue::from_str(&TUWUNEL_CSP.join(";"))?,
|
||||
))
|
||||
.layer(cors_layer(server))
|
||||
.layer(body_limit_layer(server))
|
||||
|
||||
@@ -6,17 +6,15 @@ mod router;
|
||||
mod run;
|
||||
mod serve;
|
||||
|
||||
extern crate conduwuit_core as conduwuit;
|
||||
|
||||
use std::{panic::AssertUnwindSafe, pin::Pin, sync::Arc};
|
||||
|
||||
use conduwuit::{Error, Result, Server};
|
||||
use conduwuit_service::Services;
|
||||
use futures::{Future, FutureExt, TryFutureExt};
|
||||
use tuwunel_core::{Error, Result, Server};
|
||||
use tuwunel_service::Services;
|
||||
|
||||
conduwuit::mod_ctor! {}
|
||||
conduwuit::mod_dtor! {}
|
||||
conduwuit::rustc_flags_capture! {}
|
||||
tuwunel_core::mod_ctor! {}
|
||||
tuwunel_core::mod_dtor! {}
|
||||
tuwunel_core::rustc_flags_capture! {}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "Rust" fn start(
|
||||
|
||||
@@ -8,12 +8,12 @@ use axum::{
|
||||
extract::State,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use conduwuit::{Result, debug, debug_error, debug_warn, err, error, trace};
|
||||
use conduwuit_service::Services;
|
||||
use futures::FutureExt;
|
||||
use http::{Method, StatusCode, Uri};
|
||||
use tokio::time::sleep;
|
||||
use tracing::Span;
|
||||
use tuwunel_core::{Result, debug, debug_error, debug_warn, err, error, trace};
|
||||
use tuwunel_service::Services;
|
||||
|
||||
#[tracing::instrument(name = "request", level = "debug", skip_all)]
|
||||
pub(crate) async fn handle(
|
||||
@@ -82,7 +82,7 @@ async fn execute(
|
||||
parent: &Span,
|
||||
) -> Response {
|
||||
#[cfg(debug_assertions)]
|
||||
conduwuit::defer! {{
|
||||
tuwunel_core::defer! {{
|
||||
_ = services.server
|
||||
.metrics
|
||||
.requests_handle_finished
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{Router, response::IntoResponse, routing::get};
|
||||
use conduwuit::Error;
|
||||
use conduwuit_api::router::{state, state::Guard};
|
||||
use conduwuit_service::Services;
|
||||
use http::{StatusCode, Uri};
|
||||
use ruma::api::client::error::ErrorKind;
|
||||
use tuwunel_api::router::{state, state::Guard};
|
||||
use tuwunel_core::Error;
|
||||
use tuwunel_service::Services;
|
||||
|
||||
pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
|
||||
let router = Router::<state::State>::new();
|
||||
let (state, guard) = state::create(services.clone());
|
||||
let router = conduwuit_api::router::build(router, &services.server)
|
||||
let router = tuwunel_api::router::build(router, &services.server)
|
||||
.route("/", get(it_works))
|
||||
.fallback(not_found)
|
||||
.with_state(state);
|
||||
@@ -22,4 +22,4 @@ async fn not_found(_uri: Uri) -> impl IntoResponse {
|
||||
Error::Request(ErrorKind::Unrecognized, "Not Found".into(), StatusCode::NOT_FOUND)
|
||||
}
|
||||
|
||||
async fn it_works() -> &'static str { "hewwo from conduwuit woof!" }
|
||||
async fn it_works() -> &'static str { "hewwo from tuwunel woof!" }
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
extern crate conduwuit_admin as admin;
|
||||
extern crate conduwuit_core as conduwuit;
|
||||
extern crate conduwuit_service as service;
|
||||
|
||||
use std::{
|
||||
sync::{Arc, Weak, atomic::Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use axum_server::Handle as ServerHandle;
|
||||
use conduwuit::{Error, Result, Server, debug, debug_error, debug_info, error, info};
|
||||
use futures::FutureExt;
|
||||
use service::Services;
|
||||
use tokio::{
|
||||
sync::broadcast::{self, Sender},
|
||||
task::JoinHandle,
|
||||
};
|
||||
use tuwunel_core::{Error, Result, Server, debug, debug_error, debug_info, error, info};
|
||||
use tuwunel_service::Services;
|
||||
|
||||
use crate::serve;
|
||||
|
||||
@@ -25,7 +21,7 @@ pub(crate) async fn run(services: Arc<Services>) -> Result<()> {
|
||||
debug!("Start");
|
||||
|
||||
// Install the admin room callback here for now
|
||||
admin::init(&services.admin).await;
|
||||
tuwunel_admin::init(&services.admin).await;
|
||||
|
||||
// Setup shutdown/signal handling
|
||||
let handle = ServerHandle::new();
|
||||
@@ -51,7 +47,7 @@ pub(crate) async fn run(services: Arc<Services>) -> Result<()> {
|
||||
_ = sigs.await;
|
||||
|
||||
// Remove the admin room callback
|
||||
admin::fini(&services.admin).await;
|
||||
tuwunel_admin::fini(&services.admin).await;
|
||||
|
||||
debug_info!("Finish");
|
||||
res
|
||||
|
||||
@@ -6,9 +6,9 @@ mod unix;
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum_server::Handle as ServerHandle;
|
||||
use conduwuit::{Result, err};
|
||||
use conduwuit_service::Services;
|
||||
use tokio::sync::broadcast;
|
||||
use tuwunel_core::{Result, err};
|
||||
use tuwunel_service::Services;
|
||||
|
||||
use super::layers;
|
||||
|
||||
@@ -36,9 +36,9 @@ pub(super) async fn serve(
|
||||
return tls::serve(server, app, handle, addrs).await;
|
||||
|
||||
#[cfg(not(feature = "direct_tls"))]
|
||||
return conduwuit::Err!(Config(
|
||||
return tuwunel_core::Err!(Config(
|
||||
"tls",
|
||||
"conduwuit was not built with direct TLS support (\"direct_tls\")"
|
||||
"tuwunel was not built with direct TLS support (\"direct_tls\")"
|
||||
));
|
||||
} else {
|
||||
plain::serve(server, app, handle, addrs).await
|
||||
|
||||
@@ -5,8 +5,8 @@ use std::{
|
||||
|
||||
use axum::Router;
|
||||
use axum_server::{Handle as ServerHandle, bind};
|
||||
use conduwuit::{Result, Server, debug_info, info};
|
||||
use tokio::task::JoinSet;
|
||||
use tuwunel_core::{Result, Server, debug_info, info};
|
||||
|
||||
pub(super) async fn serve(
|
||||
server: &Arc<Server>,
|
||||
|
||||
@@ -6,9 +6,8 @@ use axum_server_dual_protocol::{
|
||||
ServerExt,
|
||||
axum_server::{bind_rustls, tls_rustls::RustlsConfig},
|
||||
};
|
||||
use conduwuit::{Result, Server, err};
|
||||
use tokio::task::JoinSet;
|
||||
use tracing::{debug, info, warn};
|
||||
use tuwunel_core::{Result, Server, debug, err, info, warn};
|
||||
|
||||
pub(super) async fn serve(
|
||||
server: &Arc<Server>,
|
||||
@@ -33,7 +32,7 @@ pub(super) async fn serve(
|
||||
|
||||
info!(
|
||||
"Note: It is strongly recommended that you use a reverse proxy instead of running \
|
||||
conduwuit directly with TLS."
|
||||
tuwunel directly with TLS."
|
||||
);
|
||||
debug!("Using direct TLS. Certificate path {certs} and certificate private key path {key}",);
|
||||
let conf = RustlsConfig::from_pem_file(certs, key)
|
||||
|
||||
@@ -11,9 +11,6 @@ use axum::{
|
||||
Router,
|
||||
extract::{Request, connect_info::IntoMakeServiceWithConnectInfo},
|
||||
};
|
||||
use conduwuit::{
|
||||
Err, Result, Server, debug, debug_error, info, result::UnwrapInfallible, trace, warn,
|
||||
};
|
||||
use hyper::{body::Incoming, service::service_fn};
|
||||
use hyper_util::{
|
||||
rt::{TokioExecutor, TokioIo},
|
||||
@@ -27,6 +24,9 @@ use tokio::{
|
||||
time::{Duration, sleep},
|
||||
};
|
||||
use tower::{Service, ServiceExt};
|
||||
use tuwunel_core::{
|
||||
Err, Result, Server, debug, debug_error, info, result::UnwrapInfallible, trace, warn,
|
||||
};
|
||||
|
||||
type MakeService = IntoMakeServiceWithConnectInfo<Router, net::SocketAddr>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user