- if(flags & MESHLINK_INVITE_NUMERIC) {
- // We don't need to do any further conversion
- freeaddrinfo(ai_in);
- continue;
- }
-
- // Convert it to a hostname
- char resolved_host[NI_MAXHOST];
- char resolved_port[NI_MAXSERV];
- err = getnameinfo(ai_in->ai_addr, ai_in->ai_addrlen, resolved_host, sizeof resolved_host, resolved_port, sizeof resolved_port, NI_NUMERICSERV);
-
- if(err || !is_valid_hostname(resolved_host)) {
- freeaddrinfo(ai_in);
- continue;
- }
-
- // Convert the hostname back to a sockaddr
- hint.ai_family = ai_in->ai_family;
- err = getaddrinfo(resolved_host, resolved_port, &hint, &ai_out);
-
- if(err || !ai_out) {
- freeaddrinfo(ai_in);
- continue;
- }
-
- // Check if it's still the same sockaddr
- if(ai_in->ai_addrlen != ai_out->ai_addrlen || memcmp(ai_in->ai_addr, ai_out->ai_addr, ai_in->ai_addrlen)) {
- freeaddrinfo(ai_in);
- freeaddrinfo(ai_out);
- continue;
- }
-
- // Yes: replace the hostname with the resolved one
- free(hostname[i]);
- hostname[i] = xstrdup(resolved_host);
-