1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

expand e2ee logging to better debug UISIs

This commit is contained in:
Matthew Hodgson
2019-11-26 01:17:12 +00:00
parent ccc85d98e2
commit 2215087f96
5 changed files with 26 additions and 21 deletions

View File

@@ -104,7 +104,7 @@ OutboundSessionInfo.prototype.sharedWithTooManyDevices = function(
}
if (!devicesInRoom.hasOwnProperty(userId)) {
logger.log("Starting new session because we shared with " + userId);
logger.log("Starting new megolm session because we shared with " + userId);
return true;
}
@@ -115,7 +115,7 @@ OutboundSessionInfo.prototype.sharedWithTooManyDevices = function(
if (!devicesInRoom[userId].hasOwnProperty(deviceId)) {
logger.log(
"Starting new session because we shared with " +
"Starting new megolm session because we shared with " +
userId + ":" + deviceId,
);
return true;
@@ -200,6 +200,7 @@ MegolmEncryption.prototype._ensureOutboundSession = function(devicesInRoom) {
if (!session) {
logger.log(`Starting new megolm session for room ${self._roomId}`);
session = await self._prepareNewSession();
logger.log(`Started new megolm session ${session.sessionId} for room ${self._roomId}`);
self._outboundSessions[session.sessionId] = session;
}
@@ -278,7 +279,7 @@ MegolmEncryption.prototype._prepareNewSession = async function() {
).catch((e) => {
// This throws if the upload failed, but this is fine
// since it will have written it to the db and will retry.
logger.log("Failed to back up group session", e);
logger.log("Failed to back up megolm session", e);
});
}
@@ -440,19 +441,19 @@ MegolmEncryption.prototype.reshareKeyWithDevice = async function(
) {
const obSessionInfo = this._outboundSessions[sessionId];
if (!obSessionInfo) {
logger.debug("Session ID " + sessionId + " not found: not re-sharing keys");
logger.debug("megolm session ID " + sessionId + " not found: not re-sharing keys");
return;
}
// The chain index of the key we previously sent this device
if (obSessionInfo.sharedWithDevices[userId] === undefined) {
logger.debug("Session ID " + sessionId + " never shared with user " + userId);
logger.debug("megolm session ID " + sessionId + " never shared with user " + userId);
return;
}
const sentChainIndex = obSessionInfo.sharedWithDevices[userId][device.deviceId];
if (sentChainIndex === undefined) {
logger.debug(
"Session ID " + sessionId + " never shared with device " +
"megolm session ID " + sessionId + " never shared with device " +
userId + ":" + device.deviceId,
);
return;
@@ -466,7 +467,7 @@ MegolmEncryption.prototype.reshareKeyWithDevice = async function(
if (!key) {
logger.warn(
"No outbound session key found for " + sessionId + ": not re-sharing keys",
"No inbound session key found for megolm " + sessionId + ": not re-sharing keys",
);
return;
}
@@ -514,7 +515,7 @@ MegolmEncryption.prototype.reshareKeyWithDevice = async function(
},
});
logger.debug(
`Re-shared key for session ${sessionId} with ${userId}:${device.deviceId}`,
`Re-shared key for megolm session ${sessionId} with ${userId}:${device.deviceId}`,
);
};
@@ -922,7 +923,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
keysClaimed = event.getKeysClaimed();
}
logger.log(`Adding key for megolm session ${senderKey}|${sessionId}`);
logger.log(`Received and adding key for megolm session ${senderKey}|${sessionId}`);
return this._olmDevice.addInboundGroupSession(
content.room_id, senderKey, forwardingKeyChain, sessionId,
content.session_key, keysClaimed,
@@ -955,7 +956,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
).catch((e) => {
// This throws if the upload failed, but this is fine
// since it will have written it to the db and will retry.
logger.log("Failed to back up group session", e);
logger.log("Failed to back up megolm session", e);
});
}
}).catch((e) => {
@@ -1088,7 +1089,7 @@ MegolmDecryption.prototype.importRoomKey = function(session) {
).catch((e) => {
// This throws if the upload failed, but this is fine
// since it will have written it to the db and will retry.
logger.log("Failed to back up group session", e);
logger.log("Failed to back up megolm session", e);
});
}
// have another go at decrypting events sent with this session.