- struct sockaddr_in sin;
- unsigned long ip;
-
- if (!getipbyname(peer, &ip)) {
- log_module(MAIN_LOG, LOG_ERROR, "getipbyname(%s) failed.", peer);
+ struct addrinfo hints, *ai;
+ char portnum[10];
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = local ? local->sa_family : 0;
+ hints.ai_socktype = SOCK_STREAM;
+ snprintf(portnum, sizeof(portnum), "%u", port);
+ if (getaddrinfo(peer, portnum, &hints, &ai)) {
+ log_module(MAIN_LOG, LOG_ERROR, "getaddrinfo(%s, %s) failed.", peer, portnum);