Skip to content

Commit d61eb6e

Browse files
committed
network: read the documented host key for the mdns config
mdns_config() documents {host, ...} but maybe_start_mdns read the `hostname` key, so a spec-conforming config handed mdns:init an undefined hostname and it crashed on iolist_to_binary/1. Accept both, preferring the documented key. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent f7594af commit d61eb6e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8282
- Fixed ESP32 socket driver holding the global socket-list lock across blocking TCP connects, leaking the port on connect failure, losing concurrent `accept` waiters, leaking `netbuf` on receive error paths, and a recycled-`netconn` race between socket close and the event handler
8383
- Fixed generic_unix TCP server sockets performing an abortive close that could truncate replies awaiting ack
8484
- Fixed a JIT crash (`EXC_BAD_ACCESS`/SIGBUS) on Apple Silicon
85+
- Fixed the `network` mdns configuration to read the documented `host` key; the previously
86+
required, undocumented `hostname` key is still accepted
8587

8688
## [0.7.0-alpha.1] - 2026-04-06
8789

libs/avm_network/src/network.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,15 @@ maybe_start_mdns(#state{config = Config, sta_ip_info = {InterfaceAddr, _, _}} =
988988
undefined ->
989989
State;
990990
MDNSConfig ->
991+
% The documented config key is `host` (see mdns_hostname_config());
992+
% `hostname` is accepted too for compatibility with older code.
993+
Hostname =
994+
case proplists:get_value(host, MDNSConfig) of
995+
undefined -> proplists:get_value(hostname, MDNSConfig);
996+
Host -> Host
997+
end,
991998
MDNSMap0 = #{
992-
hostname => proplists:get_value(hostname, MDNSConfig), interface => InterfaceAddr
999+
hostname => Hostname, interface => InterfaceAddr
9931000
},
9941001
MDNSMap1 =
9951002
case proplists:get_value(ttl, MDNSConfig) of

0 commit comments

Comments
 (0)