But to get to the outside world from my box, you have
to go through a firewall.
SOCKS to the rescue!!! Right?
So I made a copy of socketmodule.c, called it socksmodule.c,
changed the runtime-visible "socket.error" to "SOCKet.error",
and built it with -Dconnect=Rconnect etc.
Presto! Python with SOCKS on!
So I went into ftplib.py, and changed:
import SOCKS; socket = SOCKS
Everything goes OK until we go to set up the data port connection.
First, I was getting this error:
err_setstr(SocketError, "return unknown socket address type");
because the SOCKS version of getsocketname assumes that you call
bind() right before you call getsocketname -- it squirrels away
the answer to getsocketname() when you do bind(). The ftplib
just did a getsocketname() on a new socket, so Rgetsocketname returned
a bogus address.
So I changed ftplib to match the SOCKS assumptions by adding
before it does sock.getsockname(). Then I kept getting:
*resp* '200 PORT command successful.'
*cmd* 'RETR README'
*resp* "425 Can't build data connection: Can't assign requested address."
Hmmm... I just twiddled with ftplib.py a little more and now it seems
to work... go figure.
Anyway... the socksmodule stuff is real simple... and adding it to
the python interpreter is a snap, thanks to all the Setup magic.
I could contribute it if anybody's interested.
Daniel W. Connolly "We believe in the interconnectedness of all things"
Software Engineer, Hal Software Systems, OLIAS project (512) 834-9962 x5010