Skip to content

Commit

Permalink
rate limit improvment
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hansson <mailto@danielhansson.nu>
  • Loading branch information
enoch85 authored Oct 5, 2024
1 parent 1e4b17b commit 8bea869
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ curl "https://api.metadefender.com/v4/hash/$hash" -H "apikey: $apikey"

# Used in geoblock.sh
download_geoip_mmdb() {
# Do not download if less than 2 hour old file
# Rate limit to 1 hour, we have 24 requests per day
if [ -f "$GEOBLOCK_DIR/IPInfo-Country.mmdb" ]
then
if [ "$(( $(date +"%s") - $(stat -c "%Y" "$GEOBLOCK_DIR/IPInfo-Country.mmdb") ))" -lt "7200" ]
if [ "$(( $(date +"%s") - $(stat -c "%Y" "$GEOBLOCK_DIR/IPInfo-Country.mmdb") ))" -lt "3600" ]
then
print_text_in_color "$IGreen" "No need to update $GEOBLOCK_DIR/IPInfo-Country.mmdb since it's newer than 2 hours."
print_text_in_color "$IGreen" "No need to update $GEOBLOCK_DIR/IPInfo-Country.mmdb since it's newer than 1 hour."
return 1
fi
elif [ -f "$GEOBLOCK_DIR/GeoLite2-Country.mmdb" ]
Expand Down

0 comments on commit 8bea869

Please sign in to comment.