mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 07:01:21 +02:00
- some initial changes to try to get ftp working over the Internet with firewalls etc
This commit is contained in:
@@ -679,15 +679,38 @@ LOCAL int ftpCmdPasv(int sessionId, const char* args, int len)
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
ftpGetSession(sessionId)->passiveDataSocket = s;
|
||||
sprintf(str, "%s (%d,%d,%d,%d,%d,%d)",
|
||||
ftpMsg029,
|
||||
(ip >> 24) & 0xFF,
|
||||
(ip >> 16) & 0xFF,
|
||||
(ip >> 8) & 0xFF,
|
||||
ip & 0xFF,
|
||||
(port >> 8) & 0xFF,
|
||||
port & 0xFF);
|
||||
ftpGetSession(sessionId)->passiveDataSocket = s;
|
||||
|
||||
if(ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp) > 0)
|
||||
{
|
||||
ftpGetSession(sessionId)->remoteFTPServerPassivePort = port;
|
||||
if(ftpAddUPNPPortForward) {
|
||||
ftpAddUPNPPortForward(port, port);
|
||||
}
|
||||
|
||||
ip_t remoteFTPServerIp = ftpFindExternalFTPServerIp(ftpGetSession(sessionId)->remoteIp);
|
||||
|
||||
sprintf(str, "%s (%d,%d,%d,%d,%d,%d)",
|
||||
ftpMsg029,
|
||||
(remoteFTPServerIp >> 24) & 0xFF,
|
||||
(remoteFTPServerIp >> 16) & 0xFF,
|
||||
(remoteFTPServerIp >> 8) & 0xFF,
|
||||
remoteFTPServerIp & 0xFF,
|
||||
(port >> 8) & 0xFF,
|
||||
port & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s (%d,%d,%d,%d,%d,%d)",
|
||||
ftpMsg029,
|
||||
(ip >> 24) & 0xFF,
|
||||
(ip >> 16) & 0xFF,
|
||||
(ip >> 8) & 0xFF,
|
||||
ip & 0xFF,
|
||||
(port >> 8) & 0xFF,
|
||||
port & 0xFF);
|
||||
}
|
||||
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 227, str);
|
||||
ftpGetSession(sessionId)->passive = TRUE;
|
||||
return 0;
|
||||
|
@@ -32,7 +32,6 @@
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief array that holds the data of all ftp sessions
|
||||
*
|
||||
@@ -119,7 +118,14 @@ int ftpAuthSession(int id)
|
||||
* @return 0
|
||||
*/
|
||||
int ftpCloseSession(int id)
|
||||
{
|
||||
{
|
||||
if(ftpFindExternalFTPServerIp != NULL && ftpFindExternalFTPServerIp(sessions[id].remoteIp) > 0)
|
||||
{
|
||||
if(ftpRemoveUPNPPortForward)
|
||||
{
|
||||
ftpRemoveUPNPPortForward(sessions[id].remoteFTPServerPassivePort, sessions[id].remoteFTPServerPassivePort);
|
||||
}
|
||||
}
|
||||
ftpCloseSocket(sessions[id].ctrlSocket);
|
||||
ftpCloseTransmission(id);
|
||||
|
||||
|
@@ -35,18 +35,20 @@
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
#include "ftp.h"
|
||||
|
||||
ip_t ownIp;
|
||||
//ip_t ownExternalIp;
|
||||
|
||||
LOCAL fd_set watchedSockets;
|
||||
LOCAL fd_set signaledSockets;
|
||||
LOCAL int maxSockNr;
|
||||
|
||||
|
||||
void ftpArchInit(void)
|
||||
void ftpArchInit()
|
||||
{
|
||||
ownIp = 0;
|
||||
ownIp = 0;
|
||||
//ownExternalIp = externalIp;
|
||||
maxSockNr = 0;
|
||||
FD_ZERO(&watchedSockets);
|
||||
FD_ZERO(&signaledSockets);
|
||||
@@ -260,7 +262,10 @@ socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port)
|
||||
}
|
||||
|
||||
*port = ntohs(myAddr.sin_port);
|
||||
*ip = ownIp;
|
||||
*ip = ownIp;
|
||||
//if(ownExternalIp > 0) {
|
||||
// *ip = ownExternalIp;
|
||||
//}
|
||||
|
||||
if(listen(dataSocket, 1))
|
||||
{
|
||||
@@ -339,7 +344,7 @@ socket_t ftpAcceptServerConnection(socket_t server, ip_t *remoteIP, port_t *remo
|
||||
#endif
|
||||
}
|
||||
|
||||
ownIp = ntohl(sockinfo.sin_addr.s_addr); // eigene IP-Adresse abspeichern (wird dir PASV benätigt)
|
||||
ownIp = ntohl(sockinfo.sin_addr.s_addr); // eigene IP-Adresse abspeichern (wird dir PASV benätigt)
|
||||
}
|
||||
#if DBG_LOG
|
||||
printf("Verbindung mit %s auf Port %d akzeptiert.\n", inet_ntoa(sockinfo.sin_addr), *remotePort);
|
||||
|
@@ -32,16 +32,18 @@
|
||||
#pragma comment(lib, "ws2_32")
|
||||
#pragma comment(lib, "MSWSOCK")
|
||||
|
||||
ip_t ownIp;
|
||||
ip_t ownIp;
|
||||
//ip_t ownExternalIp;
|
||||
|
||||
LOCAL fd_set watchedSockets;
|
||||
LOCAL fd_set signaledSockets;
|
||||
LOCAL int maxSockNr;
|
||||
|
||||
void ftpArchInit(void)
|
||||
void ftpArchInit()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
ownIp = 0;
|
||||
ownIp = 0;
|
||||
//ownExternalIp = externalIp;
|
||||
maxSockNr = 0;
|
||||
FD_ZERO(&watchedSockets);
|
||||
WSAStartup(MAKEWORD(2, 0),&wsaData);
|
||||
@@ -291,6 +293,9 @@ socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port)
|
||||
|
||||
*port = ntohs(myAddr.sin_port);
|
||||
*ip = ownIp;
|
||||
//if(ownExternalIp > 0) {
|
||||
// *ip = ownExternalIp;
|
||||
//}
|
||||
|
||||
if(listen(dataSocket, 1))
|
||||
{
|
||||
|
Reference in New Issue
Block a user