Log envelopes and session end events
Help debug bad session errors by logging some envelope info about the message we are about to decrypt. With this, if there is a decryption error (e.g., bad mac or no session) it is clear from the logs what number and device message sent the bad message. Also log when we send and receive end session messages and when we close sessions for certain devices. // FREEBIE
This commit is contained in:
parent
d686eb4f68
commit
86132a38a8
3 changed files with 22 additions and 4 deletions
|
@ -36902,6 +36902,7 @@ MessageReceiver.prototype.extend({
|
||||||
this.pending = this.pending.then(handleEnvelope, handleEnvelope);
|
this.pending = this.pending.then(handleEnvelope, handleEnvelope);
|
||||||
},
|
},
|
||||||
handleEnvelope: function(envelope) {
|
handleEnvelope: function(envelope) {
|
||||||
|
console.log('envelope from', envelope.source + '.' + envelope.sourceDevice, envelope.timestamp.toNumber());
|
||||||
if (envelope.type === textsecure.protobuf.Envelope.Type.RECEIPT) {
|
if (envelope.type === textsecure.protobuf.Envelope.Type.RECEIPT) {
|
||||||
return this.onDeliveryReceipt(envelope);
|
return this.onDeliveryReceipt(envelope);
|
||||||
} else if (envelope.content) {
|
} else if (envelope.content) {
|
||||||
|
@ -36957,9 +36958,12 @@ MessageReceiver.prototype.extend({
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
handleDataMessage: function(envelope, message, close_session) {
|
handleDataMessage: function(envelope, message, close_session) {
|
||||||
console.log('data message from', envelope.source + '.' + envelope.sourceDevice, envelope.timestamp.toNumber());
|
var encodedNumber = envelope.source + '.' + envelope.sourceDevice;
|
||||||
|
console.log('data message from', encodedNumber, envelope.timestamp.toNumber());
|
||||||
if ((message.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION) ==
|
if ((message.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION) ==
|
||||||
textsecure.protobuf.DataMessage.Flags.END_SESSION ) {
|
textsecure.protobuf.DataMessage.Flags.END_SESSION ) {
|
||||||
|
console.log('got end session');
|
||||||
|
console.log('closing session for device', encodedNumber);
|
||||||
close_session();
|
close_session();
|
||||||
}
|
}
|
||||||
return this.processDecrypted(message, envelope.source).then(function(message) {
|
return this.processDecrypted(message, envelope.source).then(function(message) {
|
||||||
|
@ -37096,8 +37100,11 @@ MessageReceiver.prototype.extend({
|
||||||
|
|
||||||
if ((finalMessage.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION)
|
if ((finalMessage.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION)
|
||||||
== textsecure.protobuf.DataMessage.Flags.END_SESSION &&
|
== textsecure.protobuf.DataMessage.Flags.END_SESSION &&
|
||||||
finalMessage.sync !== null)
|
finalMessage.sync !== null) {
|
||||||
|
console.log('got end session');
|
||||||
res[1]();
|
res[1]();
|
||||||
|
console.log('session closed for device', from);
|
||||||
|
}
|
||||||
|
|
||||||
return this.processDecrypted(finalMessage);
|
return this.processDecrypted(finalMessage);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -37545,12 +37552,14 @@ MessageSender.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
closeSession: function(number, timestamp) {
|
closeSession: function(number, timestamp) {
|
||||||
|
console.log('sending end session');
|
||||||
var proto = new textsecure.protobuf.DataMessage();
|
var proto = new textsecure.protobuf.DataMessage();
|
||||||
proto.body = "TERMINATE";
|
proto.body = "TERMINATE";
|
||||||
proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION;
|
proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION;
|
||||||
return this.sendIndividualProto(number, proto, timestamp).then(function(res) {
|
return this.sendIndividualProto(number, proto, timestamp).then(function(res) {
|
||||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
||||||
return Promise.all(devices.map(function(device) {
|
return Promise.all(devices.map(function(device) {
|
||||||
|
console.log('closing session for', device.encodedNumber);
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
||||||
})).then(function() {
|
})).then(function() {
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -85,6 +85,7 @@ MessageReceiver.prototype.extend({
|
||||||
this.pending = this.pending.then(handleEnvelope, handleEnvelope);
|
this.pending = this.pending.then(handleEnvelope, handleEnvelope);
|
||||||
},
|
},
|
||||||
handleEnvelope: function(envelope) {
|
handleEnvelope: function(envelope) {
|
||||||
|
console.log('envelope from', envelope.source + '.' + envelope.sourceDevice, envelope.timestamp.toNumber());
|
||||||
if (envelope.type === textsecure.protobuf.Envelope.Type.RECEIPT) {
|
if (envelope.type === textsecure.protobuf.Envelope.Type.RECEIPT) {
|
||||||
return this.onDeliveryReceipt(envelope);
|
return this.onDeliveryReceipt(envelope);
|
||||||
} else if (envelope.content) {
|
} else if (envelope.content) {
|
||||||
|
@ -140,9 +141,12 @@ MessageReceiver.prototype.extend({
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
handleDataMessage: function(envelope, message, close_session) {
|
handleDataMessage: function(envelope, message, close_session) {
|
||||||
console.log('data message from', envelope.source + '.' + envelope.sourceDevice, envelope.timestamp.toNumber());
|
var encodedNumber = envelope.source + '.' + envelope.sourceDevice;
|
||||||
|
console.log('data message from', encodedNumber, envelope.timestamp.toNumber());
|
||||||
if ((message.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION) ==
|
if ((message.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION) ==
|
||||||
textsecure.protobuf.DataMessage.Flags.END_SESSION ) {
|
textsecure.protobuf.DataMessage.Flags.END_SESSION ) {
|
||||||
|
console.log('got end session');
|
||||||
|
console.log('closing session for device', encodedNumber);
|
||||||
close_session();
|
close_session();
|
||||||
}
|
}
|
||||||
return this.processDecrypted(message, envelope.source).then(function(message) {
|
return this.processDecrypted(message, envelope.source).then(function(message) {
|
||||||
|
@ -279,8 +283,11 @@ MessageReceiver.prototype.extend({
|
||||||
|
|
||||||
if ((finalMessage.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION)
|
if ((finalMessage.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION)
|
||||||
== textsecure.protobuf.DataMessage.Flags.END_SESSION &&
|
== textsecure.protobuf.DataMessage.Flags.END_SESSION &&
|
||||||
finalMessage.sync !== null)
|
finalMessage.sync !== null) {
|
||||||
|
console.log('got end session');
|
||||||
res[1]();
|
res[1]();
|
||||||
|
console.log('session closed for device', from);
|
||||||
|
}
|
||||||
|
|
||||||
return this.processDecrypted(finalMessage);
|
return this.processDecrypted(finalMessage);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -153,12 +153,14 @@ MessageSender.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
closeSession: function(number, timestamp) {
|
closeSession: function(number, timestamp) {
|
||||||
|
console.log('sending end session');
|
||||||
var proto = new textsecure.protobuf.DataMessage();
|
var proto = new textsecure.protobuf.DataMessage();
|
||||||
proto.body = "TERMINATE";
|
proto.body = "TERMINATE";
|
||||||
proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION;
|
proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION;
|
||||||
return this.sendIndividualProto(number, proto, timestamp).then(function(res) {
|
return this.sendIndividualProto(number, proto, timestamp).then(function(res) {
|
||||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
||||||
return Promise.all(devices.map(function(device) {
|
return Promise.all(devices.map(function(device) {
|
||||||
|
console.log('closing session for', device.encodedNumber);
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
||||||
})).then(function() {
|
})).then(function() {
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in a new issue