Add try-catch around packet decryption

This guards against a service crash resulting from an occasional
packet decryption error.
This commit is contained in:
Jesse Cotton 2018-04-02 21:40:57 -07:00
parent 4d0c98c97a
commit ada0b42123
No known key found for this signature in database
GPG Key ID: 731B5A1B4C1DDCD3

View File

@ -147,10 +147,15 @@ Orvibo.prototype.startServer = function() {
return;
}
if (plugPacket.packetTypeText() === 'pk') {
plugPacket.processPacket(ORVIBO_KEY);
} else {
plugPacket.processPacket(socketData.encryptionKey);
try {
if (plugPacket.packetTypeText() === 'pk') {
plugPacket.processPacket(ORVIBO_KEY);
} else {
plugPacket.processPacket(socketData.encryptionKey);
}
} catch(err) {
logger.log('Failed to parse packet: ' + err);
return;
}
LOG_PACKET && plugPacket.logPacket('Socket -> ');