Skip to content

Commit 1c9f096

Browse files
authored
Merge pull request nextcloud#687 from nextcloud/ipv6-bind
Bind to ipv6 dual stack by default
2 parents d98ee9e + 9484005 commit 1c9f096

5 files changed

Lines changed: 14 additions & 15 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ rand = { version = "0.8.5", features = ["small_rng"] }
2929
ahash = "0.8.12"
3030
flexi_logger = { version = "0.31.8", features = ["colors"] }
3131
tokio-stream = { version = "0.1.17", features = ["net"] }
32-
nextcloud-config-parser = "0.15.1"
32+
nextcloud-config-parser = "0.15.2"
3333
url = "2.5.4"
3434
clap = { version = "4.5.43", features = ["derive"] }
3535
sd-notify = { version = "0.5.0", optional = true }

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
};
2828
lib = pkgs.lib;
2929

30-
hostTarget = pkgs.hostPlatform.config;
30+
hostTarget = pkgs.stdenv.hostPlatform.config;
3131
targets = [
3232
"x86_64-unknown-linux-musl"
3333
"i686-unknown-linux-musl"

src/config.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use sqlx::any::AnyConnectOptions;
2020
use std::convert::{TryFrom, TryInto};
2121
use std::env::var;
2222
use std::fmt::{Debug, Display, Formatter};
23-
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
23+
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
2424
use std::path::{Path, PathBuf};
2525
use std::str::FromStr;
2626

@@ -183,9 +183,7 @@ impl TryFrom<PartialConfig> for Config {
183183
let bind = match config.socket {
184184
Some(socket) => Bind::Unix(socket, socket_permissions),
185185
None => {
186-
let ip = config
187-
.bind
188-
.unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)));
186+
let ip = config.bind.unwrap_or(IpAddr::V6(Ipv6Addr::UNSPECIFIED));
189187
let port = config.port.unwrap_or(7867);
190188
Bind::Tcp((ip, port).into())
191189
}
@@ -194,9 +192,7 @@ impl TryFrom<PartialConfig> for Config {
194192
let metrics_bind = match (config.metrics_socket, config.metrics_port) {
195193
(Some(socket), _) => Some(Bind::Unix(socket, socket_permissions)),
196194
(None, Some(port)) => {
197-
let ip = config
198-
.bind
199-
.unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)));
195+
let ip = config.bind.unwrap_or(IpAddr::V6(Ipv6Addr::UNSPECIFIED));
200196
Some(Bind::Tcp((ip, port).into()))
201197
}
202198
_ => None,

src/connection.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ pub async fn handle_user_socket(
226226
// hack while warp only has opaque error types
227227
match formatted.as_str() {
228228
"WebSocket protocol error: Connection reset without closing handshake"
229+
| "Broken pipe (os error 32)"
229230
| "IO error: Connection reset by peer (os error 104)" => {
230231
log::debug!("websocket error: {e:#}")
231232
}
@@ -262,11 +263,13 @@ async fn socket_auth(
262263
let username_msg = read_socket_auth_message(rx).await?;
263264
let username = username_msg
264265
.to_str()
265-
.map_err(|_| AuthenticationError::InvalidMessage)?;
266+
.map_err(|_| AuthenticationError::InvalidMessage)?
267+
.trim();
266268
let password_msg = read_socket_auth_message(rx).await?;
267269
let password = password_msg
268270
.to_str()
269-
.map_err(|_| AuthenticationError::InvalidMessage)?;
271+
.map_err(|_| AuthenticationError::InvalidMessage)?
272+
.trim();
270273

271274
// cleanup all pre_auth tokens older than 15s
272275
let cutoff = Instant::now() - Duration::from_secs(15);

0 commit comments

Comments
 (0)