diff --git a/lib/constant.js b/lib/constant.js index 8e724e8..1d4c595 100644 --- a/lib/constant.js +++ b/lib/constant.js @@ -10,5 +10,7 @@ module.exports = { workers: 3, // async concurrent workers to scan schedule: '5,11,17,23', // UTC hours to publish bot followers federated stats filterdomains: ['activitypub-troll.cf'], // domains filtered to scan - initialscan: 'mastodon.social' // initial federated domain to scan + initialscan: 'mastodon.social', // initial federated domain to scan + timeout: 3000, // Timeout of each scan request + abort_timeout: 4000 // Timeout of abort scan request } diff --git a/lib/fediblock.js b/lib/fediblock.js index a9a4661..71bd9fe 100644 --- a/lib/fediblock.js +++ b/lib/fediblock.js @@ -3,7 +3,6 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0 module.exports = async (client, apex, app) => { const util = require('./util')(apex), constant = require('./constant'), - https = require('https'), schedule = require('node-schedule'), workers = constant.workers, getAccount = api => { @@ -22,15 +21,12 @@ module.exports = async (client, apex, app) => { const ac = new AbortController() setTimeout(() => { ac.abort() - }, 5000) + }, constant.abort_timeout) const response = await fetch(uri, { headers: { 'User-Agent': constant.agent }, - agent: new https.Agent({ - keepAlive: false - }), signal: ac.signal, keepalive: false, - timeout: 3000 + timeout: constant.timeout }), json = await response.json() // setImmediate(() => { ac.abort() })