FileZilla compatible with FtpAnywhere

Source: Internet
Author: User
Tags ftp commands ftp client filezilla

 

Figure-FileZilla

FileZillaFTP is a well-known open-source standard FTP client software, but its current version is incompatible with the grid FTP provided by FtpAnywhere, currently, it is not compatible with the setting modules provided by it. Therefore, I download its source code snapshot [2009.4.16] to see if it is possible to make it compatible by modifying the source code.

Decompress its source code, go to the subdirectory \ src \ engine, and open ftpcontrolsocket. cpp file, which is the core of FileZilla to support standard FTP commands. The list mode and analysis code for PASV feedback need to be transformed [including EPSV commands under IPV6, but for the moment, because there is no IPV6, there is no need to change it], transform its PASV Parsing Code

Make FileZilla compatible with FtpAnywhere

 
 
  1. bool CFtpControlSocket::ParsePasvResponse(CRawTransferOpData* pData)  
  2.  
  3. {  
  4.  
  5. // Validate ip address  
  6.  
  7. wxString digit = _T("0*[0-9]{1,3}");  
  8.  
  9. const wxChar* dot = _T(",");  
  10.  
  11. wxString exp = _T("( |\\()(") + digit + dot + digit + dot + digit + dot + digit + dot + digit + dot + digit + _T(")( |\\)|$)");  
  12.  
  13. wxRegEx regex;  
  14.  
  15. regex.Compile(exp);  
  16.  
  17. if (!regex.Matches(m_Response))  
  18.  
  19. return false;  
  20.  
  21. pData->host = regex.GetMatch(m_Response, 2);  
  22.  
  23. int i = pData->host.Find(',', true);  
  24.  
  25. long number;  
  26.  
  27. if (i == -1 || !pData->host.Mid(i + 1).ToLong(&number))  
  28.  
  29. return false;  
  30.  
  31. pData->port = number; //get ls byte of server socket  
  32.  
  33. pData->host = pData->host.Left(i);  
  34.  
  35. i = pData->host.Find(',', true);  
  36.  
  37. if (i == -1 || !pData->host.Mid(i + 1).ToLong(&number))  
  38.  
  39. return false;  
  40.  
  41. pData->port += 256 * number; //add ms byte of server socket  
  42.  
  43. pData->host = pData-> host.Left(i);  
  44.  
  45. pData->host.Replace(_T(","), _T("."));  
  46.  
  47. if (m_pProxyBackend)  
  48.  
  49. {  
  50.  
  51. // We do not have any information about the proxy's inner workings  
  52.  
  53. return true;  
  54.  
  55. }  

// Note that the following code can be deregistered to support connection transmission in P2P PASV mode.

 
 
  1. //const wxString peerIP = m_pSocket->GetPeerIP();  
  2.  
  3. //if (!IsRoutableAddress(pData->host, m_pSocket->GetAddressFamily()) && IsRoutableAddress(peerIP, m_pSocket->GetAddressFamily()))  
  4.  
  5. //{  
  6.  
  7. //if (!m_pEngine->GetOptions()->GetOptionVal(OPTION_PASVREPLYFALLBACKMODE) || pData->bTriedActive)  
  8.  
  9. //{  
  10.  
  11. //LogMessage(Status, _("Server sent passive reply with unroutable address. Using server address instead."));  
  12.  
  13. //LogMessage(Debug_Info, _T(" Reply: %s, peer: %s"), pData->host.c_str(), peerIP.c_str());  
  14.  
  15. //pData->host = peerIP;  
  16.  
  17. //}  
  18.  
  19. //else  
  20.  
  21. //{  
  22.  
  23. //LogMessage(Status, _("Server sent passive reply with unroutable address. Passive mode failed."));  
  24.  
  25. //LogMessage(Debug_Info, _T(" Reply: %s, peer: %s"), pData->host.c_str(), peerIP.c_str());  
  26.  
  27. //return false;  
  28.  
  29. //}  
  30.  
  31. //}  
  32.  
  33. return true;  
  34.  
  35. }  

Now, as long as the PORT is specified as priority in the connection mode of the site attribute, if the connection fails in the PORT mode, it is set to automatically switch to the PASV mode, and conditional compatibility is available, this is only because the first download will fail. Next we will transform its list mode to make it more compatible. of course, you can disable the PASV list under the root directory on the FtpAnywhere server to enable FileZilla to automatically determine the connection mode, but from its code, it still has some compatibility problems. therefore, transforming LIST into active mode takes priority, which is the best choice.

Here is the problem

 
 
  1. CRawTransferOpData::CRawTransferOpData()  
  2.  
  3. : COpData(cmd_rawtransfer)  
  4.  
  5. {  
  6.  
  7. bTriedPasv = bTriedActive = false;  
  8.  
  9. bPasv = true;  
  10.  
  11. }  

Its initialization takes precedence over the passive mode. In this way, a problem occurs during the list, but the download is successful. However, I read the code and found that unless an additional list is specified, the mode variable is preferentially used, otherwise, it is difficult to modify the code, because the list in the Code is consistent with the file transmission priority mode, but also to adapt to other standard FTP sites, after all, I cannot optimize it for my FtpAnywhere by using the FtpControlSocket. class defined in h

 
 
  1. class CRawTransferOpData : public COpData  
  2.  
  3. {  
  4.  
  5. public:  
  6.  
  7. CRawTransferOpData();  
  8.  
  9. wxString cmd;  
  10.  
  11. CFtpTransferOpData* pOldData;  
  12.  
  13. bool bPasv;  
  14.  
  15. bool bTriedPasv;  
  16.  
  17. bool bTriedActive;  
  18.  
  19. wxString host;  
  20.  
  21. int port;  
  22.  
  23. };  

Add an extra variable to it, such as bool bFtpAnywhere. Then, before the List Command, determine whether to use PASV or PORT to determine whether bFtpAnywhere is true. If it is true, the list should adopt the PORT mode first; otherwise, the default action will be continued; while the bFtpAnywhere initialization should be determined by sending the VDSI command to the server whether 2XX is returned, whether it is an FtpAnywhere server, because too many modifications are involved here, unless agreed by the FileZilla code maintainer, it makes no sense. Therefore, the simplest and fastest way is to directly unregister the code I provided above, although it cannot be 100% compatible, but it is basically compatible, and manual compatibility can be achieved by setting projects.

Through the description and code analysis, we can clearly understand that FileZilla is compatible with FtpAnywhere and is expected to be useful to everyone!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.