@@ -14,7 +14,7 @@ use File::Spec;
1414
1515use constant DSHIELD_BASE => ' https://secure.dshield.org/api/sources/attacks/100/' ;
1616
17- our %blacklist_countries = (
17+ my %blacklist_countries = (
1818 ' BY' => 1,
1919 ' MD' => 1,
2020 ' RU' => 1,
@@ -35,7 +35,7 @@ our %blacklist_countries = (
3535 ' XH' => 1,
3636);
3737
38- our %blacklist_agents = (
38+ my %blacklist_agents = (
3939 ' Barkrowler' => ' Barkrowler' ,
4040 ' masscan' => ' Masscan' ,
4141 ' WBSearchBot' => ' Warebay' ,
@@ -48,7 +48,7 @@ our %blacklist_agents = (
4848 ' ZoominfoBot (zoominfobot at zoominfo dot com)' => ' zoominfobot' ,
4949);
5050
51- our %status ;
51+ my %status ;
5252
5353my $STATUS_TTL = 300; # 5 minutes; keeps memory bounded and lets throttle windows expire
5454
@@ -139,13 +139,16 @@ sub allow {
139139 }
140140 };
141141 if ($@ ) {
142- # Genuine YAML/IO error from Data::Throttler — delete the corrupt DB and continue
143- if ($logger ) {
144- $logger -> info(" removing $db_file : $@ " );
145- } elsif (ref ($@ ) && $@ -> isa(' Error' )) {
146- # Deliberate block (throttle) — re-throw so caller sees the denial
142+ if (ref ($@ ) && $@ -> isa(' Error' )) {
143+ # Deliberate throttle block: re-throw so the caller sees the denial.
144+ # Do NOT unlink the DB here -- that would erase the throttle window.
147145 $@ -> throw();
148146 }
147+ # Genuine YAML/IO error from Data::Throttler -- remove the corrupt file
148+ # and fall through so this request is served (fail open).
149+ if ($logger ) {
150+ $logger -> info(" removing corrupt throttle DB $db_file : $@ " );
151+ }
149152 unlink ($db_file );
150153 }
151154
@@ -242,7 +245,7 @@ sub allow {
242245 my $cache = $args {' cache' };
243246 if (!defined ($cache )) {
244247 throw Error::Simple(' Either cache or config must be given' ) unless ($args {config });
245- $cache = ::create_memory_cache(config => $args {' config' }, namespace => __PACKAGE__ , logger => $logger );
248+ $cache = VWF::Utils ::create_memory_cache(config => $args {' config' }, namespace => __PACKAGE__ , logger => $logger );
246249 }
247250 if (defined ($cache )) {
248251 my $cachecontent = $cache -> get($today );
0 commit comments