Chore: add fetch retry support

This commit is contained in:
SukkaW
2022-09-22 21:19:45 +08:00
parent ad542d45c8
commit a1098fbfcb
10 changed files with 59 additions and 14 deletions

View File

@@ -1,11 +1,11 @@
const { fetch } = require('undici');
const { fetchWithRetry } = require('./lib/fetch-retry');
const fs = require('fs');
const path = require('path');
const rDomain = /^(((?!\-))(xn\-\-)?[a-z0-9\-_]{0,61}[a-z0-9]{1,1}\.)*(xn\-\-)?([a-z0-9\-]{1,61}|[a-z0-9\-]{1,30})\.[a-z]{2,}$/m;
(async () => {
const res = (await (await fetch('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf')).text())
const res = (await (await fetchWithRetry('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf')).text())
.split('\n')
.map(line => {
if (line.startsWith('server=/') && line.endsWith('/114.114.114.114')) {