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

Monks, from home I happily use Net::FTP to connect to an FTP site over the public Internet. But from my company office, I need to access the FTP site via a firewall.

Net::Config describes firewall types 0 - 7, according the dialog supported. But my firewall does not match any of these documented types. At an interactive FTP session, online diagnostics show that the expected dialog is:

USER username@hostname proxyusername PASS password ACCT proxypassword

The USER formats supported by the current firewall types are:

1: USER user@remote.host 2: USER fwuser ... USER user@remote.host 3 and 4: USER fwuser ... USER user 5: USER user@fwuser@remote.site 6: USER fwuser@remote.site ... USER user 7: USER user@remote.host ... AUTH fwuser

Should I politely request the author of Net::Config (Graham Barr) to implement this new type?

Should I (gulp!) extend the module to implement this myself? (OOPs -- I would not know where to start ...)

Is there any way to drive Net::FTP to bypass the firewall types in Net::Config?

I notice Net:FTP has an "authorize" method, which sounds useful for firewalls. I do not know if it will help me get access thru my new firewall type.

Replies are listed 'Best First'.
Re: New FTP firewall type for Net::Config
by thundergnat (Deacon) on Jan 08, 2010 at 17:53 UTC

    FWIW, There aren't really any "standard" connection formats for ftp. Different versions of ftp are free to implement their own types of connection. That being said, most implementations seem to recognize those 7 formats. They have become defacto standards by convention. If you need a different format, it looks like you need to set up a custom .netrc file in your home directory. See man ftp and man netrc.

    But that doesn't have anything to do with perl particularly....

    Poking around in the guts of Net::Config, it looks like it will try to use a file called .libnetrc in your home directory to load custom settings.

    Update: Actually, it looks like Net::FTP will load settings from .netrc if it exists. Check the perl docs for Net::Netrc.

      Thank-you, thundergnat, for the remarks on Net::Netrc.

      I e-mailed Graham Barr directly, and he kindly gave a fast response, saying I should connect thru a firewall like this:

      my $ftp = Net::FTP->new( $firewall_host, Firewall => undef ); $ftp->login( "$ftp_user\@$ftp_host $proxy_user", $ftp_password, $proxy_password );

      I tried this and it works just fine.

      I copied Graham's solution to this thread in case it helps other seekers of wisdom.

      I'll watch Net::Config in case Graham enhances it to handle this new firewall type. But in the meantime, his quick solution is just the ticket.