|
@@ -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
|
}
|