make extension robust to dns failures (test0)

This commit is contained in:
ilyaigpetrov 2021-08-27 16:19:50 +00:00
parent 5b3e6f1f51
commit 86d07b79c3
2 changed files with 8 additions and 9 deletions

View File

@ -469,24 +469,24 @@
reject([err, ...warns]); reject([err, ...warns]);
return; return;
} }
resolve(err, res, ...warns); resolve([err, res, ...warns]);
}, },
), ),
); );
const ipsErrorPromise = !ifUnattended const ipsPromise = !ifUnattended
? updateIpsAsync() ? updateIpsAsync()
: tryPromiseSeveralTimesAsync(updateIpsAsync, [20, 40, 60]); : tryPromiseSeveralTimesAsync(updateIpsAsync, [20, 40, 60]);
Promise.all([pacSetPromise, ipsErrorPromise]).then( Promise.all([pacSetPromise, ipsPromise]).then(
([[pacErr, pacRes, ...pacWarns], ipsErr]) => { ([[pacErr, pacRes, ...pacWarns], [ipsErr, ipsRes, ...ipsWarns]]) => {
if (pacErr && ipsErr) { if (pacErr) {
return cb(pacErr, pacRes); return cb(pacErr, pacRes);
} }
const warns = pacWarns; const warns = pacWarns;
if (ipsErr) { if (ipsErr || ipsWarns.length) {
warns.push(ipsErr); warns.push(...[ipsErr], ...ipsWarns);
} }
this.pushToStorageAsync( this.pushToStorageAsync(
(pushErr) => cb(pacErr || pushErr, null, ...warns), (pushErr) => cb(pacErr || pushErr, null, ...warns),

View File

@ -115,7 +115,7 @@
const promises = types.map( const promises = types.map(
(type) => new Promise((resolve) => (type) => new Promise((resolve) =>
httpLib.get( httpLib.get(
`https://dnsssssss.google.com/resolve?type=${type}&name=${host}&random_padding=${generateRandomHexString(30,500)}`, `https://dns.google.com/resolve?type=${type}&name=${host}&random_padding=${generateRandomHexString(30,500)}`,
(err, res) => { (err, res) => {
if (res) { if (res) {
@ -282,7 +282,6 @@
' блокировок может не отображаться.' ' блокировок может не отображаться.'
); );
} }
console.log('IP ERRORS:', ipErrors); // TODO:
cb(null, null, ipErrors); cb(null, null, ipErrors);
}); });
}, },