don't require client id for ping

This commit is contained in:
antelle 2021-04-16 21:06:20 +02:00
parent 27143e2663
commit e3f33b9d4c
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 17 additions and 9 deletions

View File

@ -182,19 +182,27 @@ const BrowserExtensionConnector = {
logger.debug('Extension -> KeeWeb', request);
const clientId = request?.clientID;
if (!clientId) {
logger.warn('Empty client ID in request', request);
if (!request) {
logger.warn('Empty request', request);
socket.destroy();
return;
}
if (!state.clientId) {
state.clientId = clientId;
} else if (state.clientId !== clientId) {
logger.warn(`Changing client ID is not allowed: ${state.clientId} => ${clientId}`);
socket.destroy();
return;
if (request.clientID) {
const clientId = request.clientID;
if (!state.clientId) {
state.clientId = clientId;
} else if (state.clientId !== clientId) {
logger.warn(`Changing client ID is not allowed: ${state.clientId} => ${clientId}`);
socket.destroy();
return;
}
} else {
if (request.action !== 'ping') {
logger.warn('Empty client ID in request', request);
socket.destroy();
return;
}
}
state.processingData = true;