diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-08-17 22:01:46 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-08-17 22:01:46 +0900 |
| commit | df67836c1ad281d2622b52bdf7c767b2dfc0e6a5 (patch) | |
| tree | 5a2c4e5b681857d846d5fea1f4058b72e80651da /src/misc | |
| parent | Merge branch 'develop' (diff) | |
| parent | Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff) | |
| download | misskey-df67836c1ad281d2622b52bdf7c767b2dfc0e6a5.tar.gz misskey-df67836c1ad281d2622b52bdf7c767b2dfc0e6a5.tar.bz2 misskey-df67836c1ad281d2622b52bdf7c767b2dfc0e6a5.zip | |
Merge branch 'develop'
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/fetch.ts | 33 | ||||
| -rw-r--r-- | src/misc/is-blocker-user-related.ts | 15 |
2 files changed, 42 insertions, 6 deletions
diff --git a/src/misc/fetch.ts b/src/misc/fetch.ts index 37f8203543..f7756f9256 100644 --- a/src/misc/fetch.ts +++ b/src/misc/fetch.ts @@ -1,9 +1,8 @@ import * as http from 'http'; import * as https from 'https'; -import * as cache from 'lookup-dns-cache'; +import CacheableLookup from 'cacheable-lookup'; import fetch, { HeadersInit } from 'node-fetch'; -import { HttpProxyAgent } from 'http-proxy-agent'; -import { HttpsProxyAgent } from 'https-proxy-agent'; +import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'; import config from '@/config'; import { URL } from 'url'; @@ -49,6 +48,12 @@ export async function getHtml(url: string, accept = 'text/html, */*', timeout = return await res.text(); } +const cache = new CacheableLookup({ + maxTtl: 3600, // 1hours + errorTtl: 30, // 30secs + lookup: false, // nativeのdns.lookupにfallbackしない +}); + /** * Get http non-proxy agent */ @@ -65,20 +70,36 @@ const _https = new https.Agent({ keepAlive: true, keepAliveMsecs: 30 * 1000, lookup: cache.lookup, -}); +} as https.AgentOptions); + +const maxSockets = Math.max(256, config.deliverJobConcurrency || 128); /** * Get http proxy or non-proxy agent */ export const httpAgent = config.proxy - ? new HttpProxyAgent(config.proxy) + ? new HttpProxyAgent({ + keepAlive: true, + keepAliveMsecs: 30 * 1000, + maxSockets, + maxFreeSockets: 256, + scheduling: 'lifo', + proxy: config.proxy + }) : _http; /** * Get https proxy or non-proxy agent */ export const httpsAgent = config.proxy - ? new HttpsProxyAgent(config.proxy) + ? new HttpsProxyAgent({ + keepAlive: true, + keepAliveMsecs: 30 * 1000, + maxSockets, + maxFreeSockets: 256, + scheduling: 'lifo', + proxy: config.proxy + }) : _https; /** diff --git a/src/misc/is-blocker-user-related.ts b/src/misc/is-blocker-user-related.ts new file mode 100644 index 0000000000..8c0ebfad9b --- /dev/null +++ b/src/misc/is-blocker-user-related.ts @@ -0,0 +1,15 @@ +export function isBlockerUserRelated(note: any, blockerUserIds: Set<string>): boolean { + if (blockerUserIds.has(note.userId)) { + return true; + } + + if (note.reply != null && blockerUserIds.has(note.reply.userId)) { + return true; + } + + if (note.renote != null && blockerUserIds.has(note.renote.userId)) { + return true; + } + + return false; +} |