有没有办法为节点js https请求设置源端口?

编程入门 行业动态 更新时间:2024-10-24 23:14:58
本文介绍了有没有办法为节点js https请求设置源端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有办法为节点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请求设置源端口?

本文发布于:2023-08-07 19:46:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321404.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   节点   端口   js   https

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!