为什么 null 几乎总是传递给 RTCPeerConnection?

Why is null almost always passed to RTCPeerConnection?

几乎我在 Internet 上看到的每个 WebRTC 示例都涉及创建一个带有单个参数 nullRTCPeerConnectionThe spec calls for two parameters 待通过:ICE 服务器配置和您的媒体限制。

我注意到,如果在您通过 null(例如,var pc = new RTCPeerConnection(null);)时两个请求来自同一路由器,从技术上讲一切仍然有效。我不确定它是否适用于跨网络。有人可以在这里进一步说明发生了什么吗?

Nearly every example of WebRTC I've seen on the Internet involves creating a RTCPeerConnection with a single parameter of null.

我想对于这些示例,大多数情况下都假定您使用的是同一台计算机。所以你真的不需要任何iceServers。 (而且示例不想为您提供 "free" stun-server/turn-server?)

I've noticed that technically everything still works if the two requests are coming from the same router when you pass null.

如果客户端不在同一网络上,则不会出现这种情况。因为没有 stun 服务器(通过 iceServers 配置传递),客户端无法获得他们的服务器反射地址。

编辑:

正如 @syno 在评论中指出的:

目前,webRTC 的 "security" 问题之一是 STUN 和 TURN 服务器配置在创建对等连接时以明文形式传递。任何人都可以查看 JavaScript 代码并使用您的服务器。这就是为什么需要使用带有 REST API (code.google.com/p/rfc5766-turn-server/wiki/turnserver) 的 TURN 服务器来拥有临时 "timestamp" 以限制不需要的用户的使用。当目的是学习或展示 webRTC 的基本概念时,不需要在一个简单的演示中添加所有这些复杂性