$text =~ s/[^\#a-zA-Z0-9]//g;
$text = substr($text, 0, $duplth) if length $text > $duplth;
my $dupkey = "A$call|$to|\L$text";
- return DXDupe::check($dupkey, $t);
+ return DXDupe::check_add($dupkey, $t);
}
sub listdups
use vars qw{$lasttime $dbm %d $default $fn};
-$default = 48*24*60*60;
+$default = 2*24*60*60;
$lasttime = 0;
localdata_mv("dupefile");
$fn = localdata("dupefile");
unlink $fn;
}
-sub check
+# NOTE: This checks for a duplicate and only adds a new entry if not found
+sub check_add
{
my $s = shift;
return 1 if find($s);
delete $d{$s};
}
-sub process
+sub per_minute
{
- # once an hour
- if ($main::systime - $lasttime >= 3600) {
- my @del;
- while (($k, $v) = each %d) {
- push @del, $k if $main::systime >= $v;
- }
- del($k) for @del;
- $lasttime = $main::systime;
+ my @del;
+ while (($k, $v) = each %d) {
+ push @del, $k if $main::systime >= $v;
}
+ del($k) for @del;
+ $lasttime = $main::systime;
}
sub get
my $dupage = shift;
my $regex = shift;
+ dbg("DXDupe::listdups let='$let' dupage='$dupage' input regex='$regex'") if isdbg('dxdupe');
+
$regex =~ s/[\^\$\@\%]//g;
$regex = ".*$regex" if $regex;
$regex = "^$let" . $regex;
+
+ dbg("DXDupe::listdups generated regex='$regex'") if isdbg('dxdupe');
+
my @out;
for (sort { $d{$a} <=> $d{$b} } grep { m{$regex}i } keys %d) {
my ($dum, $key) = unpack "a1a*", $_;
return;
}
-
# If we have an ip address we can promote by route
if ($rug && $rug->ip) {
$pcno = 61;
}
}
- # this goes after the input filtering, but before the add
- # so that if it is input filtered, it isn't added to the dup
- # list. This allows it to come in from a "legitimate" source
- #
- ## NOTE: this is where we insert the spot into the DXDupe cache
- #
- if (Spot::dup(@spot[0..4,7])) {
- dbg("PCPROT: Duplicate Spot $self->{call}: $pc->[0] $key ignored\n") if isdbg('chanerr') || isdbg('dupespot') || isdbg('pc11');
- return;
- }
-
dbg("PROCESSING $self->{call}: $pc->[0] key: $key") if isdbg('pc11');
if ($pcno == 11) {
}
}
+ # this goes after the input filtering, but before the actual add
+ # of the spot so that if it is input filtered, it isn't added to the dup
+ # list. This allows it to come in from a "legitimate" source
+ #
+ ## NOTE: this is where we FINALLY insert the spot into the DXDupe cache
+ ##
+ ## Jan 2025 - I have moved this here so that ONLY potential spots for
+ ## output to users are added to the duplicate cache
+ #
+ #
+
+ if (Spot::dup_add(0, @spot[0..4,7])) {
+ dbg("PCPROT: Duplicate Spot $self->{call}: $pc->[0] $key ignored\n") if isdbg('chanerr') || isdbg('dupespot') || isdbg('pc11');
+ return;
+ }
+
+ #
+ # Now finally: save the spot itself and send it on its merry way to the users
+ #
- # add it
Spot::add(@spot);
my $ip = '';
# now check that we have not seen this before
# this is based on the tuple (o (origin), t (time, normalised to time_t), id)
$xref->{'-timet'} = $t;
- return if DXDupe::check("xml,$o,$t,$id", $dupeage);
+ return if DXDupe::check_add("xml,$o,$t,$id", $dupeage);
my $r = bless $xref, $pkg;
$r->{'-xml'} = $line;
return 2 if $d < $main::systime - $dupage;
my $dupkey = "W$d|$sfi|$k|$a|$call";
- return DXDupe::check($dupkey, $main::systime+$dupage);
+ return DXDupe::check_add($dupkey, $main::systime+$dupage);
}
sub listdups
return "$s $comment$spotter";
}
-# enter the spot for dup checking and return true if it is already a dup
-sub dup
+# Add the dupe if it is new.
+sub dup_add
{
- my ($freq, $call, $d, $text, $by, $node, $just_find) = @_;
+ my ($just_find, $freq, $call, $d, $text, $by, $node) = @_;
dbg("Spot::dup: freq=$freq call=$call d=$d text='$text' by=$by node=$node" . ($just_find ? " jf=$just_find" : "")) if isdbg('spotdup');
# new feature: don't include the origin node in Spot dupes
# default = true
$node = '' if $no_node_in_dupe;
- $ldupkey = $oldstyle ? "X|$call|$by|$freq|$node|$d|$text" : "X|$call|$by|$qrg|$node|$nd|$text";
+ $ldupkey = $oldstyle ? "X$call|$by|$freq|$node|$d|$text" : "X$call|$by|$qrg|$node|$nd|$text";
$t = DXDupe::find($ldupkey);
dbg("Spot::dup ldupkey $ldupkey t '$t'" . ($t?' DUPE':' NEW')) if isdbg('spotdup');
$otext = substr($otext, 0, $duplth) if length $otext > $duplth;
$otext =~ s/\s+$//;
if (length $otext && $otext ne $text) {
- $ldupkey = $oldstyle ? "X|$call|$by|$freq|$otext" : "X|$call|$by|$qrg|$otext";
+ $ldupkey = $oldstyle ? "X$call|$by|$freq|$otext" : "X$call|$by|$qrg|$otext";
$t = DXDupe::find($ldupkey);
dbg("Spot::dup (OTEXT) ldupkey $ldupkey t '$t'" . ($t?' DUPE':' NEW')) if isdbg('spotdup');
if (isdbg('spottext')) {
sub dup_find
{
- return dup(@_, 1);
+ return dup_add(1, @_);
}
sub listdups
return 2 if $d < $main::systime - $dupage;
my $dupkey = "C$d";
- return DXDupe::check($dupkey, $main::systime+$dupage);
+ return DXDupe::check_add($dupkey, $main::systime+$dupage);
}
sub listdups
DXMsg::process();
DXDb::process();
DXUser::process();
- DXDupe::process();
IsoTime::update($systime);
DXConnect::process();
DXUser::process();
sub per_minute
{
RBN::per_minute();
+ DXDupe::per_minute();
}
sub per_10_minute
# seek to end of file
$fh->seek(0, 2);
for (;;) {
+ $fh->seek(0, 1);
my $line = $fh->getline;
if ($line) {
if (@patt) {