X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FNet%2FConfig.pm;h=8984ed7889a967f183e48ef04da9016e282788d9;hb=9c36735de2bc373cab0c4275429b13fc1c754d20;hp=9dd66ba227c17a63870d05452dc8c8514a7e22ca;hpb=ea5a7fad992230abd5ec11bf824bf8fd17832732;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Net/Config.pm b/lib/Net/Config.pm index 9dd66ba..8984ed7 100644 --- a/lib/Net/Config.pm +++ b/lib/Net/Config.pm @@ -13,7 +13,7 @@ use strict; @EXPORT = qw(%NetConfig); @ISA = qw(Net::LocalCfg Exporter); -$VERSION = "1.05"; # $Id: //depot/libnet/Net/Config.pm#9 $ +$VERSION = "1.10"; # $Id: //depot/libnet/Net/Config.pm#17 $ eval { local $SIG{__DIE__}; require Net::LocalCfg }; @@ -33,32 +33,57 @@ eval { local $SIG{__DIE__}; require Net::LocalCfg }; test_exist => 1, ); +# +# Try to get as much configuration info as possible from InternetConfig +# +$^O eq 'MacOS' and eval < [ \$InternetConfig{ kICNNTPHost() } ], + pop3_hosts => [ \$InternetConfig{ kICMailAccount() } =~ /\@(.*)/ ], + smtp_hosts => [ \$InternetConfig{ kICSMTPHost() } ], + ftp_testhost => \$InternetConfig{ kICFTPHost() } ? \$InternetConfig{ kICFTPHost()} : undef, + ph_hosts => [ \$InternetConfig{ kICPhHost() } ], + ftp_ext_passive => \$InternetConfig{"646F676F\xA5UsePassiveMode"} || 0, + ftp_int_passive => \$InternetConfig{"646F676F\xA5UsePassiveMode"} || 0, + socks_hosts => + \$InternetConfig{ kICUseSocks() } ? [ \$InternetConfig{ kICSocksHost() } ] : [], + ftp_firewall => + \$InternetConfig{ kICUseFTPProxy() } ? [ \$InternetConfig{ kICFTPProxyHost() } ] : [], +); +\@NetConfig{keys %nc} = values %nc; +} +TRY_INTERNET_CONFIG + my $file = __FILE__; my $ref; $file =~ s/Config.pm/libnet.cfg/; if ( -f $file ) { - $ref = eval { do $file }; + $ref = eval { local $SIG{__DIE__}; do $file }; if (ref($ref) eq 'HASH') { %NetConfig = (%NetConfig, %{ $ref }); $LIBNET_CFG = $file; } } if ($< == $> and !$CONFIGURE) { - my $home = eval { (getpwuid($>))[7] } || $ENV{HOME}; + my $home = eval { local $SIG{__DIE__}; (getpwuid($>))[7] } || $ENV{HOME}; + $home ||= $ENV{HOMEDRIVE} . ($ENV{HOMEPATH}||'') if defined $ENV{HOMEDRIVE}; if (defined $home) { $file = $home . "/.libnetrc"; - $ref = eval { do $file } if -f $file; + $ref = eval { local $SIG{__DIE__}; do $file } if -f $file; %NetConfig = (%NetConfig, %{ $ref }) if ref($ref) eq 'HASH'; } } my ($k,$v); while(($k,$v) = each %NetConfig) { - $v = [ $v ] - if($k =~ /_hosts$/ && !ref($v)); + $NetConfig{$k} = [ $v ] + if($k =~ /_hosts$/ and $k ne "test_hosts" and defined($v) and !ref($v)); } -# Take a hostname and determine if it is inside te firewall +# Take a hostname and determine if it is inside the firewall sub requires_firewall { shift; # ignore package @@ -168,7 +193,7 @@ Your internet domain name =item ftp_firewall -If you have an FTP proxy firewall (B a HTTP or SOCKS firewall) +If you have an FTP proxy firewall (B an HTTP or SOCKS firewall) then this value should be set to the firewall hostname. If your firewall does not listen to port 21, then this value should be set to C<"hostname:port"> (eg C<"hostname:99">) @@ -284,6 +309,6 @@ If true then C will check each hostname given that it exists =for html
-I<$Id: //depot/libnet/Net/Config.pm#9 $> +I<$Id: //depot/libnet/Net/Config.pm#17 $> =cut