INN commit: trunk/frontends (pullnews.in)
INN Commit
Russ_Allbery at isc.org
Mon Apr 28 17:56:15 UTC 2008
Date: Monday, April 28, 2008 @ 10:56:15
Author: iulius
Revision: 7810
Remove the redefinition of Net::NNTP::new() so as to use the function
provided by Net::NNTP >= 2.18 since 1998.
Also fix some warnings.
Modified:
trunk/frontends/pullnews.in
-------------+
pullnews.in | 105 ++++++----------------------------------------------------
1 file changed, 12 insertions(+), 93 deletions(-)
Modified: pullnews.in
===================================================================
--- pullnews.in 2008-04-28 13:14:25 UTC (rev 7809)
+++ pullnews.in 2008-04-28 17:56:15 UTC (rev 7810)
@@ -1,11 +1,10 @@
-#! /usr/bin/perl
+#! /usr/bin/perl -w
#
# Author: James Brister <brister at vix.com> -- berkeley-unix --
# Start Date: Sat, 10 Oct 1998 21:40:11 +0200
# Project: INN
# File: pullnews.pl
# RCSId: $Id$
-# Time-stamp: <Friday, 7 April 2000 15:17:12 by brister at nominum.com>
# Description: A very simple pull feeder. Connects to multiple remote
# machines (in the guise of a reader), and pulls over articles
# and feeds them to the local server (in the guise of a feeder).
@@ -24,7 +23,7 @@
# uunet.announce 0 0
# uunet.help 0 0
#
-# hostname line has no leading space on it and an optional
+# Hostname line has no leading space on it and an optional
# username and password after the hostname; all the
# subsequent group lines for that host must have leading
# spaces. The two integers on the group line will be updated by
@@ -33,20 +32,6 @@
# over.
#
-#
-# NOTE NOTE NOTE NOTE:
-#
-# The Packages Net::NNTP is required *AND* the function Net::NNTP::new is
-# redefined in this file. If you're using a new release of Net::NTTP *AND*
-# if the Net::NNTP::new function supplied there does NOT call the
-# $obj->reader() function, then you can remove the redefinition in here.
-#
-# Net::NNTP is part of the libnet bundle by Graham Barr and is available
-# from CPAN:
-#
-# http://www.cpan.org/
-#
-
# TODO
# - Have option to reset the highwater marks to match whatever
# is on the remote server.
@@ -67,7 +52,8 @@
$SIG{INT} = \&outtaHere ;
$SIG{QUIT} = \&bail ;
-use Net::NNTP;
+use Net::NNTP 2.18; # With libnet 1.0606 (10-Dec-1998) because older versions
+ # issued MODE READER with Net::NNTP::new().
use Getopt::Std;
use IO::Handle;
use Fcntl;
@@ -182,7 +168,7 @@
if (m!^(\S+)\s*((\S+)\s+(\S+))?$!) {
$sname = $1 ;
$servers->{$sname} = {} ;
- $passwd{$sname} = [ $3, $4 ] if ($3 ne "");
+ $passwd{$sname} = [ $3, $4 ] if (defined($3) && $3 ne "");
} elsif (m!^\s+(\S+)\s+(\d+)\s+(\d+)!) {
my ($group,$date,$high) = ($1,$2,$3) ;
$servers->{$sname}->{$group} = [ $date, $high ];
@@ -208,7 +194,8 @@
"port: $localPort ..."
unless $quiet;
- my %localopts = ("Port" => "$localPort");
+ my %localopts = ("Port" => "$localPort",
+ "Reader" => 0);
$localcxn = Net::NNTP->new($localServer, %localopts) ||
die "can't connect to server $localServer\n" ;
}
@@ -251,7 +238,8 @@
my $shash = $servers->{$server} ;
print LOG "connecting to upstream server $server..." unless $quiet ;
- my $upstream = Net::NNTP->new($server) ;
+ my %localopts = ("Reader" => 0);
+ my $upstream = Net::NNTP->new($server, %localopts) ;
if (!$upstream) {
print LOG "failed." unless $quiet;
@@ -292,9 +280,9 @@
#########################
sub stats {
- my $ltotal ;
- my $reftotal ;
- my $rejtotal ;
+ my $ltotal = 0;
+ my $reftotal = 0;
+ my $rejtotal = 0;
my $sum;
map { $reftotal += $refused{$_} } keys %refused;
@@ -495,72 +483,3 @@
return 1;
}
-package Net::NNTP ;
-
-## Slightly modified implementation of the Net::NNTP::new function. The
-## original definition automatically sent a MODE READER command over which
-## breaks when trying to feed INN via IHAVE.
-
-sub new
-{
- my $self = shift;
- my $type = ref($self) || $self;
- my $host = shift if @_ % 2;
- my %arg = @_;
- my $obj;
-
- $host ||= $ENV{NNTPSERVER} || $ENV{NEWSHOST};
-
- my $hosts = defined $host ? [$host] : $NetConfig{nntp_hosts};
-
- @{$hosts} = qw(news)
- unless @{$hosts};
-
- 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
- ) and last;
- }
-
- return undef
- unless defined $obj;
-
- ${*$obj}{'net_nntp_host'} = $host;
-
- $obj->autoflush(1);
- $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef);
-
- unless ($obj->response() == CMD_OK)
- {
- $obj->close;
- return undef;
- }
-
-##++ brister removed the bit below.
-## my $c = $obj->code;
-## my @m = $obj->message;
-##
-## # if server is INN and we have transfer rights the we are currently
-## # talking to innd not nnrpd
-## if($obj->reader)
-## {
-## # If reader suceeds the we need to consider this code to determine postok
-## $c = $obj->code;
-## }
-## else
-## {
-## # I want to ignore this failure, so restore the previous status.
-## $obj->set_status($c,\@m);
-## }
-## ${*$obj}{'net_nntp_post'} = $c == ? 1 : 0;
-##--
-
- $obj;
-}
-
More information about the inn-committers
mailing list