Procházet zdrojové kódy

feat(Jingle): add 'failICE' config option

The flag when set to 'true' will enforce ICE failure. It is supposed to
be used in automatic testing.
dev1
paweldomas před 9 roky
rodič
revize
937dc622c0
2 změnil soubory, kde provedl 31 přidání a 1 odebrání
  1. 18
    1
      modules/xmpp/JingleSessionPC.js
  2. 13
    0
      modules/xmpp/SDP.js

+ 18
- 1
modules/xmpp/JingleSessionPC.js Zobrazit soubor

@@ -59,6 +59,12 @@ function JingleSessionPC(me, sid, peerjid, connection,
59 59
     this.jingleOfferIq = null;
60 60
     this.webrtcIceUdpDisable = !!this.service.options.webrtcIceUdpDisable;
61 61
     this.webrtcIceTcpDisable = !!this.service.options.webrtcIceTcpDisable;
62
+    /**
63
+     * Flag used to enforce ICE failure through the URL parameter for
64
+     * the automatic testing purpose.
65
+     * @type {boolean}
66
+     */
67
+    this.failICE = !!this.service.options.failICE;
62 68
 
63 69
     this.modifySourcesQueue = async.queue(this._modifySources.bind(this), 1);
64 70
 }
@@ -212,7 +218,12 @@ JingleSessionPC.prototype.sendIceCandidates = function (candidates) {
212 218
                 name: (cands[0].sdpMid? cands[0].sdpMid : mline.media)
213 219
             }).c('transport', ice);
214 220
             for (var i = 0; i < cands.length; i++) {
215
-                cand.c('candidate', SDPUtil.candidateToJingle(cands[i].candidate)).up();
221
+                var candidate = SDPUtil.candidateToJingle(cands[i].candidate);
222
+                // Mangle ICE candidate if 'failICE' test option is enabled
223
+                if (this.service.options.failICE) {
224
+                    candidate.ip = "1.1.1.1";
225
+                }
226
+                cand.c('candidate', candidate).up();
216 227
             }
217 228
             // add fingerprint
218 229
             var fingerprint_line = SDPUtil.find_line(this.localSDP.media[mid], 'a=fingerprint:', this.localSDP.session);
@@ -423,6 +434,9 @@ JingleSessionPC.prototype.sendSessionAccept = function (localSDP,
423 434
     if (this.webrtcIceUdpDisable) {
424 435
         localSDP.removeUdpCandidates = true;
425 436
     }
437
+    if (this.failICE) {
438
+        localSDP.failICE = true;
439
+    }
426 440
     localSDP.toJingle(
427 441
         accept,
428 442
         this.initiator == this.me ? 'initiator' : 'responder',
@@ -755,6 +769,9 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
755 769
         if (this.webrtcIceUdpDisable) {
756 770
             sdp.removeUdpCandidates = true;
757 771
         }
772
+        if (this.failICE) {
773
+            sdp.failICE = true;
774
+        }
758 775
 
759 776
         sdp.fromJingle(this.jingleOfferIq);
760 777
         this.readSsrcInfo($(this.jingleOfferIq).find(">content"));

+ 13
- 0
modules/xmpp/SDP.js Zobrazit soubor

@@ -19,6 +19,14 @@ function SDP(sdp) {
19 19
     this.session = session;
20 20
 }
21 21
 
22
+/**
23
+ * A flag will make {@link transportToJingle} and {@link jingle2media} replace
24
+ * ICE candidates IPs with invalid value of '1.1.1.1' which will cause ICE
25
+ * failure. The flag is used in the automated testing.
26
+ * @type {boolean}
27
+ */
28
+SDP.prototype.failICE = false;
29
+
22 30
 /**
23 31
  * Whether or not to remove TCP ice candidates when translating from/to jingle.
24 32
  * @type {boolean}
@@ -385,6 +393,9 @@ SDP.prototype.transportToJingle = function (mediaindex, elem) {
385 393
             var lines = SDPUtil.find_lines(this.media[mediaindex], 'a=candidate:', this.session);
386 394
             lines.forEach(function (line) {
387 395
                 var candidate = SDPUtil.candidateToJingle(line);
396
+                if (self.failICE) {
397
+                    candidate.ip = "1.1.1.1";
398
+                }
388 399
                 var protocol = (candidate &&
389 400
                         typeof candidate.protocol === 'string')
390 401
                     ? candidate.protocol.toLowerCase() : '';
@@ -598,6 +609,8 @@ SDP.prototype.jingle2media = function (content) {
598 609
         if ((self.removeTcpCandidates && protocol === 'tcp') ||
599 610
             (self.removeUdpCandidates && protocol === 'udp')) {
600 611
             return;
612
+        } else  if (self.failICE) {
613
+            this.setAttribute('ip', '1.1.1.1');
601 614
         }
602 615
 
603 616
         media += SDPUtil.candidateFromJingle(this);

Načítá se…
Zrušit
Uložit