Compare commits
3 Commits
c95c26afd7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd37554b7d | ||
|
|
0a9b0cc631 | ||
| eca99567d8 |
25
maxmind.js
25
maxmind.js
@@ -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);
|
||||
@@ -112,6 +114,11 @@ async function downloadAndExtractMaxmindData(url, outputDir, tempDir, username,
|
||||
* @return {Promise<void>} Resolves when the data check and optional update process is completed.
|
||||
*/
|
||||
async function checkAndUpdateMaxmindData(outputDir, tempDir, url, username, password) {
|
||||
if (username === '' || password === '') {
|
||||
console.log('No MaxMind credentials provided. Skipping MaxMind database update.');
|
||||
return
|
||||
}
|
||||
|
||||
console.log('Checking for MaxMind database updates.');
|
||||
|
||||
// Ensure the output directory exists
|
||||
@@ -146,21 +153,25 @@ async function checkAndUpdateMaxmindData(outputDir, tempDir, url, username, pass
|
||||
|
||||
const url = 'https://download.maxmind.com/geoip/databases/GeoIP2-Country/download?suffix=tar.gz';
|
||||
const outputDirectory = './maxmind';
|
||||
const username = '1102431';
|
||||
const password = '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';
|
||||
// const username = process.env.MAXMIND_ACCOUNT_NUMBER;
|
||||
// const password = process.env.MAXMIND_LICENSE_KEY;
|
||||
// const username = '1102431';
|
||||
// const password = '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';
|
||||
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) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta property="og:title" content="Dexorder Trade Setup">
|
||||
<meta property="og:description" content="Trade this setup on Dexorder">
|
||||
<meta property="og:image" content="{{{imageUrl}}}">
|
||||
<meta property="og:url" content="https://dexorder.com/">
|
||||
<meta property="og:url" content="https://app.dexorder.com/">
|
||||
<meta property="og:type" content="website">
|
||||
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
|
||||
Reference in New Issue
Block a user