Skip to content

Commit

Permalink
whitelist: handle whitelist load error
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Nov 13, 2024
1 parent bc935b6 commit e807c44
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions lib/whitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,25 @@
options.headers['If-Modified-Since'] = whitelistLastModified;
}

got(options).then(response => {
const newWhitelist = response.body;

if (response.statusCode === 500) {
console.error('Error loading domains list from ' + CONFIG.WHITELIST_URL + ' : ' + newWhitelist);
} else if (response.statusCode === 304) {
log('Whitelist respond: 304 (not modified)');
} else if (!newWhitelist || typeof newWhitelist === 'string') {
console.error('Error loading domains list from ' + CONFIG.WHITELIST_URL + ' : incorrect data: ' + newWhitelist);
} else {
whitelistLastModified = response.headers['last-modified'];
applyParsedWhitelist(newWhitelist);
}
got(options)
.then(response => {
const newWhitelist = response.body;

if (response.statusCode === 500) {
console.error('Error loading domains list from ' + CONFIG.WHITELIST_URL + ' : ' + newWhitelist);
} else if (response.statusCode === 304) {
log('Whitelist respond: 304 (not modified)');
} else if (!newWhitelist || typeof newWhitelist === 'string') {
console.error('Error loading domains list from ' + CONFIG.WHITELIST_URL + ' : incorrect data: ' + newWhitelist);
} else {
whitelistLastModified = response.headers['last-modified'];
applyParsedWhitelist(newWhitelist);
}

setTimeout(loadWhitelistUrl, CONFIG.WHITELIST_URL_RELOAD_PERIOD);
});
setTimeout(loadWhitelistUrl, CONFIG.WHITELIST_URL_RELOAD_PERIOD);
})
.catch(error => {
console.error('Error loading domains list from ' + CONFIG.WHITELIST_URL + ':', error.message);
});
}
}
}

0 comments on commit e807c44

Please sign in to comment.