summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-24 12:44:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-24 12:44:16 +0200
commit64df9e49a09a17fe1150a0eb5343d6088be1b5a9 (patch)
treedbeb9304f7c25d302d30f3430927703871f30c0a /util/src
parent:bug: delay worker thread start (diff)
parentMerge pull request #495 from KagurazakaNyaa/master (diff)
downloadserver-64df9e49a09a17fe1150a0eb5343d6088be1b5a9.tar.xz
Merge branch 'master' of http://github.com/fosscord/fosscord-server
Diffstat (limited to 'util/src')
-rw-r--r--util/src/util/AutoUpdate.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/util/src/util/AutoUpdate.ts b/util/src/util/AutoUpdate.ts

index cafc7bdb..531bd8b7 100644 --- a/util/src/util/AutoUpdate.ts +++ b/util/src/util/AutoUpdate.ts
@@ -1,5 +1,6 @@ import "missing-native-js-functions"; import fetch from "node-fetch"; +import ProxyAgent from 'proxy-agent'; import readline from "readline"; import fs from "fs/promises"; import path from "path"; @@ -52,7 +53,8 @@ async function download(url: string, dir: string) { try { // TODO: use file stream instead of buffer (to prevent crash because of high memory usage for big files) // TODO check file hash - const response = await fetch(url); + const agent = new ProxyAgent(); + const response = await fetch(url, { agent }); const buffer = await response.buffer(); const tempDir = await fs.mkdtemp("fosscord"); fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer); @@ -72,7 +74,8 @@ async function getCurrentVersion(dir: string) { async function getLatestVersion(url: string) { try { - const response = await fetch(url); + const agent = new ProxyAgent(); + const response = await fetch(url, { agent }); const content = await response.json(); return content.version; } catch (error) {