diff --git a/flake.lock b/flake.lock index 15574f08..ab75aa63 100644 --- a/flake.lock +++ b/flake.lock @@ -30,11 +30,11 @@ ] }, "locked": { - "lastModified": 1736429655, - "narHash": "sha256-BwMekRuVlSB9C0QgwKMICiJ5EVbLGjfe4qyueyNQyGI=", + "lastModified": 1751923969, + "narHash": "sha256-QNo234SxSB2lLavaT2d+g+Z2WB7o7w29vYkM6zfRLi4=", "owner": "nix-community", "repo": "naersk", - "rev": "0621e47bd95542b8e1ce2ee2d65d6a1f887a13ce", + "rev": "0473954e399eec0081ee816f3430c17d1f7e5a42", "type": "github" }, "original": { @@ -45,16 +45,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1736754065, - "narHash": "sha256-hcETjfECLklW1ND8svDvN0Nw6H/1qtuoz3rbFNQ1Lrk=", + "lastModified": 1751741127, + "narHash": "sha256-t75Shs76NgxjZSgvvZZ9qOmz5zuBE8buUaYD28BMTxg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "67e9c880898889470f153157a96b595e758167fc", + "rev": "29e290002bfff26af1db6f64d070698019460302", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.11", + "ref": "nixos-25.05", "repo": "nixpkgs", "type": "github" } @@ -75,11 +75,11 @@ ] }, "locked": { - "lastModified": 1736735482, - "narHash": "sha256-QOA4jCDyyUM9Y2Vba+HSZ/5LdtCMGaTE/7NkkUzBr50=", + "lastModified": 1751942411, + "narHash": "sha256-01uMHCt2U9tP4f24DGch145tT8YQppLY5TC9mWK7O0A=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "cf960a1938ee91200fe0d2f7b2582fde2429d562", + "rev": "c587235f892930a61c9e415f0d9792a1b27a41a2", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index aad93995..47676181 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; utils.url = "github:numtide/flake-utils"; naersk.url = "github:nix-community/naersk"; naersk.inputs.nixpkgs.follows = "nixpkgs"; diff --git a/src/config.rs b/src/config.rs index 00fa4107..04032ddb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -150,7 +150,7 @@ impl Debug for Bind { Bind::Unix(path, permissions) => f .debug_tuple("Unix") .field(path) - .field(&format!("0{:0}", permissions)) + .field(&format!("0{permissions:0}")) .finish(), } } diff --git a/src/connection.rs b/src/connection.rs index 43a5805f..988b3514 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -57,7 +57,7 @@ impl ActiveConnections { pub fn remove(&self, user: &UserId) { if let Entry::Occupied(e) = self.0.entry(user.clone()) { if e.get().receiver_count() == 1 { - log::debug!("Removing {} from active connections", user); + log::debug!("Removing {user} from active connections"); METRICS.remove_user(); e.remove(); } @@ -96,8 +96,8 @@ pub async fn handle_user_socket( { Ok(Ok(user_id)) => user_id, Ok(Err(e)) => { - log::warn!("{}", e); - ws.send(Message::text(format!("err: {}", e))).await.ok(); + log::warn!("{e:#}"); + ws.send(Message::text(format!("err: {e:#}"))).await.ok(); return; } Err(_) => { @@ -108,7 +108,7 @@ pub async fn handle_user_socket( } }; - log::info!("new websocket authenticated as {}", user_id); + log::info!("new websocket authenticated as {user_id}"); ws.send(Message::text("authenticated")).await.ok(); let mut rx = match app.connections.add(user_id.clone()) { @@ -149,7 +149,7 @@ pub async fn handle_user_socket( match msg { Ok(Ok(msg)) => { if let Some(msg) = send_queue.push(msg, now) { - log::debug!(target: "notify_push::send", "Sending {} to {}", msg, user_id); + log::debug!(target: "notify_push::send", "Sending {msg} to {user_id}"); METRICS.add_message(msg.message_type()); last_send = now; user_ws_tx.send(msg.into_message(&opts)).await.ok(); @@ -165,7 +165,7 @@ pub async fn handle_user_socket( for msg in send_queue.drain(now, METRICS.active_connection_count() + 50000, opts.max_debounce_time) { last_send = now; METRICS.add_message(msg.message_type()); - log::debug!(target: "notify_push::send", "Sending debounced {} to {}", msg, user_id); + log::debug!(target: "notify_push::send", "Sending debounced {msg} to {user_id}"); user_ws_tx.feed(msg.into_message(&opts)).await.ok(); } @@ -173,10 +173,10 @@ pub async fn handle_user_socket( let data = rng.gen::().into(); let last_ping = expect_pong.swap(data, Ordering::SeqCst); if last_ping > 0 { - log::info!("{} didn't reply to ping, closing", user_id); + log::info!("{user_id} didn't reply to ping, closing"); break; } - log::debug!(target: "notify_push::send", "Sending ping to {}", user_id); + log::debug!(target: "notify_push::send", "Sending ping to {user_id}"); last_send = now; user_ws_tx .feed(Message::ping(data.to_le_bytes())) @@ -223,9 +223,9 @@ pub async fn handle_user_socket( match formatted.as_str() { "WebSocket protocol error: Connection reset without closing handshake" | "IO error: Connection reset by peer (os error 104)" => { - log::debug!("websocket error: {}", e) + log::debug!("websocket error: {e:#}") } - _ => log::warn!("websocket error: {}", e), + _ => log::warn!("websocket error: {e:#}"), }; break; } @@ -269,10 +269,7 @@ async fn socket_auth( app.pre_auth.retain(|_, (time, _)| *time > cutoff); if let Some((_, (_, user))) = app.pre_auth.remove(password) { - log::debug!( - "Authenticated socket for {} using pre authenticated token", - user - ); + log::debug!("Authenticated socket for {user} using pre authenticated token"); return Ok(user); } diff --git a/src/lib.rs b/src/lib.rs index 49f17578..89fc8b38 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,7 @@ impl App { .send_to_user(&user, PushMessage::File(file_id.into())); } } - Err(e) => log::error!("{:#}", e), + Err(e) => log::error!("{e:#}"), } } Event::GroupUpdate(GroupUpdate { user, .. }) => { @@ -196,8 +196,8 @@ impl App { } Event::Config(event::Config::LogSpec(spec)) => { match self.log_handle.lock().await.parse_and_push_temp_spec(&spec) { - Ok(()) => log::info!("Set log level to {}", spec), - Err(e) => log::error!("Failed to set log level: {:?}", e), + Ok(()) => log::info!("Set log level to {spec}"), + Err(e) => log::error!("Failed to set log level: {e:#}"), } } Event::Config(event::Config::LogRestore) => { @@ -213,15 +213,15 @@ impl App { ) .await { - log::warn!("Failed to set metrics: {}", e); + log::warn!("Failed to set metrics: {e:#}"); } } - Err(e) => log::warn!("Failed to set metrics: {}", e), + Err(e) => log::warn!("Failed to set metrics: {e:#}"), }, Event::Signal(event::Signal::Reset) => { log::info!("Stopping all open connections"); if let Err(e) = self.reset_tx.send(()) { - log::warn!("Failed to send reset command to all connections: {}", e); + log::warn!("Failed to send reset command to all connections: {e:#}"); } } } @@ -270,7 +270,7 @@ pub fn serve( .and(app.clone()) .map(|app: Arc| { let cookie = app.test_cookie.load(Ordering::SeqCst); - log::debug!("current test cookie is {}", cookie); + log::debug!("current test cookie is {cookie}"); cookie.to_string() }); @@ -279,12 +279,12 @@ pub fn serve( .and_then(|app: Arc| async move { let response = match app.nc_client.get_test_cookie().await { Ok(cookie) => { - log::debug!("got remote test cookie {}", cookie); + log::debug!("got remote test cookie {cookie}"); cookie.to_string() } Err(e) => { - log::warn!("Error while trying to get cookie from Nextcloud {:#}", e); - format!("{:#}", e) + log::warn!("Error while trying to get cookie from Nextcloud {e:#}"); + format!("{e:#}") } }; @@ -300,16 +300,11 @@ pub fn serve( .await .map(|access| { let count = access.count(); - log::debug!("storage mapping count for {} = {}", storage_id, count); + log::debug!("storage mapping count for {storage_id} = {count}"); count }) - .map_err(|err| { - log::error!( - "error while getting mapping count for {}: {:#}", - storage_id, - err - ); - err + .inspect_err(|err| { + log::error!("error while getting mapping count for {storage_id}: {err:#}"); }) .unwrap_or(0); Result::<_, Infallible>::Ok(access.to_string()) @@ -324,7 +319,7 @@ pub fn serve( .await .map(|remote| remote.to_string()) .unwrap_or_else(|e| e.to_string()); - log::debug!("got remote {} when trying to set remote {}", result, remote); + log::debug!("got remote {result} when trying to set remote {remote}"); Result::<_, Infallible>::Ok(result) }); @@ -341,7 +336,7 @@ pub fn serve( "set" } Err(e) => { - log::warn!("Failed to get redis connection for version set: {:#}", e); + log::warn!("Failed to get redis connection for version set: {e:#}"); "error" } }) @@ -412,7 +407,7 @@ pub async fn listen_loop(app: Arc, cancel: oneshot::Receiver<()>) { let loop_ = async move { loop { if let Err(e) = listen(app.clone()).await { - log::error!("Failed to setup redis subscription: {:#}", e); + log::error!("Failed to setup redis subscription: {e:#}"); } log::warn!("Redis server disconnected, reconnecting in 1s"); sleep(Duration::from_secs(1)).await; @@ -438,12 +433,11 @@ pub async fn listen(app: Arc) -> Result<()> { Ok(event) => { log::debug!( target: "notify_push::receive", - "Received {}", - event + "Received {event}" ); tokio::spawn(handle(event)); } - Err(e) => log::warn!("{:#}", e), + Err(e) => log::warn!("{e:#}"), } } Ok(()) diff --git a/src/main.rs b/src/main.rs index 7d95871b..669d7388 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,7 @@ fn main() -> Result<()> { let config = Config::from_opt(opt)?; if dump_config { - println!("{:#?}", config); + println!("{config:#?}"); return Ok(()); } @@ -64,7 +64,7 @@ async fn run(config: Config, log_handle: LoggerHandle) -> Result<()> { let (metrics_cancel, metrics_cancel_handle) = oneshot::channel(); let (listen_cancel, listen_cancel_handle) = oneshot::channel(); - log::trace!("Running with config: {:?}", config); + log::trace!("Running with config: {config:?}"); if config.allow_self_signed { log::info!("Running with certificate validation disabled"); @@ -81,10 +81,10 @@ async fn run(config: Config, log_handle: LoggerHandle) -> Result<()> { let max_connection_time = config.max_connection_time; let app = Arc::new(App::new(config, log_handle).await?); if let Err(e) = app.self_test().await { - log::error!("Self test failed: {:#}", e); + log::error!("Self test failed: {e:#}"); } - log::trace!("Listening on {}", bind); + log::trace!("Listening on {bind}"); let server = spawn(serve( app.clone(), bind, @@ -95,7 +95,7 @@ async fn run(config: Config, log_handle: LoggerHandle) -> Result<()> { )?); if let Some(metrics_bind) = metrics_bind { - log::trace!("Metrics listening {}", metrics_bind); + log::trace!("Metrics listening {metrics_bind}"); spawn(serve_metrics( metrics_bind, metrics_cancel_handle, diff --git a/src/message.rs b/src/message.rs index e8caadbf..25cbd911 100644 --- a/src/message.rs +++ b/src/message.rs @@ -89,7 +89,7 @@ impl PushMessage { ty } else { let mut str = ty; - write!(&mut str, " {}", body).ok(); + write!(&mut str, " {body}").ok(); str } }), diff --git a/src/nc.rs b/src/nc.rs index 08fea03c..30337d87 100644 --- a/src/nc.rs +++ b/src/nc.rs @@ -32,7 +32,7 @@ impl Client { password: &str, forwarded_for: Vec, ) -> Result { - log::debug!("Verifying credentials for {}", username); + log::debug!("Verifying credentials for {username}"); let response = self.auth_request(username, password, forwarded_for).await?; match response.status() { @@ -65,7 +65,7 @@ impl Client { if !joined.is_empty() { write!(&mut joined, ", ").ok(); } - write!(&mut joined, "{}", ip).ok(); + write!(&mut joined, "{ip}").ok(); joined }, ), diff --git a/src/storage_mapping.rs b/src/storage_mapping.rs index 9e49d772..c094e565 100644 --- a/src/storage_mapping.rs +++ b/src/storage_mapping.rs @@ -105,7 +105,7 @@ impl StorageMapping { &self, storage: u32, ) -> Result, DatabaseError> { - debug!("querying storage mapping for {}", storage); + debug!("querying storage mapping for {storage}"); let users = query_as::(&format!( "\ SELECT user_id, path \ @@ -120,7 +120,7 @@ impl StorageMapping { .map_err(DatabaseError::Query)?; METRICS.add_mapping_query(); - debug!("got storage mappings for {}: {:?}", storage, users); + debug!("got storage mappings for {storage}: {users:?}"); Ok(users) } diff --git a/test_client/src/main.rs b/test_client/src/main.rs index 62cecfbe..2396eb54 100644 --- a/test_client/src/main.rs +++ b/test_client/src/main.rs @@ -26,7 +26,7 @@ fn main() -> Result<()> { let (nc_url, username, password) = match (args.next(), args.next(), args.next()) { (Some(host), Some(username), Some(password)) => (host, username, password), _ => { - eprintln!("usage {} ", bin); + eprintln!("usage {bin} "); return Ok(()); } }; @@ -36,7 +36,7 @@ fn main() -> Result<()> { } else { get_endpoint(&nc_url, &username, &password)? }; - info!("Found push server at {}", ws_url); + info!("Found push server at {ws_url}"); let ws_url = Url::parse(&ws_url) .into_diagnostic() @@ -61,10 +61,10 @@ fn main() -> Result<()> { loop { if let Message::Text(text) = socket.read().into_diagnostic()? { if let Some(err) = text.strip_prefix("err: ") { - warn!("Received error: {}", err); + warn!("Received error: {err}"); return Ok(()); } else if text.starts_with("notify_file") { - info!("Received file update notification {}", text); + info!("Received file update notification {text}"); } else if text == "notify_activity" { info!("Received activity notification"); } else if text == "notify_notification" { @@ -72,19 +72,19 @@ fn main() -> Result<()> { } else if text == "authenticated" { info!("Authenticated"); } else { - info!("Received: {}", text); + info!("Received: {text}"); } } } } fn get_endpoint(nc_url: &str, user: &str, password: &str) -> Result { - let raw = ureq::get(&format!("{}/ocs/v2.php/cloud/capabilities", nc_url)) + let raw = ureq::get(&format!("{nc_url}/ocs/v2.php/cloud/capabilities")) .set( "Authorization", &format!( "Basic {}", - base64::engine::general_purpose::STANDARD.encode(format!("{}:{}", user, password)) + base64::engine::general_purpose::STANDARD.encode(format!("{user}:{password}")) ), ) .set("Accept", "application/json") @@ -93,10 +93,10 @@ fn get_endpoint(nc_url: &str, user: &str, password: &str) -> Result { .into_diagnostic()? .into_string() .into_diagnostic()?; - trace!("Capabilities response: {}", raw); + trace!("Capabilities response: {raw}"); let json: Value = serde_json::from_str(&raw) .into_diagnostic() - .wrap_err_with(|| format!("Failed to decode json capabilities response: {}", raw))?; + .wrap_err_with(|| format!("Failed to decode json capabilities response: {raw}"))?; if let Some(capabilities) = json["ocs"]["data"]["capabilities"].as_object() { debug!( "Supported capabilities: {:?}", @@ -116,8 +116,7 @@ fn get_endpoint(nc_url: &str, user: &str, password: &str) -> Result { } } else { Err(Report::msg(format!( - "invalid capabilities response: {}", - json + "invalid capabilities response: {json}" ))) } }