jettero has asked for the wisdom of the Perl Monks concerning the following question:

My xbox is special. Unlike the store bought xboxen, mine has an FTP server that I can use to put files on it and take them off. Unfortunately, the ftp server doesn't have a complete set of ftp commands. ls -al works fine, but ls does not. NLIST doesn't work, CD by absolute pathnames doesn't always work, though CD by relative filenames usually does.

I can ncftp the box (though some things don't work), but I can't mount it with lufs, midnight commander, etc...

I reasoned out that I could probably write an FTP proxy that would take commands like ls, NLST and re-write them -- to make it appear the commands were finished.

Every time I started to write the FTP proxy, I discovered the project was a great deal more difficult than I wanted it to be. Is there a really easy way to write an FTP proxy that I'm just missing? I found a few things on CPAN, but nothing specifically helpful.

Net::FTPServer seems like the coolest ftp server I have ever seen. I'd guess it can help me write my proxy. But I'm just not sure that's a good way. Is tjat a good way? Is there a better way?

All tips welcome. Thanks for your help.

Replies are listed 'Best First'.
Re: FTP Proxy
by Corion (Patriarch) on Dec 12, 2003 at 12:22 UTC

    I'm not sure if the tools you want to use support HTTP proxies, but if they (or some of them) do well enough, HTTP::Proxy could bring you a big step forward, as it relies mostly on LWP and should be easily hackable to support (nonpersistent) ftp connections.

    Programming a real ftp proxy will be a bit harder, as I don't know of ready-made modules for that, you will have to kludge together something using Net::FTP on one side, and maybe Net::FTPServer on the other, but I guess you mostly want some dynamic command rewriting, so you can be off better by remotely controlling your Xbox in passive mode through one connection and connecting to your proxy in passive mode as well. That way, you can implement your "proxy" mostly as a variant of netcat, piping data between the two socket connections, although you still need to parse the control data.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      FYI, I failed to mention, the evox (evolution x) ftp server doesn't support passive mode. But I'm glad to hear the net::ftp/net::ftpserver plan is a good one. That's probably how I'll end up doing it -- if I do it at all.
Re: FTP Proxy
by b10m (Vicar) on Dec 12, 2003 at 12:33 UTC
    I know the problem, I have a modded Xbox myself and discovered that the ftp server is kinda "awkward" to put it as gently as I can. You could write a proxy, (but I don't really see the need for it (then again, I'm just busy/lazy ;)), if you're really determined to use your regular ftp client.

    I work around all this by just using `ftp` (man ftp) to transfer files, and/or use the ftp client that's on my xbox and use it the other way around (so I use the xbox as client and my PC as host).

    Maybe it's even easier to write a ftp client that uses the right commands, instead of a proxy? Or maybe you could use some Win32 ftp clients (since they do seem to work) running WINE?

    Anyway, if you happen to finish the proxy, I'll be more then willing to test it ;)

    --
    b10m
      I'd love to write a ftp server for evox. I don't know that I'm going to work up the courage to install the devkit mod anytime soon though.

      And I totally agree. The regular ftp client is good enough for now. I was hoping I could find an easy way to fix the ftp server...