From 1a8d911c8db7c8ff31ba2b68ae112c3b5385f4a7 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 28 Apr 2019 17:09:21 -0700 Subject: [PATCH] fix: add BLOCKEXPLORER_GEOIP_WHITELIST env var --- api/api.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/api.js b/api/api.js index cef9a299..b826566c 100644 --- a/api/api.js +++ b/api/api.js @@ -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); } }