有没有办法为节点js https请求设置源端口?我不是询问目的地,而是询问源,即用于发送请求的端口。
Is there a way to set the source port for a node js https request? I am not asking about the destination, rather the source, ie the port used to send the request.
上下文是我试图从特定端口发送https请求而不是随机端口,因此允许锁定iptables。节点未以root身份运行,因此端口不是443。
The context is I am trying to send https requests from a specific port, rather than random ports, thus allowing for locking down iptables. Node is not running as root, thus the port is not 443.
更新:看来Node中存在错误。选项localAddress和localPort不起作用,至少使用TLS套接字。
Update : It appears there is a bug in Node. The options localAddress and localPort do not work, at least with a TLS socket.
更新:从去年发现了类似的问题。答案是不要那样做,这似乎是愚蠢的,因为该节点被认为是一个通用工具。 Nodejs TCP连接客户端端口分配
推荐答案不幸的是,看起来Node不支持绑定客户端端口。显然,这不是一个使用很多的功能,但它是可能的。此链接相当好地解释了端口绑定。 blog.cloudflare/cloudflare-now-supports-websockets/不确定如何让nodejs的人考虑这一变化。
Unfortunately it looks like Node does not support binding a client port. Apparently this isn't a feature that is used much, but it is possible. This link explains port binding fairly well. blog.cloudflare/cloudflare-now-supports-websockets/ Not sure how to get the nodejs people to consider this change.
更多推荐
有没有办法为节点js https请求设置源端口?
发布评论