Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

FileZilla 3.0.4 keepalive 功能
post by tommy @ 29 十一月, 2007 13:10

FileZilla 3.0.4 版中, 作者終於加上了 KeepAlive 的功能了. 原本以為, 我另外加上的那個 keepalive patch 就用不到了. 不過... 用了兩天後, 發現... 目前這個版本的 keepalive 還是有些問題.

首先是由於使用的指令的關係, 在 pure-ftpd 中, 仍然會照成斷線. 這個問題比較容易解決, 只要多加一個 STAT 指令, 就可以避免 pure-ftpd 的逾時設計了. 修正如下:

diff -Nur filezilla-3.0.4.orig/src/engine/ftpcontrolsocket.cpp filezilla-3.0.4/src/engine/ftpcontrolsocket.cpp
--- filezilla-3.0.4.orig/src/engine/ftpcontrolsocket.cpp Tue Nov 27 04:42:56 2007
+++ filezilla-3.0.4/src/engine/ftpcontrolsocket.cpp Tue Nov 27 20:42:42 2007
@@ -4175,7 +4175,7 @@
LogMessage(Status, _("Sending keep-alive command"));

wxString cmd;
- int i = rand() * 3 / (RAND_MAX + 1);
+ int i = rand() * 4 / (RAND_MAX + 1);
if (!i)
cmd = _T("NOOP");
else if (i == 1)
@@ -4185,6 +4185,8 @@
else
cmd = _T("TYPE A");
}
+ else if (i == 2)
+ cmd = _T("STAT");
else
cmd = _T("PWD");

Patch 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/filezilla_3.0.4_keepalive_for_pureftpd.patch

不過, 在加上上頭的 patch 之後, 還是發現有逾時的情形, 因為不好查, 所以, 就在顯示的訊息上頭, 先加上時間, 方便於除錯.  修正如下:

diff -Nur filezilla-3.0.4.orig/src/interface/StatusView.cpp filezilla-3.0.4/src/interface/StatusView.cpp
--- filezilla-3.0.4.orig/src/interface/StatusView.cpp Tue Nov 27 04:42:56 2007
+++ filezilla-3.0.4/src/interface/StatusView.cpp Thu Nov 29 11:10:40 2007
@@ -151,6 +151,9 @@
 
m_pTextCtrl->SetDefaultStyle(m_attributeCache[messagetype].attr);
 
+ wxDateTime now = wxDateTime::Now();
+ prefix += now.FormatISOTime();
+ prefix += _T(" ");
prefix += m_attributeCache[messagetype].prefix;
 
int lineLength = m_attributeCache[messagetype].len + message.Length();

Patch 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/filezilla_3.0.4_add_time_to_message.patch

經過上頭的修正之後, 發現系統在經過 30 分鐘的閒置後, 就停止送出 keepalive 的指令. 看一下程式碼, 果然有個檢查 30 分鐘的地方, 不知道是作者故意的設計, 還是 bug? 到 SourceForge submit 給作者, 看是否是真要如此設計. 在得到答案之前, 當然只好自己弄個 patch 來用. 修正如下:

diff -Nur filezilla-3.0.4.orig/src/engine/ftpcontrolsocket.cpp filezilla-3.0.4/src/engine/ftpcontrolsocket.cpp
--- filezilla-3.0.4.orig/src/engine/ftpcontrolsocket.cpp Tue Nov 27 04:42:56 2007
+++ filezilla-3.0.4/src/engine/ftpcontrolsocket.cpp Thu Nov 29 12:33:40 2007
@@ -4204,9 +4204,11 @@
if (!m_lastCommandCompletionTime.IsValid())
return;

+/*
wxTimeSpan span = wxDateTime::Now() - m_lastCommandCompletionTime;
if (span.GetSeconds() >= (60 * 30))
return;
+*/

 
m_idleTimer.Start(30000, true);
}

Patch 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/filezilla_3.0.4_keepalive_after_30_minutes.patch

經過上頭的處理之後, 目前看起來運作就正常了.

如果需要 patch 過的執行檔, 請到 FileZillaPV 專案去下載吧. 


2007/11/30: 

作者表示, 30 分鐘的限制是故意的設計. 所以... 如果有這種一直連線的需求, 就自己 patch 吧.

 

Del.icio.us Furl HEMiDEMi Technorati MyShare
commons icon [1] Re:FileZilla 3.0.4 keepalive 功能 [ 回覆 ]

你好
我可以請問你到那裡可以找到FileZilla的原始碼嗎?!
我是資工系的學生,我需要找ftp的原始碼
請問你可以提供到那裡去下載原始碼嗎?!
我們是要探討加密的ftp
非常感謝你~

commons icon [2] Re:FileZilla 3.0.4 keepalive 功能 [ 回覆 ]

source code 在官方網站就有了啊.

commons icon [3] Re:FileZilla 3.0.4 keepalive 功能 [ 回覆 ]

雖然我是資工系的學生
可是我對找資料真的不太行
你可以給我網址嗎?!
謝謝你

commons icon [4] Re:FileZilla 3.0.4 keepalive 功能 [ 回覆 ]

那就學著怎麼找資料吧. 我覺得先學會這個比較重要些.
事實上, FileZilla 的官方網站連結, 在這篇文章內就有了. 連這個也找不到, 以後你可能作業 (或上班工作) 會做的很辛苦吧.

commons icon [5] Re:FileZilla 3.0.4 keepalive 功能 [ 回覆 ]

恩,是啊…
謝謝你的建議…

commons icon [6] Re:FileZilla 3.0.4 keepalive 功能 [ 回覆 ]

我找到原始碼了
雖然…我好像不太適合念資工(我太笨了= =)
不過,還是得繼續努力…
謝謝你~
找資料時找到你的部落格
真是太好了!
哈~

迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 92 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS