自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

FileZilla FTP 兼容FtpAnywhere

運維 系統(tǒng)運維
FileZilla FTP是一個著名的開源標準FTP客戶端軟件,但是與FtpAnywhere提供的網(wǎng)格FTP有兼容問題。所以如何才能讓FileZilla FTP 兼容FtpAnywhere呢?本文主要講述的就是這個問題:讓FileZilla FTP 兼容FtpAnywhere

  讓FileZilla兼容FtpAnywhere

  FileZilla FTP是一個著名的開源標準FTP客戶端軟件,但是它的目前版本與FtpAnywhere提供的網(wǎng)格FTP有兼容問題,而且,目前無法通過它提供的那些設(shè)置模塊來實現(xiàn)兼容,因此,我特地下載了它的源代碼快照 [2009.4.16] ,看看是否有可能通過修改源代碼來讓它兼容.

  解壓縮它的源代碼,轉(zhuǎn)到子目錄\src\engine下,打開ftpcontrolsocket.cpp文件,這個文件就是FileZilla用來支持標準FTP指令的核心,需要改造的是它的列表模式以及對PASV反饋的分析代碼 [包括IPV6下的EPSV指令,但是暫時因為沒有IPV6,所以沒必要動它],改造它的PASV解析代碼

  讓FileZilla兼容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.   }  
  56.  
  57.   const wxString peerIP = m_pSocket->GetPeerIP();  
  58.  
  59.   if (!IsRoutableAddress(pData->host, m_pSocket->GetAddressFamily()) && IsRoutableAddress(peerIP, m_pSocket->GetAddressFamily()))  
  60.  
  61.   {  
  62.  
  63.   if (!m_pEngine->GetOptions()->GetOptionVal(OPTION_PASVREPLYFALLBACKMODE) || pData->bTriedActive)  
  64.  
  65.   {  
  66.  
  67.   LogMessage(Status, _("Server sent passive reply with unroutable address. Using server address instead."));  
  68.  
  69.   LogMessage(Debug_Info, _T(" Reply: %s, peer: %s"), pData->host.c_str(), peerIP.c_str());  
  70.  
  71.   pData->host = peerIP;  
  72.  
  73.   }  
  74.  
  75.   else  
  76.  
  77.   {  
  78.  
  79.   LogMessage(Status, _("Server sent passive reply with unroutable address. Passive mode failed."));  
  80.  
  81.   LogMessage(Debug_Info, _T(" Reply: %s, peer: %s"), pData->host.c_str(), peerIP.c_str());  
  82.  
  83.   return false;  
  84.  
  85.   }  
  86.  
  87.   }  
  88.  
  89.   return true;  
  90.  
  91.   }  
  92.  

  這里是它原先的代碼,導致PASV模式下無法下載的問題就出在它不知道有P2P傳輸這么個東西,因此加了個安全判斷功能,只要把它注銷就可以適合FtpAnywhere了,一般來說,只要FTP服務器是正規(guī)的服務器,那么這些代碼完全是白費蠟,注銷后的代碼

  讓FileZilla兼容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.   }  
  56.  
  57.   //注意,把下面的代碼注銷,就可以支持P2P PASV模式下的連接傳輸了  
  58.  
  59.   //const wxString peerIP = m_pSocket->GetPeerIP();  
  60.  
  61.   //if (!IsRoutableAddress(pData->host, m_pSocket->GetAddressFamily()) && IsRoutableAddress(peerIP, m_pSocket->GetAddressFamily()))  
  62.  
  63.   //{  
  64.  
  65.   //if (!m_pEngine->GetOptions()->GetOptionVal(OPTION_PASVREPLYFALLBACKMODE) || pData->bTriedActive)  
  66.  
  67.   //{  
  68.  
  69.   //LogMessage(Status, _("Server sent passive reply with unroutable address. Using server address instead."));  
  70.  
  71.   //LogMessage(Debug_Info, _T(" Reply: %s, peer: %s"), pData->host.c_str(), peerIP.c_str());  
  72.  
  73.   //pData->host = peerIP;  
  74.  
  75.   //}  
  76.  
  77.   //else  
  78.  
  79.   //{  
  80.  
  81.   //LogMessage(Status, _("Server sent passive reply with unroutable address. Passive mode failed."));  
  82.  
  83.   //LogMessage(Debug_Info, _T(" Reply: %s, peer: %s"), pData->host.c_str(), peerIP.c_str());  
  84.  
  85.   //return false;  
  86.  
  87.   //}  
  88.  
  89.   //}  
  90.  
  91.   return true;  
  92.  
  93.   }  
  94.  

#p#

  那么現(xiàn)在的代碼,只要在站點屬性的連接模式里,指定PORT為優(yōu)先,在PORT模式連接失敗后,設(shè)置自動切換到PASV模式,已經(jīng)可以有條件兼容,只是***次下載會失敗而已,下面我們改造它的列表模式,讓它具備更好的兼容性. 當然,你可以在FtpAnywhere服務器里,設(shè)置禁止根目錄下PASV列表,來讓FileZilla自動判斷連接模式,但是從它的代碼看,它的判斷還是存在一點兼容問題.因此,將LIST改造成主動模式優(yōu)先,是***的選擇.

  問題在這里

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

  它的初始化是被動模式優(yōu)先,這樣,列表的時候?qū)l(fā)生問題,但是下載可以成功,但是我閱讀代碼,發(fā)現(xiàn)除非額外指定一個列表時優(yōu)先使用的模式變量,否則很難修改代碼,因為它的代碼中列表和文件傳輸?shù)膬?yōu)先模式是一致的,還要適應其他標準FTP站點,畢竟我不可以能讓它為我的FtpAnywhere進行優(yōu)化,方法是,在FtpControlSocket.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.   };  
  24.  

  給它加個額外的變量,例如 bool bFtpAnywhere;然后,在List指令前,確定首先采用PASV或者PORT前,判斷 bFtpAnywhere是否為真,如果為真,那么列表應該優(yōu)先采用PORT模式,否則繼續(xù)執(zhí)行默認的動作;而bFtpAnywhere的初始化應該從給服務器發(fā)送 VDSI指令是否返回2XX來判斷,是否是一個FtpAnywhere服務器,因為這里涉及的修改太多,除非FileZilla代碼維護人員同意,否則沒有意義,因此,最簡單最快的方法還是直接注銷我上面給出的代碼,雖然無法獲得100%兼容,但是基本可以兼容,而且通過設(shè)置項目,可以做到手動兼容.

【編輯推薦】

  1. FileZilla Ftp 教程
  2. FileZilla客戶端高級體驗(圖)
  3. FTP客戶端 Filezilla
  4. FileZilla Server 安裝設(shè)置(圖)
  5. FileZilla FTP server 安裝配置(圖)
  6. 用FileZilla共享文件Win7和Centos5虛擬機(圖)
  7. Filezilla server 安裝指南
  8. FileZilla FTP Server安裝教程
責任編輯:zhaolei 來源: CSDN
相關(guān)推薦

2011-03-07 14:34:50

FileZillaFtpAnywhere

2011-03-02 09:00:26

2011-03-07 14:23:08

2011-03-04 12:00:47

FileZilla

2011-03-01 16:50:19

2011-03-07 14:32:54

FileZilla帳戶

2011-03-02 14:36:24

Filezilla客戶端

2011-03-07 15:51:41

FileZilla

2011-03-07 14:36:36

2011-03-07 14:36:36

2011-03-04 10:35:39

FileZilla

2011-03-07 13:36:16

2011-03-01 17:38:07

FileZilla安裝

2011-03-04 14:02:53

Windows7Filezilla

2011-03-04 11:51:00

FileZilla用戶組

2021-11-01 07:15:36

服務器FTPFileZilla

2011-03-07 13:12:58

FileZilla

2011-03-01 16:25:37

FileZilla

2011-03-04 11:23:55

FileZilla

2011-03-01 16:32:58

FileZilla
點贊
收藏

51CTO技術(shù)棧公眾號