Page 1 of 2

Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-07-26 10:30
by pyro
Hi folks,

In the last 3 hours i managed to create a patch which adds PRET-support to filezilla:

Code: Select all

--- filezilla-3.3.3/src/engine/ftpcontrolsocket.cpp	2010-06-13 19:13:28.000000000 +0000
+++ filezilla-3.3.3-pret-support/src/engine/ftpcontrolsocket.cpp	2010-07-26 12:06:49.132993558 +0000
@@ -91,6 +91,7 @@ enum rawtransferStates
 {
 	rawtransfer_init = 0,
 	rawtransfer_type,
+	rawtransfer_pret,
 	rawtransfer_port_pasv,
 	rawtransfer_rest,
 	rawtransfer_transfer,
@@ -3991,7 +3992,12 @@ int CFtpControlSocket::Transfer(const wx
 
 	if ((pData->pOldData->binary && m_lastTypeBinary == 1) ||
 		(!pData->pOldData->binary && m_lastTypeBinary == 0))
-		pData->opState = rawtransfer_port_pasv;
+	{
+		if (pData->bPasv && CServerCapabilities::GetCapability(*m_pCurrentServer, pret_command) == yes)
+			pData->opState = rawtransfer_pret;
+		else
+			pData->opState = rawtransfer_port_pasv;
+	}
 	else
 		pData->opState = rawtransfer_type;
 
@@ -4026,10 +4032,25 @@ int CFtpControlSocket::TransferParseResp
 			error = true;
 		else
 		{
-			pData->opState = rawtransfer_port_pasv;
+			if (pData->bPasv && CServerCapabilities::GetCapability(*m_pCurrentServer, pret_command) == yes) 
+				pData->opState = rawtransfer_pret;
+			else
+				pData->opState = rawtransfer_port_pasv;
 			m_lastTypeBinary = pData->pOldData->binary ? 1 : 0;
 		}
 		break;
+	
+	case rawtransfer_pret:
+		if (code != 2 && code != 2)
+		{
+			error = true;
+		}
+		else
+		{
+			pData->opState = rawtransfer_port_pasv;
+		}
+		break;
+
 	case rawtransfer_port_pasv:
 		if (code != 2 && code != 3)
 		{
@@ -4180,6 +4201,13 @@ int CFtpControlSocket::TransferSend()
 		else
 			cmd = _T("TYPE A");
 		break;
+
+	case rawtransfer_pret:
+		cmd = _T("PRET ");
+		cmd += pData->cmd;
+
+		break;
+		
 	case rawtransfer_port_pasv:
 		if (pData->bPasv)
 		{
The code works for me quite well. Downloading, Uploading an listing files works without problems.

I do not expect that the patch will be applied to the current development branch as i've seen the aversion of the development team against the PRET command. i just post it here so that other people can compile their own filezilla-versions.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-07-26 14:12
by boco
as i've seen the aversion of the development team against the PRET command
That's got nothing to do with it. The problem is that PRET is not an FTP command. It's not standardized and there are probably hundreds of different implementations floating around. THAT'S why it's not implemented.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-07-26 15:17
by pyro
ok, i see you're right.

i used this description: http://www.drftpd.org/index.php/PRET_Specifications

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-07-26 18:00
by boco
That's made by one entity and is in no way official. There are also posts of botg (the developer) in these forums explaining why PRET could create more problems than it solves.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-07-26 18:42
by botg
Thanks for your effort.

Unfortunately, PRET is not standardized and the provided documentation is in no way formal enough. In addition, the provided syntax is ambiguous and conflicts with itself:
PRET RETR <file> [ignored arguments]
Where does the file end and the ignored arguments start if there's a command like PRET RETR foo bar?

As such, I cannot apply your patch to FileZilla.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-08-07 23:51
by EHCanadian
I think the fact that someone went and did what you basicly refuse to do is more of a insult to pryo.

There is really no reason at all why this could not be branched.

Any other time you offer to implement it with some decent documents but when both devs are just
lazy the comunity looses out casue both want to be stubborn and lazy. A user took insentive and x
hours of his time to do what nether of you felt like doing. While PRET may not be a standard and
geared at only a few applications the fact that supporting it while being under open source and
community driven application.

Hell I'll take his patch and call it... EhZilla... slap on a donate now and be a prick to everyone tooo!

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-08-08 01:08
by boco
There's only one dev. And he's the one having the last word.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2010-08-08 10:01
by botg
Did you even bother to try to understand the technical arguments why I cannot support PRET in its current form?

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2012-05-29 03:05
by dev_rand
Hate to revive an (really) old topic, but this seems to be the most appropriate spot for it. After killing a few hours setting up and tweaking my build environment, I got this patch to work and figured I'd make the build available to others since a few people have asked for this feature now and official support won't happen short of an RFC being written.

As it states in the link below, this is completely unsupported - I'm not sure what will work/break/explode. If you find an issue that you have some idea how to fix, feel free to let me know.

Hope this helps somebody!

http://urandom.us/fz_pret/

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2012-05-29 04:10
by boco

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2014-08-16 06:36
by FileGamer
I didn't want to make a new topic about PRET support, so I'm replying to this one. Is there a build of Filezilla 3.9 that supports PRET? That link of the Windows build 3.3 on the WIKI page seems to be down, and I'm wondering if there's an updated unofficial build anyway. Unfortunately, a server I use still uses PRET and every time I connect to it, it shows this:

Response: 500 You need to use a client supporting PRET (PRE Transfer) to use PASV
Command: PORT 192,168,1,10,40,163
Response: 501- ==YOU'RE BEHIND A NAT ROUTER==
Response: 501- Configure the firewall settings of your FTP client
Response: 501- to use your real IP: SERVER.IP.IS.HERE
Response: 501- And set up port forwarding in your router.
Response: 501- Or you can just use a PRET capable client, see
Response: 501- http://drftpd.org/ for PRET capable clients
Response: 501
Error: Failed to retrieve directory listing

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2014-08-16 10:28
by boco
No, the official build does not support PRET (as it's not a part of FTP). The 3.5.3 was an unofficial build and seems to be down (unofficial builds are not mirrored).

Examine this list: http://www.drftpd.org/index.php/Clients ... ET_support

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2014-08-22 06:23
by FileGamer
boco wrote:No, the official build does not support PRET (as it's not a part of FTP). The 3.5.3 was an unofficial build and seems to be down (unofficial builds are not mirrored).

Examine this list: http://www.drftpd.org/index.php/Clients ... ET_support
If anyone has the installer file for the 3.5.3 unofficial build, I would greatly appreciate it. That mirror in the wiki article has been down for weeks.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2014-08-22 22:48
by boco
That build is very old and suffers from many issues (security-related ones included). Get an up-to-date client, instead.

Re: Patch for PRET-Support in Filezilla 3.3.3

Posted: 2014-08-23 05:47
by FileGamer
boco wrote:That build is very old and suffers from many issues (security-related ones included). Get an up-to-date client, instead.
The thing is, I need an FTP client that uses PRET (the servers I connect to use that), maxes out my download/upload speeds, has Auth TLS, and can perform simultaneous transfers. I've tried every client on that list that works with Windows 7 (both 32-bit or 64-bit). I've tried both FTP Rush v1 and v2, and both have bugs for me including giving several download errors with a red X as well as not maxing out my speed and giving me way less both uploading and downloading. FlashFXP gives me a little bit in better speeds, still a lot less than my internet speed, but doesn't have the capability to do simultaneous transfers. Keep in mind, I'm connecting to servers with much faster speeds than what I have for internet. All the other clients on that list and even others I've tried like cuteFTP or smartFTP or other ones mentioned online do not fulfill the requirements. If I knew how to give Filezilla PRET support in my own unofficial build, I wouldn't be here complaining. But Filezilla has everything except PRET support.