From 9b56216ff375eaf129d1d61761a384438b7c61ea Mon Sep 17 00:00:00 2001 From: Graham Barr Date: Sat, 9 Feb 2008 15:16:28 +0000 Subject: Add support for LocalAddr to be passed to ->new --- Net/NNTP.pm | 24 +++++++++++++++--------- 1 file 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 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 - If multiple IP addresses are present on the client host +with a valid route to the destination, you can specify the address your +C connects from and this way override the operating system's +pick. + =back =head1 METHODS -- cgit v1.2.3-24-ge0c7