- struct addrinfo *ai_in, *ai_out;
- struct addrinfo hint = {
- .ai_family = AF_UNSPEC,
- .ai_flags = AI_NUMERICSERV,
- .ai_socktype = SOCK_STREAM,
- };
- int err = getaddrinfo(hostname[i], port[i], &hint, &ai_in);
-
- if(err || !ai_in) {
- continue;
- }
-
- // Remember the address
- node_add_recent_address(mesh, mesh->self, (sockaddr_t *)ai_in->ai_addr);
-
- 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;
- }
+ struct addrinfo *ai_in = adns_blocking_request(mesh, xstrdup(hostname[i]), xstrdup(port[i]), SOCK_STREAM, 5);