Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down
25 changes: 11 additions & 14 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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(_) => {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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();
Expand All @@ -165,18 +165,18 @@ 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();
}

if now.duration_since(last_send) > PING_INTERVAL {
let data = rng.gen::<NonZeroUsize>().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()))
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
42 changes: 18 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. }) => {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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:#}");
}
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ pub fn serve(
.and(app.clone())
.map(|app: Arc<App>| {
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()
});

Expand All @@ -279,12 +279,12 @@ pub fn serve(
.and_then(|app: Arc<App>| 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:#}")
}
};

Expand All @@ -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())
Expand All @@ -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)
});

Expand All @@ -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"
}
})
Expand Down Expand Up @@ -412,7 +407,7 @@ pub async fn listen_loop(app: Arc<App>, 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;
Expand All @@ -438,12 +433,11 @@ pub async fn listen(app: Arc<App>) -> 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(())
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() -> Result<()> {
let config = Config::from_opt(opt)?;

if dump_config {
println!("{:#?}", config);
println!("{config:#?}");
return Ok(());
}

Expand Down Expand Up @@ -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");
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl PushMessage {
ty
} else {
let mut str = ty;
write!(&mut str, " {}", body).ok();
write!(&mut str, " {body}").ok();
str
}
}),
Expand Down
4 changes: 2 additions & 2 deletions src/nc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Client {
password: &str,
forwarded_for: Vec<IpAddr>,
) -> Result<UserId, AuthenticationError> {
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() {
Expand Down Expand Up @@ -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
},
),
Expand Down
4 changes: 2 additions & 2 deletions src/storage_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl StorageMapping {
&self,
storage: u32,
) -> Result<Vec<UserStorageAccess>, DatabaseError> {
debug!("querying storage mapping for {}", storage);
debug!("querying storage mapping for {storage}");
let users = query_as::<Any, UserStorageAccess>(&format!(
"\
SELECT user_id, path \
Expand All @@ -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)
}
Expand Down
Loading