Add retries (finished, test0)

This commit is contained in:
ilyaigpetrov 2021-05-24 17:30:43 +00:00
parent 699bef6fea
commit b5154f6453
2 changed files with 15 additions and 9 deletions

View File

@ -229,7 +229,7 @@
Promise.reject(), Promise.reject(),
); );
return (ifUnattended return (ifUnattended
? tryPromiseSeveralTimesAsync(tryAllUrlsAsync, [10, 20, 30]) ? tryPromiseSeveralTimesAsync(tryAllUrlsAsync, [20, 40, 60])
: tryAllUrlsAsync() : tryAllUrlsAsync()
).catch( ).catch(
(err) => Promise.reject(clarify( (err) => Promise.reject(clarify(
@ -275,7 +275,7 @@
<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://AAAAAAAAAantizapret.prostovpn.org/proxy.pac'], pacUrls: ['https://antizapret.prostovpn.org/proxy.pac'],
}, },
Антицензорити: { Антицензорити: {
distinctKey: 'Anticensority', distinctKey: 'Anticensority',
@ -441,8 +441,6 @@
const pacProvider = this.getPacProvider(key); const pacProvider = this.getPacProvider(key);
ifUnattended = true; // TODO:
const pacSetPromise = new Promise( const pacSetPromise = new Promise(
(resolve, reject) => setPacScriptFromProviderAsync( (resolve, reject) => setPacScriptFromProviderAsync(
pacProvider, pacProvider,
@ -466,13 +464,19 @@
const updateIpsAsync = () => new Promise( const updateIpsAsync = () => new Promise(
(resolve, reject) => updatePacProxyIps( (resolve, reject) => updatePacProxyIps(
resolve, (err, res, ...warns) => {
if (err) {
reject([err, ...warns]);
return;
}
resolve(err, res, ...warns);
},
), ),
); );
const ipsErrorPromise = !ifUnattended const ipsErrorPromise = !ifUnattended
? updateIpsAsync() ? updateIpsAsync()
: tryPromiseSeveralTimesAsync(updateIpsAsync, [10, 20, 30]); : tryPromiseSeveralTimesAsync(updateIpsAsync, [20, 40, 60]);
Promise.all([pacSetPromise, ipsErrorPromise]).then( Promise.all([pacSetPromise, ipsErrorPromise]).then(
([[pacErr, pacRes, ...pacWarns], ipsErr]) => { ([[pacErr, pacRes, ...pacWarns], ipsErr]) => {
@ -622,7 +626,7 @@
'Periodic PAC update triggered:', 'Periodic PAC update triggered:',
new Date().toLocaleString('ru-RU'), new Date().toLocaleString('ru-RU'),
); );
antiCensorRu.syncWithPacProviderAsync(() => { /* Swallow. */ }); antiCensorRu.syncWithPacProviderAsync({ ifUnattended: true }, () => { /* Swallow. */ });
} }
}) })

View File

@ -112,7 +112,7 @@
const promises = types.map( const promises = types.map(
(type) => new Promise((resolve) => (type) => new Promise((resolve) =>
httpLib.get( httpLib.get(
`https://AAAAAAAAAdns.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) {
@ -255,7 +255,9 @@
_updateAllAsync(cb = mandatory()) { _updateAllAsync(cb = mandatory()) {
const hostArr = Object.keys(privates._strToHostObj); const hostArr = Object.keys(privates._strToHostObj)
.filter((hostStr) => hostStr !== 'localhost');
console.log('Update all:', hostArr); console.log('Update all:', hostArr);
const promises = hostArr.map( const promises = hostArr.map(