mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-11-17 18:29:19 +01:00
Reverse DNS-lookup
This commit is contained in:
parent
1c5084e08e
commit
9d2a3906f3
16
source/ftp.c
16
source/ftp.c
@ -5,6 +5,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -675,6 +676,8 @@ 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);
|
||||||
@ -684,8 +687,17 @@ ftp_session_new(int listen_fd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console_print(CYAN "accepted connection from %s:%u\n" RESET,
|
memset(host, 0, sizeof(host));
|
||||||
inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
|
memset(serv, 0, sizeof(serv));
|
||||||
|
|
||||||
|
rc = getnameinfo((struct sockaddr*)&addr, addrlen,
|
||||||
|
host, 15, serv, 2, 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*)malloc(sizeof(ftp_session_t));
|
session = (ftp_session_t*)malloc(sizeof(ftp_session_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user