Merge remote-tracking branch 'upsuper/master' into gh-pages
Conflicts: README.md
This commit is contained in:
commit
d0b47fcfe9
2 changed files with 16 additions and 18 deletions
19
README.md
19
README.md
|
@ -21,21 +21,20 @@ function getIPs(callback){
|
||||||
var RTCPeerConnection = window.RTCPeerConnection
|
var RTCPeerConnection = window.RTCPeerConnection
|
||||||
|| window.mozRTCPeerConnection
|
|| window.mozRTCPeerConnection
|
||||||
|| window.webkitRTCPeerConnection;
|
|| window.webkitRTCPeerConnection;
|
||||||
|
var useWebKit = !!window.webkitRTCPeerConnection;
|
||||||
|
|
||||||
//bypass naive webrtc blocking
|
//bypass naive webrtc blocking
|
||||||
if (!RTCPeerConnection) {
|
if(!RTCPeerConnection){
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
//invalidate content script
|
//invalidate content script
|
||||||
iframe.sandbox = 'allow-same-origin';
|
iframe.sandbox = 'allow-same-origin';
|
||||||
iframe.style.display = 'none';
|
iframe.style.display = 'none';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
var win = iframe.contentWindow;
|
var win = iframe.contentWindow;
|
||||||
window.RTCPeerConnection = win.RTCPeerConnection;
|
RTCPeerConnection = win.RTCPeerConnection
|
||||||
window.mozRTCPeerConnection = win.mozRTCPeerConnection;
|
|| win.mozRTCPeerConnection
|
||||||
window.webkitRTCPeerConnection = win.webkitRTCPeerConnection;
|
|| win.webkitRTCPeerConnection;
|
||||||
RTCPeerConnection = window.RTCPeerConnection
|
useWebKit = !!win.webkitRTCPeerConnection;
|
||||||
|| window.mozRTCPeerConnection
|
|
||||||
|| window.webkitRTCPeerConnection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//minimal requirements for data connection
|
//minimal requirements for data connection
|
||||||
|
@ -49,7 +48,7 @@ function getIPs(callback){
|
||||||
var servers = undefined;
|
var servers = undefined;
|
||||||
|
|
||||||
//add same stun server for chrome
|
//add same stun server for chrome
|
||||||
if(window.webkitRTCPeerConnection)
|
if(useWebKit)
|
||||||
servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
|
servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
|
||||||
|
|
||||||
//construct a new RTCPeerConnection
|
//construct a new RTCPeerConnection
|
||||||
|
@ -87,11 +86,11 @@ function getIPs(callback){
|
||||||
}, function(){});
|
}, function(){});
|
||||||
|
|
||||||
//wait for a while to let everything done
|
//wait for a while to let everything done
|
||||||
setTimeout(function() {
|
setTimeout(function(){
|
||||||
//read candidate info from local description
|
//read candidate info from local description
|
||||||
var lines = pc.localDescription.sdp.split('\n');
|
var lines = pc.localDescription.sdp.split('\n');
|
||||||
|
|
||||||
lines.forEach(function(line) {
|
lines.forEach(function(line){
|
||||||
if(line.indexOf('a=candidate:') === 0){
|
if(line.indexOf('a=candidate:') === 0){
|
||||||
handleCandidate(line);
|
handleCandidate(line);
|
||||||
}
|
}
|
||||||
|
|
15
index.html
15
index.html
|
@ -28,21 +28,20 @@
|
||||||
var RTCPeerConnection = window.RTCPeerConnection
|
var RTCPeerConnection = window.RTCPeerConnection
|
||||||
|| window.mozRTCPeerConnection
|
|| window.mozRTCPeerConnection
|
||||||
|| window.webkitRTCPeerConnection;
|
|| window.webkitRTCPeerConnection;
|
||||||
|
var useWebKit = !!window.webkitRTCPeerConnection;
|
||||||
|
|
||||||
//bypass naive webrtc blocking
|
//bypass naive webrtc blocking
|
||||||
if (!RTCPeerConnection) {
|
if(!RTCPeerConnection){
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
//invalidate content script
|
//invalidate content script
|
||||||
iframe.sandbox = 'allow-same-origin';
|
iframe.sandbox = 'allow-same-origin';
|
||||||
iframe.style.display = 'none';
|
iframe.style.display = 'none';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
var win = iframe.contentWindow;
|
var win = iframe.contentWindow;
|
||||||
window.RTCPeerConnection = win.RTCPeerConnection;
|
RTCPeerConnection = win.RTCPeerConnection
|
||||||
window.mozRTCPeerConnection = win.mozRTCPeerConnection;
|
|| win.mozRTCPeerConnection
|
||||||
window.webkitRTCPeerConnection = win.webkitRTCPeerConnection;
|
|| win.webkitRTCPeerConnection;
|
||||||
RTCPeerConnection = window.RTCPeerConnection
|
useWebKit = !!win.webkitRTCPeerConnection;
|
||||||
|| window.mozRTCPeerConnection
|
|
||||||
|| window.webkitRTCPeerConnection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//minimal requirements for data connection
|
//minimal requirements for data connection
|
||||||
|
@ -56,7 +55,7 @@
|
||||||
var servers = undefined;
|
var servers = undefined;
|
||||||
|
|
||||||
//add same stun server for chrome
|
//add same stun server for chrome
|
||||||
if(window.webkitRTCPeerConnection)
|
if(useWebKit)
|
||||||
servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
|
servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
|
||||||
|
|
||||||
//construct a new RTCPeerConnection
|
//construct a new RTCPeerConnection
|
||||||
|
|
Loading…
Reference in a new issue