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 <giithub@anderstb.dk>
This commit is contained in:
Ernst 2024-10-06 22:11:57 +02:00 committed by GitHub
parent 353c696554
commit 0ddb3b4cb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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<Self, Error> {
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();