apply new rustfmt.toml changes, fix some clippy lints

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-12-15 00:05:47 -05:00
parent 0317cc8cc5
commit 77e0b76408
No known key found for this signature in database
296 changed files with 7147 additions and 4300 deletions

View file

@ -14,7 +14,9 @@ use super::layers;
/// Serve clients
pub(super) async fn serve(
services: Arc<Services>, handle: ServerHandle, shutdown: broadcast::Receiver<()>,
services: Arc<Services>,
handle: ServerHandle,
shutdown: broadcast::Receiver<()>,
) -> Result<()> {
let server = &services.server;
let config = &server.config;

View file

@ -9,12 +9,16 @@ use conduwuit::{debug_info, info, Result, Server};
use tokio::task::JoinSet;
pub(super) async fn serve(
server: &Arc<Server>, app: Router, handle: ServerHandle, addrs: Vec<SocketAddr>,
server: &Arc<Server>,
app: Router,
handle: ServerHandle,
addrs: Vec<SocketAddr>,
) -> Result<()> {
let app = app.into_make_service_with_connect_info::<SocketAddr>();
let mut join_set = JoinSet::new();
for addr in &addrs {
join_set.spawn_on(bind(*addr).handle(handle.clone()).serve(app.clone()), server.runtime());
join_set
.spawn_on(bind(*addr).handle(handle.clone()).serve(app.clone()), server.runtime());
}
info!("Listening on {addrs:?}");

View file

@ -10,7 +10,12 @@ use conduwuit::{err, Result, Server};
use tokio::task::JoinSet;
use tracing::{debug, info, warn};
pub(super) async fn serve(server: &Arc<Server>, app: Router, handle: ServerHandle, addrs: Vec<SocketAddr>) -> Result {
pub(super) async fn serve(
server: &Arc<Server>,
app: Router,
handle: ServerHandle,
addrs: Vec<SocketAddr>,
) -> Result {
let tls = &server.config.tls;
let certs = tls
.certs
@ -29,7 +34,8 @@ pub(super) async fn serve(server: &Arc<Server>, app: Router, handle: ServerHandl
debug!("Using direct TLS. Certificate path {certs} and certificate private key path {key}",);
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(certs, key).await?;
@ -58,8 +64,8 @@ pub(super) async fn serve(server: &Arc<Server>, app: Router, handle: ServerHandl
if tls.dual_protocol {
warn!(
"Listening on {addrs:?} with TLS certificate {certs} and supporting plain text (HTTP) connections too \
(insecure!)",
"Listening on {addrs:?} with TLS certificate {certs} and supporting plain text \
(HTTP) connections too (insecure!)",
);
} else {
info!("Listening on {addrs:?} with TLS certificate {certs}");

View file

@ -10,7 +10,9 @@ use axum::{
extract::{connect_info::IntoMakeServiceWithConnectInfo, Request},
Router,
};
use conduwuit::{debug, debug_error, info, result::UnwrapInfallible, trace, warn, Err, Result, Server};
use conduwuit::{
debug, debug_error, info, result::UnwrapInfallible, trace, warn, Err, Result, Server,
};
use hyper::{body::Incoming, service::service_fn};
use hyper_util::{
rt::{TokioExecutor, TokioIo},
@ -31,7 +33,11 @@ const NULL_ADDR: net::SocketAddr = net::SocketAddr::new(IpAddr::V4(Ipv4Addr::new
const FINI_POLL_INTERVAL: Duration = Duration::from_millis(750);
#[tracing::instrument(skip_all, level = "debug")]
pub(super) async fn serve(server: &Arc<Server>, app: Router, mut shutdown: broadcast::Receiver<()>) -> Result<()> {
pub(super) async fn serve(
server: &Arc<Server>,
app: Router,
mut shutdown: broadcast::Receiver<()>,
) -> Result<()> {
let mut tasks = JoinSet::<()>::new();
let executor = TokioExecutor::new();
let app = app.into_make_service_with_connect_info::<net::SocketAddr>();
@ -55,8 +61,12 @@ pub(super) async fn serve(server: &Arc<Server>, app: Router, mut shutdown: broad
}
async fn accept(
server: &Arc<Server>, listener: &UnixListener, tasks: &mut JoinSet<()>, mut app: MakeService,
builder: server::conn::auto::Builder<TokioExecutor>, conn: (UnixStream, SocketAddr),
server: &Arc<Server>,
listener: &UnixListener,
tasks: &mut JoinSet<()>,
mut app: MakeService,
builder: server::conn::auto::Builder<TokioExecutor>,
conn: (UnixStream, SocketAddr),
) {
let (socket, remote) = conn;
let socket = TokioIo::new(socket);
@ -103,7 +113,8 @@ async fn init(server: &Arc<Server>) -> Result<UnixListener> {
}
let socket_perms = config.unix_socket_perms.to_string();
let octal_perms = u32::from_str_radix(&socket_perms, 8).expect("failed to convert octal permissions");
let octal_perms =
u32::from_str_radix(&socket_perms, 8).expect("failed to convert octal permissions");
let perms = std::fs::Permissions::from_mode(octal_perms);
if let Err(e) = fs::set_permissions(&path, perms).await {
return Err!("Failed to set socket {path:?} permissions: {e}");