maxmind fix

This commit is contained in:
tim
2025-12-18 20:59:31 -04:00
parent 0a9b0cc631
commit bd37554b7d

View File

@@ -3,6 +3,8 @@ import path from 'path';
import {extract} from "tar";
import {Reader} from '@maxmind/geoip2-node';
const ENABLE_MAXMIND=false
let ipdb = null
function setDbFile(file) {
const dbBuffer = fs.readFileSync(file);
@@ -156,16 +158,20 @@ const outputDirectory = './maxmind';
const username = process.env.MAXMIND_ACCOUNT_NUMBER;
const password = process.env.MAXMIND_LICENSE_KEY;
await checkAndUpdateMaxmindData(outputDirectory, '/tmp', url, username, password);
if( ENABLE_MAXMIND ) {
await checkAndUpdateMaxmindData(outputDirectory, '/tmp', url, username, password);
setInterval(async () => {
setInterval(async () => {
try {
await checkAndUpdateMaxmindData(outputDirectory, '/tmp', url, username, password);
} catch (error) {
console.error('Error during MaxMind database update:', error);
}
}, 24 * 60 * 60 * 1000 + 1000); // 1 day + 1 second
}, 24 * 60 * 60 * 1000 + 1000); // 1 day + 1 second
}
export function countryForIP(ipAddress) {