On Wed, 25 Aug 2004, Wan Kwong Yeung wrote:

Understood that Squid is not a ftp proxy, however, it may be required to interwork with an upstream ftp proxy.

Ok.

[EMAIL PROTECTED] type FTP proxies is accessible via Squid, either by manually translating the FTP proxy request into URL syntax or using a redirector to do so for you.

FTP URL syntax is

  ftp://user:[EMAIL PROTECTED]/path/to/file

In a [EMAIL PROTECTED] FTP proxy environment host is the name of the proxy server, user is [EMAIL PROTECTED] (i.e. [EMAIL PROTECTED]) and password is what is to be used as password (usually your email for anonymous FTP). Each @ sign or other strange characters in the differen fields of the ftp:// URL needs to be URL encoded in %nn syntax.

Example:


FTP Proxy: ftpproxy.example.com

  FTP Server: ftp.example.org

  Login: Anonymous

  Password: hno@

  File:  /pub/example.txt


Is equivalent to the URL

ftp://Anonymous%40ftp.example.org:[EMAIL PROTECTED]/pub/example.txt



Doing this in a redirector is relatively easy.

#!/usr/bin/perl -p

if ( m%^ftp://(([^@:/]*)(:([^@/]*))@)?([^/]+)(\S*)% ) {
   my ($login, $password, $host, $file) = ($2, $4, $5, $6);
   my $proxy = "ftpproxy.example.com";
   $login = "Anonymous" if ($login eq "");
   $password = "Squid%40" if ($password eq "" && (lc($login) eq "anonymous" || lc($login) eq 
"ftp"));
   $_ = "ftp://${login}%40${host}:[EMAIL PROTECTED]";
   next;
}


Regards Henrik

Reply via email to