On 1/26/2014 00:57, Cal Dershowitz wrote:
> Howdy newsgroup,
>
> I'm a little bit bored and have decided to indulge a hobby project. I have one binary group that I download: alt.binaries.humor.skewed, and it has been a great group over the years, but recently is beset by so much nauseating racism, that I can't look at it anymore. If I didn't go out of my way to disavow it tonight, the arbitrary advanced observer might notice these unwanted images coming to my machine and think that I have some sympathy for them.
>
> So it is that I will either write an effective way to avoid these images, or I'll scale back to NIN and avoid the world of usenet binaries altogether. I figure they're not more clever than a well-written regex.
>
> So I've started this great thing, downloaded News::NNTPClient, man'ed it a couple times, and I thought I would find a means of authentication in there that would be the analog of ftp'ing, but I haven't:
<code here>
> On my machine, the values in %config are all populated, so I thought I would just re-write get_ftp_object with a get_nntp_object , but I don't see the equivalent of a login method.
>
> Thanks for your comment, and cheers from the great state of california.
I stripped some code out of a working script that should help you -
just fill in the host/user/pass/ip fields and maybe change the loop
index to something other than 10:
#!perl --
use strict;
use warnings;
use Net::NNTP;
my $group = 'alt.test'; # newsgroup
my $host = ''; # server hostname
my $user = ''; # username - null skips authorization
my $pass = ''; # password
my $ip = ''; # IP addr - I use this just in case DNS is down
# create news server connection
print "New NNTP connection to $host\n";
my $nntp;
if (not $nntp = Net::NNTP->new($host, Timeout => 15)) {
warn "Cannot connect to $host: $! ($^E)";
if (not $nntp = Net::NNTP->new($ip, Timeout => 15)) {
die "Cannot connect to $ip: $! ($^E)";
}
}
# login
print "sending auth\n";
$nntp->authinfo ($user, $pass) or die "nntp->authinfo: $! ($^E)" if $user;
# set newsgroup
print "Setting group\n";
my ($cnt, $first, $last, $grp) = $nntp->group($group) or
die "group failed: $! ($^E)";
print "cnt=$cnt, first=$first, last=$last, grp=$grp\n";
# start at last message
my $msgnum = $last;
for (my $ii = 0; $ii < 10; $ii++) {
# get msg header
print "get $msgnum head\n";
my $head = $nntp->head($msgnum) or do {
warn "nntp->head $msgnum failed: $! ($^E)";
goto next_msg; # skip message - you could retry
};
print "head has ", scalar @$head, " lines\n";
# filter msg based on header
# ... <your code here>
# get msg body
print "get $msgnum body\n";
my $bodyref = $nntp->body($msgnum) or do {
die "nntp->body $msgnum failed: $!\n";
next;
};
print "body has ", scalar @$bodyref, " lines\n";
next_msg:
# go to prior message
my $msgid;
unless ($msgid = $nntp->last()) {
print "nntp->last($ii): $!\n";
last;
}
print "last: $msgid\n";
# get msg number for header request
$msgnum = $nntp->message();
chomp $msgnum;
print "message: $msgnum\n";
$msgnum =~ s/^\s*(\d+)\s+.*$//;
}
$nntp->quit;
__END__
> Howdy newsgroup,
>
> I'm a little bit bored and have decided to indulge a hobby project. I have one binary group that I download: alt.binaries.humor.skewed, and it has been a great group over the years, but recently is beset by so much nauseating racism, that I can't look at it anymore. If I didn't go out of my way to disavow it tonight, the arbitrary advanced observer might notice these unwanted images coming to my machine and think that I have some sympathy for them.
>
> So it is that I will either write an effective way to avoid these images, or I'll scale back to NIN and avoid the world of usenet binaries altogether. I figure they're not more clever than a well-written regex.
>
> So I've started this great thing, downloaded News::NNTPClient, man'ed it a couple times, and I thought I would find a means of authentication in there that would be the analog of ftp'ing, but I haven't:
<code here>
> On my machine, the values in %config are all populated, so I thought I would just re-write get_ftp_object with a get_nntp_object , but I don't see the equivalent of a login method.
>
> Thanks for your comment, and cheers from the great state of california.
I stripped some code out of a working script that should help you -
just fill in the host/user/pass/ip fields and maybe change the loop
index to something other than 10:
#!perl --
use strict;
use warnings;
use Net::NNTP;
my $group = 'alt.test'; # newsgroup
my $host = ''; # server hostname
my $user = ''; # username - null skips authorization
my $pass = ''; # password
my $ip = ''; # IP addr - I use this just in case DNS is down
# create news server connection
print "New NNTP connection to $host\n";
my $nntp;
if (not $nntp = Net::NNTP->new($host, Timeout => 15)) {
warn "Cannot connect to $host: $! ($^E)";
if (not $nntp = Net::NNTP->new($ip, Timeout => 15)) {
die "Cannot connect to $ip: $! ($^E)";
}
}
# login
print "sending auth\n";
$nntp->authinfo ($user, $pass) or die "nntp->authinfo: $! ($^E)" if $user;
# set newsgroup
print "Setting group\n";
my ($cnt, $first, $last, $grp) = $nntp->group($group) or
die "group failed: $! ($^E)";
print "cnt=$cnt, first=$first, last=$last, grp=$grp\n";
# start at last message
my $msgnum = $last;
for (my $ii = 0; $ii < 10; $ii++) {
# get msg header
print "get $msgnum head\n";
my $head = $nntp->head($msgnum) or do {
warn "nntp->head $msgnum failed: $! ($^E)";
goto next_msg; # skip message - you could retry
};
print "head has ", scalar @$head, " lines\n";
# filter msg based on header
# ... <your code here>
# get msg body
print "get $msgnum body\n";
my $bodyref = $nntp->body($msgnum) or do {
die "nntp->body $msgnum failed: $!\n";
next;
};
print "body has ", scalar @$bodyref, " lines\n";
next_msg:
# go to prior message
my $msgid;
unless ($msgid = $nntp->last()) {
print "nntp->last($ii): $!\n";
last;
}
print "last: $msgid\n";
# get msg number for header request
$msgnum = $nntp->message();
chomp $msgnum;
print "message: $msgnum\n";
$msgnum =~ s/^\s*(\d+)\s+.*$//;
}
$nntp->quit;
__END__
Aucun commentaire:
Enregistrer un commentaire