turn: secret is a string

This commit is contained in:
Girish Ramakrishnan
2022-02-01 17:36:51 -08:00
parent aeef815bf7
commit 944d364e1a

View File

@@ -886,7 +886,7 @@ async function setupTurn(app, options) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof options, 'object');
const turnSecret = await blobs.get(blobs.ADDON_TURN_SECRET);
const turnSecret = await blobs.getString(blobs.ADDON_TURN_SECRET);
if (!turnSecret) throw new BoxError(BoxError.ADDONS_ERROR, 'Turn secret is missing');
const env = [
@@ -913,11 +913,11 @@ async function startTurn(existingInfra) {
const memory = system.getMemoryAllocation(memoryLimit);
const realm = settings.dashboardFqdn();
let turnSecret = await blobs.get(blobs.ADDON_TURN_SECRET);
let turnSecret = await blobs.getString(blobs.ADDON_TURN_SECRET);
if (!turnSecret) {
debug('startTurn: generting turn secret');
turnSecret = 'a' + crypto.randomBytes(15).toString('hex'); // prefix with a to ensure string starts with a letter
await blobs.set(blobs.ADDON_TURN_SECRET, Buffer.from(turnSecret));
await blobs.setString(blobs.ADDON_TURN_SECRET, turnSecret);
}
const readOnly = !serviceConfig.recoveryMode ? '--read-only' : '';