This commit is contained in:
parent
f4f426a344
commit
b216baf619
@ -20,15 +20,24 @@ module.exports = async (client, apex, app) => {
|
|||||||
const ac = new AbortController(),
|
const ac = new AbortController(),
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
setImmediate(() => ac.abort())
|
setImmediate(() => ac.abort())
|
||||||
}, constant.abort_timeout),
|
}, constant.abort_timeout)
|
||||||
response = await fetch(uri, {
|
try {
|
||||||
|
const response = await fetch(uri, {
|
||||||
headers: { 'User-Agent': constant.agent },
|
headers: { 'User-Agent': constant.agent },
|
||||||
signal: ac.signal,
|
signal: ac.signal,
|
||||||
keepalive: false,
|
keepalive: false,
|
||||||
timeout: constant.timeout,
|
timeout: constant.timeout,
|
||||||
})
|
})
|
||||||
setImmediate(() => clearTimeout(timeout))
|
setImmediate(() => clearTimeout(timeout))
|
||||||
return await response.json()
|
return await response.json()
|
||||||
|
} catch (e) {
|
||||||
|
setImmediate(() => {
|
||||||
|
clearTimeout(timeout)
|
||||||
|
ac.abort()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
// console.error(e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
scanInstance = async instance => {
|
scanInstance = async instance => {
|
||||||
const json = await requestPart(`https://${instance}/api/v1/instance/domain_blocks`)
|
const json = await requestPart(`https://${instance}/api/v1/instance/domain_blocks`)
|
||||||
@ -108,7 +117,7 @@ module.exports = async (client, apex, app) => {
|
|||||||
app.locals.peers++
|
app.locals.peers++
|
||||||
await scanInstance(instance)
|
await scanInstance(instance)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yield 0
|
yield 0
|
||||||
|
Loading…
Reference in New Issue
Block a user