FTPPutFile触发防火墙问题导致故障 我在C++方面很缺乏经验,我正在尝试做一个项目,它可以简单地从客户端PC上传文件到我的PyrFTP服务器。然而,我注意到默认情况下windows防火墙会阻止这种通信(我在active directory和外部的PC上进行了测试,得到了相同的结果)
这是我的密码FTPPutFile触发防火墙问题导致故障 我在C++方面很缺乏经验,我正在尝试做一个项目,它可以简单地从客户端PC上传文件到我的PyrFTP服务器。然而,我注意到默认情况下windows防火墙会阻止这种通信(我在active directory和外部的PC上进行了测试,得到了相同的结果),c++,ftp,firewall,wininet,C++,Ftp,Firewall,Wininet,这是我的密码 void doUpload(char *LocFile, char *Rfile){ //LocFile must come with path e.g. C:\\helloworld.txt //Rfile is the name of the file on the remote server. hi.txt char *user="<FTPUSER>
void doUpload(char *LocFile, char *Rfile){
//LocFile must come with path e.g. C:\\helloworld.txt
//Rfile is the name of the file on the remote server. hi.txt
char *user="<FTPUSER>";
char *pass="<FTPPASS>";
char *ftpserver="<FTPIP>";
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0);
//doupload
if(FtpPutFile(hFtpSession, LocFile, Rfile,FTP_TRANSFER_TYPE_BINARY,INTERNET_FLAG_PASSIVE)){
print("Upload Worked!");
Sleep(1000);
InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);
}
else{cout << "FAILED UPLOAD\n";cout << LocFile;cout << Rfile;}
}
您正在执行被动模式转换。这通常是防火墙友好的,因为它使用出站连接。防火墙往往会阻止入站连接,而不是出站连接,除非防火墙管理员已配置了阻止出站连接的特定规则。防火墙旨在控制通信,而不是绕过。因此,无论您使用何种套接字API,您都会遇到相同问题的类似变化。@雷米尔博公司的安全专家在正确执行其工作时通常不允许PC/PC通信,只允许PC/服务器和PC/路由设备。这就是使用被动模式的想法,所以你是说一般来说这不应该触发防火墙阻止?难道我没有办法让它使用现有的开放端口吗?因为它只需要上传就可以了。而且@cristo FTP服务器不是PC对PC的,FTP在云端。
200 Switching to Binary mode.
500 Illegal PORT command.
500 Unknown command.