views:

366

answers:

3

I'm developing ftp client in python ftplib. How do i add proxies support to it (most ftp apps i seen seem to have it)? I'm especially thinking about socks proxies, but also other types... ftp, http (is it even possible to use http proxies with ftp program?)

Any ideas how to do it?

A: 

Standard module ftplib doesn't support proxies. It seems the only solution is to write your own customized version of the ftplib.

Eugene Morozov
+3  A: 

As per this source.

Depends on the proxy, but a common method is to ftp to the proxy, then use user at real-server as the user name, and the original password

EG for ftp.download.com

ftp proxyserver  (or open proxyserver from with ftp)
user anonymous at ftp.download.com
pass xxxxx

... so

from ftplib import FTP
site = FTP('my_proxy')
site.set_debuglevel(1)
msg = site.login('anonymous at ftp.download.com', 'password')
site.cwd('/pub')
Kevin Boyd
the link in the above answer is 404. Might have meant this one: http://mail.python.org/pipermail/python-list/2004-October/863602.html
AndrewR
+2  A: 

You can use the ProxyHandler in urllib2.

ph = urlli2.ProxyHandler( { 'ftp' : proxy_server_url } )
server= urllib2.build_opener( proxy_hander )
S.Lott