Skip to content

Commit 0ddb3b4

Browse files
ernstklAnders Ballegaard
andauthored
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 <[email protected]>
1 parent 353c696 commit 0ddb3b4

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ https://github.com/librespot-org/librespot
5959
- [core] `Credentials.username` is now an `Option` (breaking)
6060
- [core] `Session::connect` tries multiple access points, retrying each one.
6161
- [core] Each access point connection now timesout after 3 seconds.
62+
- [core] Listen on both IPV4 and IPV6 on non-windows hosts
6263
- [main] `autoplay {on|off}` now acts as an override. If unspecified, `librespot`
6364
now follows the setting in the Connect client that controls it. (breaking)
6465
- [metadata] Most metadata is now retrieved with the `spclient` (breaking)

discovery/src/server.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
borrow::Cow,
33
collections::BTreeMap,
44
convert::Infallible,
5-
net::{Ipv4Addr, SocketAddr, TcpListener},
5+
net::{Ipv4Addr, Ipv6Addr, SocketAddr, TcpListener},
66
pin::Pin,
77
sync::{Arc, Mutex},
88
task::{Context, Poll},
@@ -266,7 +266,12 @@ pub struct DiscoveryServer {
266266
impl DiscoveryServer {
267267
pub fn new(config: Config, port: &mut u16) -> Result<Self, Error> {
268268
let (discovery, cred_rx) = RequestHandler::new(config);
269-
let address = SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), *port);
269+
let address = if cfg!(windows) {
270+
SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), *port)
271+
} else {
272+
// this creates a dual stack socket on non-windows systems
273+
SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), *port)
274+
};
270275

271276
let (close_tx, close_rx) = oneshot::channel();
272277

0 commit comments

Comments
 (0)