Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
fix: add BLOCKEXPLORER_GEOIP_WHITELIST env var
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Apr 29, 2019
1 parent 3d1e266 commit 1a8d911
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,20 @@ app.get('/blk/:id', (req, res) => {
sendBlockResult(req, res);
});

const geoipWhitelistFile =
process.env.BLOCKEXPLORER_GEOIP_WHITELIST || 'blockexplorer-geoip.yml';
let geoipWhitelist = {};
if (fs.existsSync('blockexplorer-geoip.yml')) {
if (fs.existsSync(geoipWhitelistFile)) {
try {
const file = fs.readFileSync('blockexplorer-geoip.yml', 'utf8');
const file = fs.readFileSync(geoipWhitelistFile, 'utf8');
geoipWhitelist = YAML.parse(file);
console.log('geoip whitelist:', geoipWhitelist);
console.log(
`Loaded geoip whitelist from ${geoipWhitelistFile}:`,
geoipWhitelist,
);
assert(typeof geoipWhitelist === 'object');
} catch (err) {
console.log(err);
console.log(`Failed to process ${geoipWhitelistFile}:`, err);
}
}

Expand Down

0 comments on commit 1a8d911

Please sign in to comment.