Skip to content

Commit 426847c

Browse files
authored
Provide an IPv4-only default socket for mdns (#51)
And mention that dual-stack and single-stack implementations exist
1 parent 2924d35 commit 426847c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

edge-mdns/src/io.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,19 @@ use log::{debug, warn};
2020

2121
use super::*;
2222

23-
/// A quick-and-dirty socket address that binds to a "default" interface.
23+
/// Socket address that binds to any IPv4-configured interface available
24+
pub const IPV4_DEFAULT_SOCKET: SocketAddr =
25+
SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), PORT);
26+
27+
/// Socket address that binds to any IPv6-configured interface available on single-stack
28+
/// implementations and to any configured interface available on dual-stack implementations.
29+
pub const IPV6_DEFAULT_SOCKET: SocketAddr =
30+
SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), PORT);
31+
32+
/// A quick-and-dirty socket address that binds to any interface available on dual-stack
33+
/// implementations.
2434
/// Don't use in production code.
25-
pub const DEFAULT_SOCKET: SocketAddr = SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), PORT);
35+
pub const DEFAULT_SOCKET: SocketAddr = IPV6_DEFAULT_SOCKET;
2636

2737
/// The IPv4 mDNS broadcast address, as per spec.
2838
pub const IP_BROADCAST_ADDR: Ipv4Addr = Ipv4Addr::new(224, 0, 0, 251);

0 commit comments

Comments
 (0)