小编Neo*_*Neo的帖子

无法从 RTCPeerConnection 获取 IP V4 地址 - chrome

我需要从 Web 应用程序获取客户端本地 IP 地址。

为此,我使用标准的 RTCPeerConnection 实现来获取。但是返回的ice候选并没有携带IP V4地址,而是一个看起来像guid的地址:asdf-xxxx-saass-xxxx.local

但令人惊讶的是,这个chrome 扩展程序能够在同一台机器和浏览器上获取相同的内容。

注意:我在 Web 应用程序中使用的代码与扩展的代码相同

这是相同的html代码:

<html>

<head>

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.js"></script>

    <script type="text/javascript">

        function logit(msg) {
            var dt = new Date(); var time = dt.getHours() + ":" + dt.getMinutes() + ":"
                + dt.getSeconds();
            console.log(time + " " + msg);
        };

        function getChromeVersion() {
            try {
                var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
                return raw ? parseInt(raw[2], 10) : false;
            } catch (e) {
                return null;
            }
        }

        function getChromeManifest() {
            return chrome.runtime …
Run Code Online (Sandbox Code Playgroud)

google-chrome webrtc rtcpeerconnection

2
推荐指数
1
解决办法
4630
查看次数

标签 统计

google-chrome ×1

rtcpeerconnection ×1

webrtc ×1