Merge branch 'work-even-if-dns-fails' into development

This commit is contained in:
ilyaigpetrov 2021-09-15 16:30:18 +00:00
commit 8f00516d44
5 changed files with 25 additions and 32 deletions

View File

@ -275,7 +275,10 @@
<br/> <a href="https://rebrand.ly/ac-pacs">Comparison of PAC-scripts (ru)</a>. <br/> <a href="https://rebrand.ly/ac-pacs">Comparison of PAC-scripts (ru)</a>.
\`, \`,
order: 0, order: 0,
pacUrls: ['https://antizapret.prostovpn.org/proxy.pac'], pacUrls: [
'https://antizapret.prostovpn.org/proxy.pac',
'https://rebrand.ly/ac-antizapret-pac',
],
}, },
Антицензорити: { Антицензорити: {
distinctKey: 'Anticensority', distinctKey: 'Anticensority',
@ -469,25 +472,28 @@
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) {
warns.push(ipsErr); warns.push(ipsErr);
} }
if (ipsWarns.length) {
warns.push(...ipsWarns);
}
this.pushToStorageAsync( this.pushToStorageAsync(
(pushErr) => cb(pacErr || pushErr, null, ...warns), (pushErr) => cb(pacErr || pushErr, null, ...warns),
); );

View File

@ -87,7 +87,7 @@
"message": "Error" "message": "Error"
}, },
"Non_critical_error": { "Non_critical_error": {
"message": "Non-critical error" "message": "Non-critical error. Don't worry: it works"
}, },
"Donate": { "Donate": {
"message": "Donate" "message": "Donate"

View File

@ -87,7 +87,7 @@
"message": "Ошибка" "message": "Ошибка"
}, },
"Non_critical_error": { "Non_critical_error": {
"message": "Некритичная ошибка" "message": "Некритичная ошибка. Всё хорошо, продолжаем работу"
}, },
"Donate": { "Donate": {
"message": "Поддержать" "message": "Поддержать"

View File

@ -266,7 +266,6 @@ export default function getApp(theState) {
this.setStatusTo(beforeStatus); this.setStatusTo(beforeStatus);
this.switchInputs('off'); this.switchInputs('off');
operation((err, res, ...warns) => { operation((err, res, ...warns) => {
warns = warns.filter( (w) => w ); warns = warns.filter( (w) => w );
if (err || warns.length) { if (err || warns.length) {
this.showErrors(err, ...warns); this.showErrors(err, ...warns);

View File

@ -231,12 +231,11 @@
getIpsFor(hostStr, (err, ips, ...warns) => { getIpsFor(hostStr, (err, ips, ...warns) => {
console.log('Got IPs + err?:', ips, err); console.log('Got IPs + err?:', ips, err);
if (!err) { if (err) {
resolveIps(ips);
} else {
reject([err, null, ...warns]); reject([err, null, ...warns]);
return;
} }
resolveIps(ips);
}); });
}).then( }).then(
@ -273,29 +272,18 @@
); );
Promise.all( promises ).then( (cbsRes) => { Promise.all( promises ).then( (cbsRes) => {
const errors = cbsRes.map( ([err]) => err ).filter( (err) => err ); let ipErrors = cbsRes.map( ([err]) => err ).filter( (err) => err );
let newError; let warns = [];
const ifAllErrors = cbsRes.length === errors.length; if (ipErrors.length) {
if (errors.length) { warns = [clarify(
if (ifAllErrors) { ipErrors,
newError = errors.shift();
} else {
newError = errors;
}
newError = clarify(
newError,
'Не удалось получить один или несколько IP адресов для' + 'Не удалось получить один или несколько IP адресов для' +
' прокси-серверов. Иконка для уведомления об обходе' + ' прокси-серверов. Иконка для уведомления об обходе' +
' блокировок может не отображаться.' ' блокировок может не отображаться.'
); )];
if (ifAllErrors) { } else {}
return cb(newError); cb(null, null, ...warns);
}
}
cb(null, null, newError);
}); });
}, },
_replaceAllAsync(hostArr = mandatory(), cb) { _replaceAllAsync(hostArr = mandatory(), cb) {