xiongzhu пре 2 година
родитељ
комит
9df2b7ce8f
5 измењених фајлова са 26 додато и 3 уклоњено
  1. 3 1
      .env.production
  2. 9 0
      p.mjs
  3. 1 0
      package.json
  4. 4 1
      src/danmu/danmu.service.ts
  5. 9 1
      yarn.lock

+ 3 - 1
.env.production

@@ -76,4 +76,6 @@ TWITCH_ACCESS_TOKEN=6ppjqg2pjn3vffhiltgqef8tuqtal8
 REDIS_HOST=localhost
 REDIS_PORT=6379
 REDIS_PASSWORD=4dSM4yvhbS6@8@oE
-REDIS_DB=2
+REDIS_DB=2
+
+HTTP_PROXY=http://127.0.0.1:7890

+ 9 - 0
p.mjs

@@ -0,0 +1,9 @@
+import * as https from 'https'
+import { HttpsProxyAgent } from 'https-proxy-agent'
+
+const agent = new HttpsProxyAgent('http://localhost:7890')
+
+https.get('https://www.google.com', { agent }, (res) => {
+    console.log('"response" event!', res.headers)
+    res.pipe(process.stdout)
+})

+ 1 - 0
package.json

@@ -58,6 +58,7 @@
     "express-handlebars": "^7.0.6",
     "handlebars": "^4.7.7",
     "hbs": "^4.2.0",
+    "http-proxy-agent": "^7.0.0",
     "https-proxy-agent": "^7.0.2",
     "ioredis": "^5.3.2",
     "isomorphic-fetch": "^3.0.0",

+ 4 - 1
src/danmu/danmu.service.ts

@@ -37,7 +37,10 @@ export class DanmuService implements OnModuleInit {
             .map((i) => i.channelId)
         this.logger.log(`channels=${channels}`)
         const client = new Client({
-            channels
+            channels,
+            connection: {
+                agent: process.env.HTTP_PROXY ? new HttpsProxyAgent(process.env.HTTP_PROXY) : undefined
+            }
         })
 
         // Register our event handlers (defined below)

+ 9 - 1
yarn.lock

@@ -1849,7 +1849,7 @@ agent-base@6, agent-base@^6.0.0, agent-base@^6.0.2:
   dependencies:
     debug "4"
 
-agent-base@^7.0.2:
+agent-base@^7.0.2, agent-base@^7.1.0:
   version "7.1.0"
   resolved "https://registry.npmmirror.com/agent-base/-/agent-base-7.1.0.tgz#536802b76bc0b34aa50195eb2442276d613e3434"
   integrity sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==
@@ -3991,6 +3991,14 @@ http-proxy-agent@^4.0.0, http-proxy-agent@^4.0.1:
     agent-base "6"
     debug "4"
 
+http-proxy-agent@^7.0.0:
+  version "7.0.0"
+  resolved "https://registry.npmmirror.com/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz#e9096c5afd071a3fce56e6252bb321583c124673"
+  integrity sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==
+  dependencies:
+    agent-base "^7.1.0"
+    debug "^4.3.4"
+
 http-signature@~1.2.0:
   version "1.2.0"
   resolved "https://registry.npmmirror.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"