You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Log when turn creds expire
This commit is contained in:
@@ -393,6 +393,9 @@ export function MatrixClient(opts) {
|
||||
this._clientWellKnown = undefined;
|
||||
this._clientWellKnownPromise = undefined;
|
||||
|
||||
this._turnServers = [];
|
||||
this._turnServersExpiry = null;
|
||||
|
||||
// The SDK doesn't really provide a clean way for events to recalculate the push
|
||||
// actions for themselves, so we have to kinda help them out when they are encrypted.
|
||||
// We do this so that push rules are correctly executed on events in their decrypted
|
||||
@@ -4942,6 +4945,15 @@ MatrixClient.prototype.getTurnServers = function() {
|
||||
return this._turnServers || [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the unix timestamp (in seconds) at which the current
|
||||
* TURN credentials (from getTurnServers) expire
|
||||
* @return {number} The expiry timestamp, in seconds, or null if no credentials
|
||||
*/
|
||||
MatrixClient.prototype.getTurnServersExpiry = function() {
|
||||
return this._turnServersExpiry;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether to allow a fallback ICE server should be used for negotiating a
|
||||
* WebRTC connection if the homeserver doesn't provide any servers. Defaults to
|
||||
@@ -5437,6 +5449,7 @@ function checkTurnServers(client) {
|
||||
credential: res.password,
|
||||
};
|
||||
client._turnServers = [servers];
|
||||
client._turnServersExpiry = Date.now() + res.ttl;
|
||||
// re-fetch when we're about to reach the TTL
|
||||
client._checkTurnServersTimeoutID = setTimeout(() => {
|
||||
checkTurnServers(client);
|
||||
|
||||
@@ -138,6 +138,8 @@ export class CallEventHandler {
|
||||
);
|
||||
}
|
||||
|
||||
const timeUntilTurnCresExpire = this.client.getTurnServersExpiry() - Date.now();
|
||||
logger.info("Current turn creds expire in " + timeUntilTurnCresExpire + " seconds");
|
||||
call = createNewMatrixCall(this.client, event.getRoomId(), {
|
||||
forceTURN: this.client._forceTURN,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user