Node.js 使用ipv6代理获取节点

Node.js 使用ipv6代理获取节点,node.js,proxy,ipv6,node-fetch,Node.js,Proxy,Ipv6,Node Fetch,您知道如何将节点获取(或类似的包)与ipv6代理一起使用吗?我被困在这个“小”点上了 我试着 const fetch = require('node-fetch'); const HttpsProxyAgent = require('https-proxy-agent'); class Something { async init (url) { return fetch(url, {agent: new HttpsProxyAgent('https://2a01:cb00:861

您知道如何将节点获取(或类似的包)与ipv6代理一起使用吗?我被困在这个“小”点上了

我试着

const fetch = require('node-fetch');
const HttpsProxyAgent = require('https-proxy-agent');

class Something {
  async init (url) {
    return fetch(url, {agent: new HttpsProxyAgent('https://2a01:cb00:8612:c000:86d:5188:7abc:4c2f')})
      .then(res => res.text())
    }
}
但不起作用(惊讶…)

得到:


我确信我在做一些愚蠢的事情,但我不明白我可以用ipv6做什么或不做什么…

您的URL中的ipv6地址文本格式不正确。您需要将IPv6地址用括号括起来(
[
]
):

下文对此进行了解释:

2.URL语法中的文字IPv6地址格式

要在URL中使用文字IPv6地址,文字地址应为 包含在“[”和“]”字符中。例如,下面的文本 IPv6地址:

  FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
  1080:0:0:0:8:800:200C:4171
  3ffe:2a00:100:7031::1
  1080::8:800:200C:417A
  ::192.9.5.5
  ::FFFF:129.144.52.38
  2010:836B:4179::836B:4179
将表示为以下示例URL:

  http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
  http://[1080:0:0:0:8:800:200C:417A]/index.html
  http://[3ffe:2a00:100:7031::1]
  http://[1080::8:800:200C:417A]/foo
  http://[::192.9.5.5]/ipng
  http://[::FFFF:129.144.52.38]:80/index.html
  http://[2010:836B:4179::836B:4179]
  FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
  1080:0:0:0:8:800:200C:4171
  3ffe:2a00:100:7031::1
  1080::8:800:200C:417A
  ::192.9.5.5
  ::FFFF:129.144.52.38
  2010:836B:4179::836B:4179
  http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
  http://[1080:0:0:0:8:800:200C:417A]/index.html
  http://[3ffe:2a00:100:7031::1]
  http://[1080::8:800:200C:417A]/foo
  http://[::192.9.5.5]/ipng
  http://[::FFFF:129.144.52.38]:80/index.html
  http://[2010:836B:4179::836B:4179]