我可以使用 WebRTC 打开 UDP 连接吗?

2022-01-22 00:00:00 udp webrtc javascript

我们需要使用 TFTP 协议将数据发送到用户的设备,这是一个简单的类似 FTP 的协议,通过 UDP 工作.

We need send data to our users' devices using the TFTP protocol, which is a simple FTP-like protocol that works over UDP.

由于我们无法使用 javascript 打开 UDP 套接字,我们一直使用我们的服务器作为代理,将数据发送到我们的服务器并打开从服务器到设备的 UDP 连接.这样做的缺点是我们的用户需要了解 NAT 和配置端口转发.

Since we can't open a UDP socket using javascript, we have been using our server as a proxy, sending the data to our server and opening a UDP connection from the server to the device. That does have the drawback that our users need to learn about NAT and configure port forwarding.

那么问题来了,我们是否可以使用 WebRTC 打开一个直接的 UDP 套接字在浏览器和设备之间进行发送和接收?

So the question is, could we use WebRTC to open a direct UDP socket to send and receive between the browser and the devices?

http://www.webrtc.org/reference/webrtc-internals/vienetwork#TOC-SendUDPPacket 建议我们可以通过套接字发送一些原始 UDP 数据(也就是说,如果可以通过 javascript 访问该层.我不确定),但我认为没有获取原始 UDP 响应的方法.

http://www.webrtc.org/reference/webrtc-internals/vienetwork#TOC-SendUDPPacket suggests that we could send some raw UDP data over the socket (that is, if it's possible to access that layer over javascript. i'm not sure about that), but I see no way to fetch a raw UDP response.

非常感谢任何帮助

推荐答案

没有.有太多的安全问题允许 WebRTC 发送到随机地址/端口 - 我们必须确保它不能作为 DDOS 平台工作,因此我们要求目标实现 ICE 作为发送数据的隐式权限,并且我们也不允许发送任意数据,仅允许发送 SRTP 媒体流和 DataChannels 中的数据(通过 SCTP over DTLS over UDP+ICE).

No. There are too many security issues allowing WebRTC to send to a random address/port - we have to make sure it doesn't work as a DDOS platform, so we require the target to implement ICE as an implicit permission to send data, and we also don't allow sending arbitrary data, just SRTP mediastreams and data in DataChannels (over SCTP over DTLS over UDP+ICE).

相关文章