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

FileZilla兼容FtpAnywhere

運(yùn)維 系統(tǒng)運(yùn)維
FileZilla是一個(gè)免費(fèi)開源的FTP客戶端軟件,分為客戶端版本和服務(wù)器版本,具備所有的FTP軟件功能??煽匦?、有條理的界面和管理多站點(diǎn)的簡化方式使得Filezilla客戶端版成為一個(gè)方便高效的FTP客戶端工具,今天看看FileZilla是如何兼容FtpAnywhere!

 

FileZilla 

圖-FileZilla

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

  解壓縮它的源代碼,轉(zhuǎn)到子目錄\src\engine下,打開ftpcontrolsocket.cpp文件,這個(gè)文件就是FileZilla用來支持標(biāo)準(zhǔn)FTP指令的核心,需要改造的是它的列表模式以及對(duì)PASV反饋的分析代碼 [包括IPV6下的EPSV指令,但是暫時(shí)因?yàn)闆]有IPV6,所以沒必要?jiǎng)铀黓,改造它的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.   }  

 

  //注意,把下面的代碼注銷,就可以支持P2P PASV模式下的連接傳輸了

 

  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.   }  

 

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

  問題在這里

 

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

 

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

 

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

通過文章描寫和代碼的分析,我們可以清楚的知道:FileZilla是兼容FtpAnywhere,希望對(duì)大家有用!

【編輯推薦】

  1. 如何解決FileZilla連接不上IIS FTP的問題
  2. Filezilla Server架構(gòu)FTP服務(wù)器
  3. 使用FileZilla進(jìn)行加密的FTP協(xié)議認(rèn)證
  4. Filezilla的utf-8支持
  5. FileZilla Server提權(quán)
  6. FileZilla使用測評(píng)
  7. FileZilla實(shí)用功能之文件存在處理
  8. FileZilla實(shí)用功能之分組管理
  9. 如何實(shí)現(xiàn)FileZilla防掉線(反空閑、閑置保護(hù))
責(zé)任編輯:趙鵬 來源: 網(wǎng)絡(luò)轉(zhuǎn)載
相關(guān)推薦

2011-03-02 16:46:35

FileZillaFtpAnywhere

2011-03-04 14:02:53

Windows7Filezilla

2011-03-02 09:00:26

2011-03-07 11:26:45

FileZilla

2011-03-07 09:58:51

FileZilla

2011-02-23 16:40:12

FileZillaSe

2011-02-23 13:28:12

2011-03-07 14:08:06

FileZilla配置

2011-03-04 12:18:24

FileZilla

2011-03-04 15:28:33

FileZilla

2011-03-07 11:36:23

FileZillaSe

2011-03-07 16:16:14

filezilla s設(shè)置

2011-02-23 16:08:51

FileZilla S

2011-03-07 13:20:12

FileZilla設(shè)置

2011-03-07 15:07:30

2011-03-07 09:51:12

Filezilla

2011-03-04 15:34:52

FileZilla

2011-03-04 15:21:12

FileZilla

2011-03-04 16:13:54

FileZilla

2011-03-01 17:26:21

點(diǎn)贊
收藏

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