diff options
author | Tim Harvey <tharvey@gateworks.com> | 2025-05-30 08:38:26 -0700 |
---|---|---|
committer | Jerome Forissier <jerome.forissier@linaro.org> | 2025-07-08 11:07:37 +0200 |
commit | d373436f50bb5f8ec3c3301532b92d2408bdc429 (patch) | |
tree | 78c36fb2f144b4468868b75c89e30f8b34620f94 | |
parent | a383869d6b58b3d66a91460a8b1a6fdcc09a1fe9 (diff) |
net: lwip: wget: initialize dns if a hostname is used in a URL
Initialize dns servers if a hostname (vs ipaddr) is used in a URL.
Otherwise the wget will fail without displaying an error due to
dns_gethostbyname failing silently when no DNS servers are set unless
you have previously performed a 'dns <arg>' command.
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
-rw-r--r-- | net/lwip/wget.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/lwip/wget.c b/net/lwip/wget.c index 3c39a1b59a6..f9af2fc0d2b 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -461,6 +461,10 @@ int wget_do_request(ulong dst_addr, char *uri) if (!netif) return -1; + /* if URL with hostname init dns */ + if (!ipaddr_aton(ctx.server_name, NULL) && net_lwip_dns_init()) + return CMD_RET_FAILURE; + memset(&conn, 0, sizeof(conn)); #if CONFIG_IS_ENABLED(WGET_HTTPS) if (is_https) { |