X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXMsg.pm;h=bb8cbb68331692ce272df62b938c94c54e27f6bd;hb=417f55d271551683dfe1a49fb754024ba4731363;hp=f3c2172cfba7c45c70e7fa5d3c12353853dd2b92;hpb=48d614dae214326305879ac572d8c5f0a6150f99;p=spider.git diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index f3c2172c..bb8cbb68 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -27,6 +27,13 @@ use IO::File; use Fcntl; use strict; + +use vars qw($VERSION $BRANCH); +$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); +$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0; +$main::build += $VERSION; +$main::branch += $BRANCH; + use vars qw(%work @msg $msgdir %valid %busy $maxage $last_clean @badmsg @swop $swopfn $badmsgfn $forwardfn @forward $timeout $waittime $queueinterval $lastq $importfn $minchunk $maxchunk $bulltopriv); @@ -168,7 +175,7 @@ sub process if (exists $busy{$fromnode}) { my $ref = $busy{$fromnode}; - my $tonode = $ref->{tonode}; + my $tonode = $ref->{tonode} || "unknown"; dbg("Busy, stopping msgno: $ref->{msgno} $fromnode->$tonode") if isdbg('msg'); $ref->stop_msg($self->call); } @@ -274,8 +281,8 @@ sub process if ($ref->{subject} eq $m->{subject} && $ref->{t} == $m->{t} && $ref->{from} eq $m->{from} && $ref->{to} eq $m->{to}) { $ref->stop_msg($self->call); my $msgno = $m->{msgno}; - dbg("duplicate message from $ref->{from} -> $ref->{to} to $msgno") if isdbg('msg'); - Log('msg', "duplicate message from $ref->{from} -> $ref->{to} to $msgno"); + dbg("duplicate message from $ref->{from} -> $ref->{to} to msg: $msgno") if isdbg('msg'); + Log('msg', "duplicate message from $ref->{from} -> $ref->{to} to msg: $msgno"); return; } } @@ -291,6 +298,23 @@ sub process return; } + # check the message for bad words + my @words; + for (@{$ref->{lines}}) { + push @words, BadWords::check($_); + } + push @words, BadWords::check($ref->{subject}); + if (@words) { + dbg("message with badwords '@words' $ref->{from} -> $ref->{to} '$ref->{subject}' origin: $ref->{origin}") if isdbg('msg'); + Log('msg',"message with badwords '@words' $ref->{from} -> $ref->{to} origin: $ref->{origin}"); + Log('msg',"subject: $ref->{subject}"); + for (@{$ref->{lines}}) { + Log('msg', "line: $_"); + } + $ref->stop_msg($self->call); + return; + } + $ref->{msgno} = next_transno("Msgno"); push @{$ref->{gotit}}, $f[2]; # mark this up as being received $ref->store($ref->{lines}); @@ -382,7 +406,7 @@ sub process if ($_->{from} eq $f[1] && $_->{subject} eq $f[2]) { $_->del_msg(); Log('msg', "Message $_->{msgno} from $_->{from} ($_->{subject}) fully deleted"); - DXProt::broadcast_ak1a($line, $self); + DXChannel::broadcast_nodes($line, $self); } } } @@ -580,7 +604,6 @@ sub send_tranche sub queue_msg { my $sort = shift; - my $call = shift; my $ref; my $clref; @@ -634,23 +657,26 @@ sub queue_msg dbg("Route: No dxchan for $ref->{to} " . ref($clref) ) if isdbg('msg'); } } - } - - # otherwise we are dealing with a bulletin or forwarded private message - # compare the gotit list with - # the nodelist up above, if there are sites that haven't got it yet - # then start sending it - what happens when we get loops is anyone's - # guess, use (to, from, time, subject) tuple? - foreach $dxchan (@nodelist) { - my $call = $dxchan->call; - next unless $call; - next if $call eq $main::mycall; - next if ref $ref->{gotit} && grep $_ eq $call, @{$ref->{gotit}}; - next unless $ref->forward_it($call); # check the forwarding file - - # if we are here we have a node that doesn't have this message - $ref->start_msg($dxchan) if !get_busy($call) && $dxchan->state eq 'normal'; - last; + } else { + + # otherwise we are dealing with a bulletin or forwarded private message + # compare the gotit list with + # the nodelist up above, if there are sites that haven't got it yet + # then start sending it - what happens when we get loops is anyone's + # guess, use (to, from, time, subject) tuple? + foreach $dxchan (@nodelist) { + my $call = $dxchan->call; + next unless $call; + next if $call eq $main::mycall; + next if ref $ref->{gotit} && grep $_ eq $call, @{$ref->{gotit}}; + next unless $ref->forward_it($call); # check the forwarding file + + # if we are here we have a node that doesn't have this message + if (!get_busy($call) && $dxchan->state eq 'normal') { + $ref->start_msg($dxchan); + last; + } + } } # if all the available nodes are busy then stop @@ -686,7 +712,15 @@ sub start_msg $busy{$self->{tonode}} = $self; $work{$self->{tonode}} = $self; $self->{lastt} = $main::systime; - $dxchan->send(DXProt::pc28($self->{tonode}, $self->{fromnode}, $self->{to}, $self->{from}, $self->{t}, $self->{private}, $self->{subject}, $self->{origin}, $self->{rrreq})); + my ($fromnode, $origin); + if ($dxchan->is_arcluster) { + $fromnode = $self->{origin}; + $origin = $self->{fromnode}; + } else { + $fromnode = $self->{fromnode}; + $origin = $self->{origin}; + } + $dxchan->send(DXProt::pc28($self->{tonode}, $fromnode, $self->{to}, $self->{from}, $self->{t}, $self->{private}, $self->{subject}, $origin, $self->{rrreq})); } # get the ref of a busy node @@ -851,6 +885,10 @@ sub do_send_stuff # $DB::single = 1; confess "local var gone missing" if !ref $self->{loc}; my $loc = $self->{loc}; + if (my @ans = BadWords::check($line)) { + Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} in msg"); + return ($self->msg('e17', @ans), $self->msg('m1')); + } $loc->{subject} = $line; $loc->{lines} = []; $self->state('sendbody'); @@ -903,12 +941,17 @@ sub do_send_stuff $self->func(undef); $self->state('prompt'); } else { + if (my @ans = BadWords::check($line)) { + Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} subject: '$loc->{subject}' in msg"); + Log('msg', "line: $line"); + return ($self->msg('e17', @ans)); + } # i.e. it ain't and end or abort, therefore store the line push @{$loc->{lines}}, length($line) > 0 ? $line : " "; } } - return (1, @out); + return @out; } # return the standard directory line for this ref @@ -1094,7 +1137,7 @@ sub import_msgs my @msg = map { chomp; $_ } ; close(MSG); unlink($fn); - my @out = import_one($DXProt::me, \@msg, $splitit); + my @out = import_one($main::me, \@msg, $splitit); Log('msg', @out); } }