Skip to content

Commit 1dc4dff

Browse files
committed
fix: with the unspecified address, show all interface addresses
1 parent 85d378a commit 1dc4dff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/serve/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,11 @@ impl ServeSystem {
158158
fn show_listening(cfg: &RtcServe, addr: &[SocketAddr], base: &str) {
159159
let prefix = if cfg.tls.is_some() { "https" } else { "http" };
160160

161-
// prepare local addresses
162-
let locals = local_ip_address::list_afinet_netifas()
161+
// prepare interface addresses
162+
let interfaces = local_ip_address::list_afinet_netifas()
163163
.map(|addr| {
164164
addr.into_iter()
165165
.map(|(_name, addr)| addr)
166-
.filter(|addr| addr.is_loopback())
167166
.collect::<Vec<_>>()
168167
})
169168
.unwrap_or(vec![IpAddr::V4(Ipv4Addr::LOCALHOST)]);
@@ -173,7 +172,8 @@ fn show_listening(cfg: &RtcServe, addr: &[SocketAddr], base: &str) {
173172

174173
for addr in addr {
175174
if addr.ip().is_unspecified() {
176-
addresses.extend(locals.iter().filter_map(|ipaddr| match ipaddr {
175+
// it the "unspecified" address, so we add the corresponding address family addresses
176+
addresses.extend(interfaces.iter().filter_map(|ipaddr| match ipaddr {
177177
IpAddr::V4(_ip) if addr.is_ipv4() => Some(SocketAddr::new(*ipaddr, addr.port())),
178178
IpAddr::V6(_ip) if addr.is_ipv6() => Some(SocketAddr::new(*ipaddr, addr.port())),
179179
_ => None,

0 commit comments

Comments
 (0)