about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2008-02-09 15:16:28 +0000
committerGraham Barr <gbarr@pobox.com>2009-02-24 10:40:49 -0600
commit9b56216ff375eaf129d1d61761a384438b7c61ea (patch)
tree51797f3ab68de85232c227cc74c5bac824f3fb8f
parent1cb97b891a46dba5a10de181f51b382c5e810386 (diff)
downloadperl-libnet-9b56216ff375eaf129d1d61761a384438b7c61ea.tar.gz
Add support for LocalAddr to be passed to ->new
-rw-r--r--Net/NNTP.pm24
1 files changed, 15 insertions, 9 deletions
diff --git a/Net/NNTP.pm b/Net/NNTP.pm
index d7020f3..a9a5592 100644
--- a/Net/NNTP.pm
+++ b/Net/NNTP.pm
@@ -39,23 +39,24 @@ sub new {
   @{$hosts} = qw(news)
     unless @{$hosts};
 
+  my %connect = ( Proto => 'tcp');
+  my $o;
+  foreach $o (qw(LocalAddr Timeout)) {
+    $connect{$o} = $arg{$o} if exists $arg{$o};
+  }
+  $connect{Timeout} = 120 unless defined $connect{Timeout};
+  $connect{PeerPort} = $arg{Port} || 'nntp(119)';
   my $h;
   foreach $h (@{$hosts}) {
-    $obj = $type->SUPER::new(
-      PeerAddr => ($host = $h),
-      PeerPort => $arg{Port} || 'nntp(119)',
-      Proto => 'tcp',
-      Timeout => defined $arg{Timeout}
-      ? $arg{Timeout}
-      : 120
-      )
+    $connect{PeerAddr} = $h;
+    $obj = $type->SUPER::new(%connect)
       and last;
   }
 
   return undef
     unless defined $obj;
 
-  ${*$obj}{'net_nntp_host'} = $host;
+  ${*$obj}{'net_nntp_host'} = $connect{PeerAddr};
 
   $obj->autoflush(1);
   $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef);
@@ -749,6 +750,11 @@ so that the remote server becomes innd. If the C<Reader> option is given
 with a value of zero, then this command will not be sent and the
 connection will be left talking to nnrpd.
 
+B<LocalAddr> - If multiple IP addresses are present on the client host
+with a valid route to the destination, you can specify the address your
+C<Net::NNTP> connects from and this way override the operating system's
+pick.
+
 =back
 
 =head1 METHODS