Compare commits
3 Commits
c95c26afd7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd37554b7d | ||
|
|
0a9b0cc631 | ||
| eca99567d8 |
19
maxmind.js
19
maxmind.js
@@ -3,6 +3,8 @@ import path from 'path';
|
|||||||
import {extract} from "tar";
|
import {extract} from "tar";
|
||||||
import {Reader} from '@maxmind/geoip2-node';
|
import {Reader} from '@maxmind/geoip2-node';
|
||||||
|
|
||||||
|
const ENABLE_MAXMIND=false
|
||||||
|
|
||||||
let ipdb = null
|
let ipdb = null
|
||||||
function setDbFile(file) {
|
function setDbFile(file) {
|
||||||
const dbBuffer = fs.readFileSync(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.
|
* @return {Promise<void>} Resolves when the data check and optional update process is completed.
|
||||||
*/
|
*/
|
||||||
async function checkAndUpdateMaxmindData(outputDir, tempDir, url, username, password) {
|
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.');
|
console.log('Checking for MaxMind database updates.');
|
||||||
|
|
||||||
// Ensure the output directory exists
|
// Ensure the output directory exists
|
||||||
@@ -146,10 +153,12 @@ async function checkAndUpdateMaxmindData(outputDir, tempDir, url, username, pass
|
|||||||
|
|
||||||
const url = 'https://download.maxmind.com/geoip/databases/GeoIP2-Country/download?suffix=tar.gz';
|
const url = 'https://download.maxmind.com/geoip/databases/GeoIP2-Country/download?suffix=tar.gz';
|
||||||
const outputDirectory = './maxmind';
|
const outputDirectory = './maxmind';
|
||||||
const username = '1102431';
|
// const username = '1102431';
|
||||||
const password = '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';
|
// const password = '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';
|
||||||
// const username = process.env.MAXMIND_ACCOUNT_NUMBER;
|
const username = process.env.MAXMIND_ACCOUNT_NUMBER;
|
||||||
// const password = process.env.MAXMIND_LICENSE_KEY;
|
const password = process.env.MAXMIND_LICENSE_KEY;
|
||||||
|
|
||||||
|
if( ENABLE_MAXMIND ) {
|
||||||
|
|
||||||
await checkAndUpdateMaxmindData(outputDirectory, '/tmp', url, username, password);
|
await checkAndUpdateMaxmindData(outputDirectory, '/tmp', url, username, password);
|
||||||
|
|
||||||
@@ -162,6 +171,8 @@ setInterval(async () => {
|
|||||||
}
|
}
|
||||||
}, 24 * 60 * 60 * 1000 + 1000); // 1 day + 1 second
|
}, 24 * 60 * 60 * 1000 + 1000); // 1 day + 1 second
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function countryForIP(ipAddress) {
|
export function countryForIP(ipAddress) {
|
||||||
if (!ipdb) return null
|
if (!ipdb) return null
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta property="og:title" content="Dexorder Trade Setup">
|
<meta property="og:title" content="Dexorder Trade Setup">
|
||||||
<meta property="og:description" content="Trade this setup on Dexorder">
|
<meta property="og:description" content="Trade this setup on Dexorder">
|
||||||
<meta property="og:image" content="{{{imageUrl}}}">
|
<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 property="og:type" content="website">
|
||||||
|
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
|||||||
Reference in New Issue
Block a user