Update coturn.ts

Add function for using TURN_CRED
pull/261/head
iamdoubz 9 months ago committed by GitHub
parent 7e8650fbc0
commit 27a4cc8695
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,3 +32,26 @@ export async function setTurnCredentials(
await redis.setex(key, ttl, hmacKey)
}
export async function setTurnCredentials2(
username: string,
password: string,
ttl: number,
): Promise<void> {
if (!process.env.COTURN_ENABLED) {
return
}
const realm = process.env.TURN_REALM || 'file.pizza'
if (!realm) {
throw new Error('TURN_REALM environment variable not set')
}
const redis = getRedisClient()
const hmacKey = password
const key = `turn/realm/${realm}/user/${username}/key`
await redis.setex(key, ttl, hmacKey)
}

Loading…
Cancel
Save