소스 검색

fix(P2P): do not accept P2P if disabled

Will not accept incoming P2P session if it's disabled in the config.
dev1
paweldomas 8 년 전
부모
커밋
23a374e0c1
1개의 변경된 파일19개의 추가작업 그리고 5개의 파일을 삭제
  1. 19
    5
      JitsiConference.js

+ 19
- 5
JitsiConference.js 파일 보기

@@ -302,6 +302,17 @@ JitsiConference.prototype.isJoined = function() {
302 302
     return this.room && this.room.joined;
303 303
 };
304 304
 
305
+/**
306
+ * Tells whether or not the P2P mode is enabled in the configuration.
307
+ * @return {boolean}
308
+ */
309
+JitsiConference.prototype.isP2PEnabled = function() {
310
+    return Boolean(this.options.config.p2p && this.options.config.p2p.enabled)
311
+
312
+        // FIXME: remove once we have a default config template. -saghul
313
+        || typeof this.options.config.p2p === 'undefined';
314
+};
315
+
305 316
 /**
306 317
  * Leaves the conference.
307 318
  * @returns {Promise}
@@ -1306,6 +1317,13 @@ JitsiConference.prototype.onIncomingCall
1306 1317
                     reasonMsg: 'P2P not supported',
1307 1318
                     errorMsg: 'This client does not support P2P connections'
1308 1319
                 });
1320
+        } else if (!this.isP2PEnabled()) {
1321
+            this._rejectIncomingCall(
1322
+                jingleSession, {
1323
+                    reasonTag: 'decline',
1324
+                    reasonMsg: 'P2P disabled',
1325
+                    errorMsg: 'P2P mode disabled in the configuration'
1326
+                });
1309 1327
         } else if (this.p2pJingleSession) {
1310 1328
             // Reject incoming P2P call (already in progress)
1311 1329
             this._rejectIncomingCall(
@@ -2299,11 +2317,7 @@ JitsiConference.prototype._suspendMediaTransferForJvbConnection = function() {
2299 2317
  * @private
2300 2318
  */
2301 2319
 JitsiConference.prototype._maybeStartOrStopP2P = function(userLeftEvent) {
2302
-    if (!(RTCBrowserType.isP2PSupported()
2303
-            && ((this.options.config.p2p && this.options.config.p2p.enabled)
2304
-
2305
-            // FIXME: remove once we have a default config template. -saghul
2306
-            || typeof this.options.config.p2p === 'undefined'))) {
2320
+    if (!RTCBrowserType.isP2PSupported() || !this.isP2PEnabled()) {
2307 2321
         logger.info('Auto P2P disabled');
2308 2322
 
2309 2323
         return;

Loading…
취소
저장