From cbbf83baa54e859c382de79954607923cbb1b653 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Wed, 11 Jan 2023 19:37:51 +0000 Subject: [PATCH] fix set/badip so that it appends to the existing file Because of some excess zeal on my part, I was overwriting, rather than appending to the existing file. Face Palm! --- Changes | 1 + cmd/set/badip.pl | 1 + perl/DXCIDR.pm | 9 ++++----- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 59ba86d6..7a2067f1 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,7 @@ 23 or 24 to get your own local copies. A 'set/debug badip' will show you what is being blocked. +3. Fix set/badip so that it appends new IP addresses correctly. 10Jan23======================================================================= 1. Add baddx on incoming callsign in RBN. 2. Search for all /spider/local_data/badip.* files to allow more control on diff --git a/cmd/set/badip.pl b/cmd/set/badip.pl index 3c4578ba..b33261b7 100644 --- a/cmd/set/badip.pl +++ b/cmd/set/badip.pl @@ -31,6 +31,7 @@ for my $ip (@in) { my $count = @added; my $list = join ' ', @in; DXCIDR::clean_prep(); +#$DB::single = 1; DXCIDR::append($suffix, @added); push @out, "set/badip: added $count entries to badip.$suffix : $list" if $count; return (1, @out); diff --git a/perl/DXCIDR.pm b/perl/DXCIDR.pm index fdade7fc..5a6272aa 100644 --- a/perl/DXCIDR.pm +++ b/perl/DXCIDR.pm @@ -88,14 +88,13 @@ sub append if ($suffix) { my $fn = _fn() . ".$suffix"; - my $r = rand; - my $fh = IO::File->new (">>$fn.$r"); - if ($fh) { + my $fh = IO::File->new; + if ($fh->open("$fn", "a+")) { + $fh->seek(0, 2); # belt and braces !! print $fh "$_\n" for @in; $fh->close; - move "$fn.$r", $fn; } else { - LogDbg('err', "DXCIDR::append error appending to $fn.$r $!"); + LogDbg('err', "DXCIDR::append error appending to $fn $!"); } } else { LogDbg('err', "DXCIDR::append require badip suffix"); -- 2.43.0