Fix linting errors
This commit is contained in:
parent
f376f579c0
commit
d3d7fc3848
@ -29,7 +29,8 @@
|
||||
"expect": true,
|
||||
"localStorage": false,
|
||||
"window": false,
|
||||
"jest": true
|
||||
"jest": true,
|
||||
"jasmine": true
|
||||
},
|
||||
|
||||
"rules": {
|
||||
|
||||
@ -1,31 +1,45 @@
|
||||
const iceServers = require('./iceServers.js');
|
||||
|
||||
function checkTURNServer(turnConfig, timeout){
|
||||
function noop() {}
|
||||
|
||||
function checkTURNServer(turnConfig, timeout) {
|
||||
|
||||
console.log('checking turn server', turnConfig);
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
setTimeout(function(){
|
||||
if(promiseResolved) return;
|
||||
setTimeout(function() {
|
||||
if (promiseResolved) return;
|
||||
resolve(false);
|
||||
promiseResolved = true;
|
||||
}, timeout || 5000);
|
||||
|
||||
var promiseResolved = false
|
||||
, myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection //compatibility for firefox and chrome
|
||||
, pc = new myPeerConnection({iceServers:[turnConfig]})
|
||||
, noop = function(){};
|
||||
pc.createDataChannel(""); //create a bogus data channel
|
||||
pc.createOffer(function(sdp){
|
||||
if(sdp.sdp.indexOf('typ relay') > -1){ // sometimes sdp contains the ice candidates...
|
||||
const promiseResolved = false;
|
||||
const PeerConnection = window.RTCPeerConnection ||
|
||||
window.mozRTCPeerConnection ||
|
||||
window.webkitRTCPeerConnection;
|
||||
|
||||
const pc = new PeerConnection({ iceServers: [turnConfig] });
|
||||
|
||||
// create a bogus data channel
|
||||
pc.createDataChannel('');
|
||||
pc.createOffer(function(sdp) {
|
||||
// sometimes sdp contains the ice candidates...
|
||||
if (sdp.sdp.indexOf('typ relay') > -1) {
|
||||
promiseResolved = true;
|
||||
resolve(true);
|
||||
}
|
||||
pc.setLocalDescription(sdp, noop, noop);
|
||||
}, noop); // create offer and set local description
|
||||
pc.onicecandidate = function(ice){ //listen for candidate events
|
||||
if(promiseResolved || !ice || !ice.candidate || !ice.candidate.candidate || !(ice.candidate.candidate.indexOf('typ relay')>-1)) return;
|
||||
}, noop);
|
||||
|
||||
pc.onicecandidate = function(ice) {
|
||||
if (promiseResolved ||
|
||||
!ice ||
|
||||
!ice.candidate ||
|
||||
!ice.candidate.candidate ||
|
||||
!(ice.candidate.candidate.indexOf('typ relay') > -1)) {
|
||||
return;
|
||||
}
|
||||
promiseResolved = true;
|
||||
resolve(true);
|
||||
};
|
||||
|
||||
@ -27,7 +27,7 @@ describe('turn', () => {
|
||||
username: 'c',
|
||||
secret: 'd',
|
||||
auth: 'secret'
|
||||
}]
|
||||
}];
|
||||
|
||||
it('does not expose secret', () => {
|
||||
const s = turn.processServers(servers);
|
||||
@ -40,7 +40,7 @@ describe('turn', () => {
|
||||
credential: jasmine.any(String)
|
||||
});
|
||||
expect(s[1].username).toMatch(/^[0-9]+:c$/);
|
||||
})
|
||||
});
|
||||
|
||||
it('throws error when unknown auth type', () => {
|
||||
expect(() => turn.processServers([{ auth: 'bla' }]))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user