Browse Source

Updates config feature and whitelists options that can be overridden. (#2282)

* Removes unused config logic.

* Whitelists config options that can be overridden using the URL.

* Recorder login with credentials, not supported by externalconnect.

Jibri uses xmpp credentials to login, which is not supported by externalconnect, so we want to skip it till that is supported.

* Whitelist only config.js

* Extracts whitelisting in separate function.
master
Дамян Минков 7 years ago
parent
commit
e28b847fb0

+ 51
- 0
config.js View File

@@ -317,6 +317,57 @@ var config = {
317 317
         // region: "europe",
318 318
         // userRegion: "asia"
319 319
     }
320
+
321
+    // List of undocumented settings used in jitsi-meet
322
+    /**
323
+     alwaysVisibleToolbar
324
+     analyticsScriptUrls
325
+     autoEnableDesktopSharing
326
+     autoRecord
327
+     autoRecordToken
328
+     debug
329
+     debugAudioLevels
330
+     deploymentInfo
331
+     dialInConfCodeUrl
332
+     dialInNumbersUrl
333
+     dialOutAuthUrl
334
+     dialOutCodesUrl
335
+     disableRemoteControl
336
+     displayJids
337
+     enableLocalVideoFlip
338
+     etherpad_base
339
+     externalConnectUrl
340
+     firefox_fake_device
341
+     iAmRecorder
342
+     iAmSipGateway
343
+     peopleSearchQueryTypes
344
+     peopleSearchUrl
345
+     requireDisplayName
346
+     tokenAuthUrl
347
+     */
348
+
349
+    // List of undocumented settings used in lib-jitsi-meet
350
+    /**
351
+     _peerConnStatusOutOfLastNTimeout
352
+     _peerConnStatusRtcMuteTimeout
353
+     abTesting
354
+     avgRtpStatsN
355
+     callStatsConfIDNamespace
356
+     callStatsCustomScriptUrl
357
+     desktopSharingSources
358
+     disableAEC
359
+     disableAGC
360
+     disableAP
361
+     disableHPF
362
+     disableNS
363
+     enableLipSync
364
+     enableTalkWhileMuted
365
+     forceJVB121Ratio
366
+     hiddenDomain
367
+     ignoreStartMuted
368
+     nick
369
+     startBitrate
370
+     */
320 371
 };
321 372
 
322 373
 /* eslint-enable no-unused-vars, no-var */

+ 5
- 2
connection_optimization/do_external_connect.js View File

@@ -16,14 +16,17 @@ import parseURLParams from '../react/features/base/config/parseURLParams';
16 16
  */
17 17
 
18 18
 if (typeof createConnectionExternally === 'function') {
19
-    // URL params have higher proirity than config params.
19
+    // URL params have higher priority than config params.
20 20
     let url
21 21
         = parseURLParams(window.location, true, 'hash')[
22 22
                 'config.externalConnectUrl']
23 23
             || config.externalConnectUrl;
24
+    const isRecorder
25
+        = parseURLParams(window.location, true, 'hash')['config.iAmRecorder'];
26
+
24 27
     let roomName;
25 28
 
26
-    if (url && (roomName = getRoomName())) {
29
+    if (url && (roomName = getRoomName()) && !isRecorder) {
27 30
         url += `?room=${roomName}`;
28 31
 
29 32
         const token = parseURLParams(window.location, true, 'search').jwt;

+ 0
- 1
package.json View File

@@ -43,7 +43,6 @@
43 43
     "jquery-contextmenu": "2.4.5",
44 44
     "jquery-i18next": "1.2.0",
45 45
     "js-md5": "0.6.1",
46
-    "jssha": "2.2.0",
47 46
     "jwt-decode": "2.2.0",
48 47
     "lib-jitsi-meet": "github:jitsi/lib-jitsi-meet#81f57c024e137879d6c93bef62308971d0ec71b0",
49 48
     "lodash": "4.17.4",

+ 100
- 67
react/features/base/config/functions.js View File

@@ -1,6 +1,5 @@
1 1
 /* @flow */
2 2
 
3
-import JSSHA from 'jssha';
4 3
 import _ from 'lodash';
5 4
 
6 5
 import parseURLParams from './parseURLParams';
@@ -8,15 +7,87 @@ import parseURLParams from './parseURLParams';
8 7
 declare var $: Object;
9 8
 
10 9
 /**
11
- * The config keys to ignore because, for example, their values identify scripts
12
- * and it is not desireable to inject these through URL params.
10
+ * The config keys to whitelist, the keys that can be overridden.
11
+ * Currently we can only whitelist the first part of the properties, like
12
+ * 'p2p.useStunTurn' and 'p2p.enabled' we whitelist all p2p options.
13
+ * The whitelist is used only for config.js.
13 14
  *
14 15
  * @private
15 16
  * @type Array
16 17
  */
17
-const _KEYS_TO_IGNORE = [
18
-    'analyticsScriptUrls',
19
-    'callStatsCustomScriptUrl'
18
+const WHITELISTED_KEYS = [
19
+    '_peerConnStatusOutOfLastNTimeout',
20
+    '_peerConnStatusRtcMuteTimeout',
21
+    'abTesting',
22
+    'alwaysVisibleToolbar',
23
+    'autoEnableDesktopSharing',
24
+    'autoRecord',
25
+    'autoRecordToken',
26
+    'avgRtpStatsN',
27
+    'callStatsConfIDNamespace',
28
+    'callStatsID',
29
+    'callStatsSecret',
30
+    'channelLastN',
31
+    'constraints',
32
+    'debug',
33
+    'debugAudioLevels',
34
+    'defaultLanguage',
35
+    'desktopSharingChromeDisabled',
36
+    'desktopSharingChromeExtId',
37
+    'desktopSharingChromeMinExtVersion',
38
+    'desktopSharingChromeSources',
39
+    'desktopSharingFirefoxDisabled',
40
+    'desktopSharingSources',
41
+    'disable1On1Mode',
42
+    'disableAEC',
43
+    'disableAGC',
44
+    'disableAP',
45
+    'disableAudioLevels',
46
+    'disableDesktopSharing',
47
+    'disableDesktopSharing',
48
+    'disableH264',
49
+    'disableHPF',
50
+    'disableNS',
51
+    'disableRemoteControl',
52
+    'disableRtx',
53
+    'disableSuspendVideo',
54
+    'displayJids',
55
+    'enableDisplayNameInStats',
56
+    'enableLipSync',
57
+    'enableLocalVideoFlip',
58
+    'enableRecording',
59
+    'enableStatsID',
60
+    'enableTalkWhileMuted',
61
+    'enableUserRolesBasedOnToken',
62
+    'etherpad_base',
63
+    'failICE',
64
+    'firefox_fake_device',
65
+    'forceJVB121Ratio',
66
+    'hiddenDomain',
67
+    'hosts',
68
+    'iAmRecorder',
69
+    'iAmSipGateway',
70
+    'ignoreStartMuted',
71
+    'nick',
72
+    'openBridgeChannel',
73
+    'p2p',
74
+    'preferH264',
75
+    'recordingType',
76
+    'requireDisplayName',
77
+    'resolution',
78
+    'startAudioMuted',
79
+    'startAudioOnly',
80
+    'startBitrate',
81
+    'startScreenSharing',
82
+    'startVideoMuted',
83
+    'startWithAudioMuted',
84
+    'startWithVideoMuted',
85
+    'testing',
86
+    'useIPv6',
87
+    'useNicks',
88
+    'useStunTurn',
89
+    'webrtcIceTcpDisable',
90
+    'webrtcIceUdpDisable'
20 91
 ];
21 92
 
22 93
 const logger = require('jitsi-meet-logger').getLogger(__filename);
@@ -28,60 +99,6 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
28 99
 export { default as getRoomName } from './getRoomName';
29 100
 export { parseURLParams };
30 101
 
31
-/* eslint-disable no-shadow */
32
-
33
-/**
34
- * Looks for a list of possible BOSH addresses in {@code config.boshList} and
35
- * sets the value of {@code config.bosh} based on that list and
36
- * {@code roomName}.
37
- *
38
- * @param {Object} config - The configuration object.
39
- * @param {string} roomName - The name of the room/conference.
40
- * @returns {void}
41
- */
42
-export function chooseBOSHAddress(config: Object, roomName: string) {
43
-    if (!roomName) {
44
-        return;
45
-    }
46
-
47
-    const { boshList } = config;
48
-
49
-    if (!boshList || !Array.isArray(boshList) || !boshList.length) {
50
-        return;
51
-    }
52
-
53
-    // This implements the actual choice of an entry in the list based on
54
-    // roomName. Please consider the implications for existing deployments
55
-    // before introducing changes.
56
-    const hash = (new JSSHA(roomName, 'TEXT')).getHash('SHA-1', 'HEX');
57
-    const n = parseInt(hash.substr(-6), 16);
58
-    let idx = n % boshList.length;
59
-
60
-    config.bosh = boshList[idx];
61
-    logger.log(`Setting config.bosh to ${config.bosh} (idx=${idx})`);
62
-
63
-    const { boshAttemptFirstList } = config;
64
-
65
-    if (boshAttemptFirstList
66
-            && Array.isArray(boshAttemptFirstList)
67
-            && boshAttemptFirstList.length > 0) {
68
-        idx = n % boshAttemptFirstList.length;
69
-
70
-        const attemptFirstAddress = boshAttemptFirstList[idx];
71
-
72
-        if (attemptFirstAddress === config.bosh) {
73
-            logger.log('Not setting config.boshAttemptFirst, address matches.');
74
-        } else {
75
-            config.boshAttemptFirst = attemptFirstAddress;
76
-            logger.log(
77
-                `Setting config.boshAttemptFirst=${attemptFirstAddress} (idx=${
78
-                    idx})`);
79
-        }
80
-    }
81
-}
82
-
83
-/* eslint-enable no-shadow */
84
-
85 102
 /**
86 103
  * Sends HTTP POST request to specified {@code endpoint}. In request the name
87 104
  * of the room is included in JSON format:
@@ -135,6 +152,7 @@ export function obtainConfig(
135 152
 /**
136 153
  * Overrides JSON properties in {@code config} and
137 154
  * {@code interfaceConfig} Objects with the values from {@code newConfig}.
155
+ * Overrides only the whitelisted keys.
138 156
  *
139 157
  * @param {Object} config - The config Object in which we'll be overriding
140 158
  * properties.
@@ -171,7 +189,8 @@ export function overrideConfigJSON(
171 189
             configObj = loggingConfig;
172 190
         }
173 191
         if (configObj) {
174
-            const configJSON = json[configName];
192
+            const configJSON
193
+                = _getWhitelistedJSON(configName, json[configName]);
175 194
 
176 195
             if (!_.isEmpty(configJSON)) {
177 196
                 logger.info(
@@ -190,6 +209,26 @@ export function overrideConfigJSON(
190 209
     }
191 210
 }
192 211
 
212
+/**
213
+ * Whitelist only config.js, skips this for others configs
214
+ * (interfaceConfig, loggingConfig).
215
+ * Only extracts overridden values for keys we allow to be overridden.
216
+ *
217
+ * @param {string} configName - The config name, one of config,
218
+ * interfaceConfig, loggingConfig.
219
+ * @param {Object} configJSON - The object with keys and values to override.
220
+ * @returns {Object} - The result object only with the keys
221
+ * that are whitelisted.
222
+ * @private
223
+ */
224
+function _getWhitelistedJSON(configName, configJSON) {
225
+    if (configName !== 'config') {
226
+        return configJSON;
227
+    }
228
+
229
+    return _.pick(configJSON, WHITELISTED_KEYS);
230
+}
231
+
193 232
 /* eslint-enable max-params, no-shadow */
194 233
 
195 234
 /**
@@ -233,12 +272,6 @@ export function setConfigFromURLParams() {
233 272
         const names = param.split('.');
234 273
         const last = names.pop();
235 274
 
236
-        // Prevent passing some parameters which can inject scripts.
237
-        if (_KEYS_TO_IGNORE.indexOf(last) !== -1) {
238
-            // eslint-disable-next-line no-continue
239
-            continue;
240
-        }
241
-
242 275
         for (const name of names) {
243 276
             base = base[name] = base[name] || {};
244 277
         }

+ 1
- 2
react/features/conference/route.js View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 import ConferenceUrl from '../../../modules/URL/ConferenceUrl';
4 4
 
5
-import { chooseBOSHAddress, obtainConfig } from '../base/config';
5
+import { obtainConfig } from '../base/config';
6 6
 import { RouteRegistry } from '../base/react';
7 7
 
8 8
 import { Conference } from './components';
@@ -86,7 +86,6 @@ function _obtainConfigAndInit() {
86 86
                     });
87 87
                 });
88 88
         } else {
89
-            chooseBOSHAddress(config, room);
90 89
             _initConference();
91 90
         }
92 91
     }

Loading…
Cancel
Save