Remove use of getnameinfo for new connections.

This commit is contained in:
Michael Theall 2017-07-25 22:01:10 -05:00
parent 6d042c525a
commit 8e14aa4417

View File

@ -11,7 +11,6 @@
#include <inttypes.h> #include <inttypes.h>
#include <malloc.h> #include <malloc.h>
#include <math.h> #include <math.h>
#include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <poll.h> #include <poll.h>
#include <stdarg.h> #include <stdarg.h>
@ -898,8 +897,6 @@ ftp_session_new(int listen_fd)
ftp_session_t *session; ftp_session_t *session;
struct sockaddr_in addr; struct sockaddr_in addr;
socklen_t addrlen = sizeof(addr); socklen_t addrlen = sizeof(addr);
char host[NI_MAXHOST+1];
char serv[NI_MAXSERV+1];
/* accept connection */ /* accept connection */
new_fd = accept(listen_fd, (struct sockaddr*)&addr, &addrlen); new_fd = accept(listen_fd, (struct sockaddr*)&addr, &addrlen);
@ -909,18 +906,8 @@ ftp_session_new(int listen_fd)
return; return;
} }
memset(host, 0, sizeof(host)); console_print(CYAN "accepted connection from %s:%u\n" RESET,
memset(serv, 0, sizeof(serv)); inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
/* reverse dns lookup */
rc = getnameinfo((struct sockaddr*)&addr, addrlen,
host, sizeof(host), serv, sizeof(serv), 0);
if(rc != 0)
console_print(CYAN "accepted connection from %s:%u\n" RESET,
inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
else
console_print(CYAN "accepted connection from %s:%s\n" RESET,
host, serv);
/* allocate a new session */ /* allocate a new session */
session = (ftp_session_t*)calloc(1, sizeof(ftp_session_t)); session = (ftp_session_t*)calloc(1, sizeof(ftp_session_t));