FIx passive mode (Hopefully)

This commit is contained in:
Andrew Pamment 2017-03-22 13:54:31 +10:00
parent ea32e5ab03
commit 2a2b9e7dd7
2 changed files with 6 additions and 3 deletions

View File

@ -342,7 +342,7 @@ void handle_PASV(struct ftpserver *cfg, struct ftpclient *client) {
getsockname(client->data_srv_socket, (struct sockaddr*) &file_addr, &file_sock_len);
int port = ntohs(file_addr.sin_port);
ipcpy = strdup(client->ip);
ipcpy = strdup(client->hostip);
ipptr = strtok(ipcpy, ".");
@ -687,7 +687,7 @@ int handle_client(struct ftpserver *cfg, struct ftpclient *client, char *buf, in
void init(struct ftpserver *cfg) {
int server_socket;
struct sockaddr_in server, client;
struct sockaddr_in server, client, host_addr;
fd_set master, read_fds;
int fdmax = 0;
socklen_t c;
@ -712,7 +712,6 @@ void init(struct ftpserver *cfg) {
listen(server_socket, 3);
FD_ZERO(&master);
FD_SET(server_socket, &master);
fdmax = server_socket;
@ -756,6 +755,9 @@ void init(struct ftpserver *cfg) {
exit(-1);
}
getsockname(new_fd, (struct sockaddr*) &host_addr, &c);
inet_ntop(AF_INET, &(host_addr.sin_addr), client[client_count]->hostip, INET_ADDRSTRLEN);
getpeername(new_fd, (struct sockaddr *)&client, &c);
inet_ntop(AF_INET, &(client.sin_addr), clients[client_count]->ip, INET_ADDRSTRLEN);

View File

@ -9,6 +9,7 @@ struct ftpclient {
int data_port;
int type;
char ip[20];
char hostip[20];
char name[16];
char password[32];
int data_srv_socket;