diff --git a/Cargo.lock b/Cargo.lock index 8dcc5c8..fea0764 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1520,9 +1520,9 @@ dependencies = [ [[package]] name = "nextcloud-config-parser" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a63b1374e3d837e53a783c0704013728ef392899f131b389cdda0ef922b945" +checksum = "7a285761c91b18426c4cadf66ffb77f8881ea5cb417d94bad384bcf85a9965de" dependencies = [ "form_urlencoded", "indexmap", diff --git a/Cargo.toml b/Cargo.toml index 8b88421..61c273f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ rand = { version = "0.8.5", features = ["small_rng"] } ahash = "0.8.12" flexi_logger = { version = "0.29.8", features = ["colors"] } tokio-stream = { version = "0.1.17", features = ["net"] } -nextcloud-config-parser = "0.15.1" +nextcloud-config-parser = "0.15.2" url = "2.5.4" clap = { version = "4.5.43", features = ["derive"] } sd-notify = { version = "0.4.5", optional = true } diff --git a/flake.nix b/flake.nix index a8304dd..4490d44 100644 --- a/flake.nix +++ b/flake.nix @@ -27,7 +27,7 @@ }; lib = pkgs.lib; - hostTarget = pkgs.hostPlatform.config; + hostTarget = pkgs.stdenv.hostPlatform.config; targets = [ "x86_64-unknown-linux-musl" "i686-unknown-linux-musl" diff --git a/src/config.rs b/src/config.rs index e380195..d3862eb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,7 +20,7 @@ use sqlx::any::AnyConnectOptions; use std::convert::{TryFrom, TryInto}; use std::env::var; use std::fmt::{Debug, Display, Formatter}; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use std::net::{IpAddr, Ipv6Addr, SocketAddr}; use std::path::{Path, PathBuf}; use std::str::FromStr; @@ -183,9 +183,7 @@ impl TryFrom for Config { let bind = match config.socket { Some(socket) => Bind::Unix(socket, socket_permissions), None => { - let ip = config - .bind - .unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + let ip = config.bind.unwrap_or(IpAddr::V6(Ipv6Addr::UNSPECIFIED)); let port = config.port.unwrap_or(7867); Bind::Tcp((ip, port).into()) } @@ -194,9 +192,7 @@ impl TryFrom for Config { let metrics_bind = match (config.metrics_socket, config.metrics_port) { (Some(socket), _) => Some(Bind::Unix(socket, socket_permissions)), (None, Some(port)) => { - let ip = config - .bind - .unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))); + let ip = config.bind.unwrap_or(IpAddr::V6(Ipv6Addr::UNSPECIFIED)); Some(Bind::Tcp((ip, port).into())) } _ => None, diff --git a/src/connection.rs b/src/connection.rs index e4cf55a..2d458e9 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -226,6 +226,7 @@ pub async fn handle_user_socket( // hack while warp only has opaque error types match formatted.as_str() { "WebSocket protocol error: Connection reset without closing handshake" + | "Broken pipe (os error 32)" | "IO error: Connection reset by peer (os error 104)" => { log::debug!("websocket error: {e:#}") } @@ -262,11 +263,13 @@ async fn socket_auth( let username_msg = read_socket_auth_message(rx).await?; let username = username_msg .to_str() - .map_err(|_| AuthenticationError::InvalidMessage)?; + .map_err(|_| AuthenticationError::InvalidMessage)? + .trim(); let password_msg = read_socket_auth_message(rx).await?; let password = password_msg .to_str() - .map_err(|_| AuthenticationError::InvalidMessage)?; + .map_err(|_| AuthenticationError::InvalidMessage)? + .trim(); // cleanup all pre_auth tokens older than 15s let cutoff = Instant::now() - Duration::from_secs(15);