🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #50850

Re: CANLOCK status

#50850
From: Marco d'Itri
Date: Mon, 26 Feb 2001 19:24
122 lines
4091 bytes
urs@tin.org wrote:

>> There is the original implementation by Fluffy
>IIRC that one required as last INN 2.x. many ppl. are still running
Yes, but you can easily make it work with INN 1.x using this perl
module I wrote: http://www.linux.it/~md/software/News-ICC-0.2.tar.gz .
It's a native perl implementation of the interface used by ctlinnd.

>> and another one I wrote using more modern perl modules.
>just gessing (didn't find the source): requires INN => 2.x?
I wrote only the client part, but the code can be put in the original
cleanfeed add on:

# Copyright 1999 by Marco d'Itri <md.linux.it>
#
# This code may be used and/or distributed under the same terms as Perl
# itself.
#
# Based on the perl cancel lock implementation by Fluffy.

package News::Gateway;

use strict;

$HOOKS{canlock} = ['canlock'];
sub canlock_conf {
	my ($self, $directive, $command, $arg) = @_;
	if ($command eq 'secret') {
		$$self{LockSecret} = $arg;
	} elsif ($command eq 'usemd5') {
		$$self{LockMD5} = 1;
	}
	undef;	
}

sub canlock_mesg {
	my $self = shift;
	$self->get_article->add_canlock($$self{LockSecret}, $$self{LockMD5} || 0)
		and undef;
}

package News::Article;
use strict;
use Digest;
use Digest::HMAC;
use Digest::MD5;
use Digest::SHA1;

sub add_cancelkey {
	my ($self, $secret, $usemd5) = @_;
	my ($tocancel, $key);
	$secret || return undef;

	if (($self->header('control') || '') =~ /^\s+cancel\s+(.+)/i) {
		$tocancel = $1;
	} elsif ($tocancel == $self->header('supersedes')) {
	} else {
		return 1;
	}

	if ($usemd5) {
		$key = 'md5:'.make_key_md5($secret, $tocancel);
	} else {
		$key = 'sha1:'.make_key_sha1($secret, $tocancel);
	}

	my $o = $self->header('cancel-key');
	$self->set_headers('Cancel-Key', ($o ? "$o\n\t" : '') . $key);
	1;
}

sub add_canlock {
	my ($self, $secret, $usemd5) = @_;
	my $lock;
	$secret || return undef;

	$self->add_message_id;
	my $id = $self->header('message-id');
	if ($usemd5) {
		$lock = 'md5:'.make_canlock_md5($secret, $id);
	} else {
		$lock = 'sha1:'.make_canlock_sha1($secret, $id);
	}

	my $o = $self->header('cancel-lock');
	$self->set_headers('Cancel-Lock', ($o ? "$o\n\t" : '') . $lock);
	1;
}

sub make_key_md5 {
	my ($secret, $id) = @_;
	my $hmac = Digest::HMAC->new($secret, 'Digest::MD5');
	$hmac->add($id);
	return $hmac->b64digest.'==';
}

sub make_key_sha1 {
	my ($secret, $id) = @_;
	my $hmac = Digest::HMAC->new($secret, 'Digest::SHA1');
	$hmac->add($id);
	return $hmac->b64digest.'=';
}

sub make_canlock_md5 {
	my ($secret, $id) = @_;
	my $hash = Digest->new('MD5');
	$hash->add(make_key_md5($secret, $id));
	return $hash->b64digest.'==';
}

sub make_canlock_sha1 {
	my ($secret, $id) = @_;
	my $hash = Digest->new('SHA1');
	$hash->add(make_key_sha1($secret, $id));
	return $hash->b64digest.'=';
}

-- 
ciao, |
Marco | * The Internet is full. Go away.  -- Joel Furr *

Technical Details
Message-ID: <0t3a9aabbei14e6n3e9%md@wonderland.linux.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!freenix!fr.usenet-edu.net!usenet-edu.net!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!EU.net!newssrv.ita.tip.net!phobos.ibnetwork.net!bofh.it!wonderland.linux.it!not-for-mail
References: <87itlx904d.fsf@deneb.enyo.de> <0t3a9a5fediac2n3e9%md@wonderland.linux.it> <97e5oh$b4l$1@nntp.hamburg.pop.de>

Show Full Headers
Complete Article Headers
Message-ID: <0t3a9aabbei14e6n3e9%md@wonderland.linux.it>
Subject: Re: CANLOCK status
Date: Mon, 26 Feb 2001 19:24:29 +0000
From: Marco d'Itri <abuse@1.2.0.1.0.0.1.e.f.f.3.ip6.int>
References: <87itlx904d.fsf@deneb.enyo.de> <0t3a9a5fediac2n3e9%md@wonderland.linux.it> <97e5oh$b4l$1@nntp.hamburg.pop.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!freenix!fr.usenet-edu.net!usenet-edu.net!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!EU.net!newssrv.ita.tip.net!phobos.ibnetwork.net!bofh.it!wonderland.linux.it!not-for-mail
Newsgroups: news.software.nntp
Organization: Italian Linux Society - http://www.linux.it
Lines: 121
NNTP-Posting-Host: wonderland.bofh.it
X-Trace: wonderland.linux.it 983215469 5383 10.0.0.9 (26 Feb 2001 19:24:29 GMT)
X-Break-Your-Modem: +++ATH0
User-Agent: tin/1.4.5+Md-20001121 ("Vet for the Insane") (UNIX) (Linux/2.4.1 (i586))
NNTP-Posting-Date: Mon, 2736 Sep 1993 19:24:29 GMT