Skip to content

Commit 2f5ec1c

Browse files
authored
Merge pull request #7281 from jepler/esp32-trailing-dot
handle domain with trailing dot
2 parents c8390a7 + 286efc1 commit 2f5ec1c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ports/espressif/common-hal/socketpool/SocketPool.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ void common_hal_socketpool_socketpool_construct(socketpool_socketpool_obj_t *sel
4545
mp_obj_t common_hal_socketpool_socketpool_gethostbyname(socketpool_socketpool_obj_t *self,
4646
const char *host) {
4747

48+
// As of 2022, the version of lwip in esp-idf does not handle the
49+
// trailing-dot syntax of domain names, so emulate it.
50+
// Remove this once https://github.com/espressif/esp-idf/issues/10013 has
51+
// been implemented
52+
size_t strlen_host = strlen(host);
53+
if (strlen_host && host[strlen_host - 1] == '.') {
54+
mp_obj_t nodot = mp_obj_new_str(host, strlen_host - 1);
55+
host = mp_obj_str_get_str(nodot);
56+
}
57+
4858
const struct addrinfo hints = {
4959
.ai_family = AF_INET,
5060
.ai_socktype = SOCK_STREAM,

0 commit comments

Comments
 (0)