你知道在ipv6代理中使用node-fetch (或类似的包)的方法吗?我被困在这个“小”点上了。
我试过了
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())
}
}但是没有工作(令人惊讶...)
得到:
failed, reason: getaddrinfo ENOTFOUND 2a01我确信我在做一些愚蠢的事情,但我不知道我能用ipv6做什么或不能做什么……
发布于 2020-11-17 06:03:01
您的URL中的IPv6地址文本格式不正确。您需要用括号([和])将IPv6地址括起来:
https://[2a01:cb00:8612:c000:86d:5188:7abc:4c2f]这在RFC 2732, Format for Literal IPv6 Addresses in URL's中有解释
URL2.URL语法中的文字IPv6地址格式
要在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]
https://stackoverflow.com/questions/64866276
复制相似问题