From 0ddb3b4cb6971aa0f90c5ea62a2050faa35e5e83 Mon Sep 17 00:00:00 2001 From: Ernst Date: Sun, 6 Oct 2024 22:11:57 +0200 Subject: [PATCH] Exposing service to both IPv4 and IPv6, addressing remaining issues from # (#1366) * create dual stack socket on non-windows systems only --------- Co-authored-by: Anders Ballegaard --- CHANGELOG.md | 1 + discovery/src/server.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fb79f05..494c0e85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ https://github.com/librespot-org/librespot - [core] `Credentials.username` is now an `Option` (breaking) - [core] `Session::connect` tries multiple access points, retrying each one. - [core] Each access point connection now timesout after 3 seconds. +- [core] Listen on both IPV4 and IPV6 on non-windows hosts - [main] `autoplay {on|off}` now acts as an override. If unspecified, `librespot` now follows the setting in the Connect client that controls it. (breaking) - [metadata] Most metadata is now retrieved with the `spclient` (breaking) diff --git a/discovery/src/server.rs b/discovery/src/server.rs index 0e235f77..f3c979b9 100644 --- a/discovery/src/server.rs +++ b/discovery/src/server.rs @@ -2,7 +2,7 @@ use std::{ borrow::Cow, collections::BTreeMap, convert::Infallible, - net::{Ipv4Addr, SocketAddr, TcpListener}, + net::{Ipv4Addr, Ipv6Addr, SocketAddr, TcpListener}, pin::Pin, sync::{Arc, Mutex}, task::{Context, Poll}, @@ -266,7 +266,12 @@ pub struct DiscoveryServer { impl DiscoveryServer { pub fn new(config: Config, port: &mut u16) -> Result { let (discovery, cred_rx) = RequestHandler::new(config); - let address = SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), *port); + let address = if cfg!(windows) { + SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), *port) + } else { + // this creates a dual stack socket on non-windows systems + SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), *port) + }; let (close_tx, close_rx) = oneshot::channel();