mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Expect permanent proxy
This commit is contained in:
parent
a93ac4b3ac
commit
680c224598
3 changed files with 23 additions and 14 deletions
|
|
@ -3,6 +3,7 @@
|
|||
const keepassClient = {};
|
||||
keepassClient.keySize = 24;
|
||||
keepassClient.messageTimeout = 500; // Milliseconds
|
||||
keepassClient.connectionTimeout = 5000; // Milliseconds
|
||||
keepassClient.nativeHostName = 'org.keepassxc.keepassxc_browser';
|
||||
keepassClient.nativePort = null;
|
||||
|
||||
|
|
@ -322,8 +323,7 @@ keepassClient.nativeConnect = function() {
|
|||
return keepassClient.nativePort;
|
||||
};
|
||||
|
||||
function onDisconnected() {
|
||||
keepassClient.nativePort = null;
|
||||
function disconnect() {
|
||||
keepass.isConnected = false;
|
||||
keepass.isDatabaseClosed = true;
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
|
|
@ -334,12 +334,26 @@ function onDisconnected() {
|
|||
page.clearAllLogins();
|
||||
keepass.updatePopup('cross');
|
||||
keepass.updateDatabaseHashToContent();
|
||||
logError(`Failed to connect: ${(browser.runtime.lastError === null ? 'Unknown error' : browser.runtime.lastError.message)}`);
|
||||
}
|
||||
|
||||
function onDisconnected() {
|
||||
console.log('onDisconnected');
|
||||
keepass.nativePort = null;
|
||||
disconnect();
|
||||
console.log('Failed to connect: ' + (browser.runtime.lastError === null ? 'Unknown error' : browser.runtime.lastError.message));
|
||||
}
|
||||
|
||||
keepassClient.onNativeMessage = function(response) {
|
||||
// Handle database lock/unlock status
|
||||
if (response.action === kpActions.DATABASE_LOCKED || response.action === kpActions.DATABASE_UNLOCKED) {
|
||||
keepass.updateDatabase();
|
||||
} else if (response.action === 'reconnected') {
|
||||
setTimeout(function() {
|
||||
keepass.reconnect(null, keepassClient.connectionTimeout);
|
||||
}, 1000);
|
||||
} else if (response.action === 'disconnected') {
|
||||
if (keepass.isConnected) {
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
await page.initSitePreferences();
|
||||
await page.initOpenedTabs();
|
||||
await httpAuth.init();
|
||||
await keepass.reconnect(null, 5000); // 5 second timeout for the first connect
|
||||
await keepass.enableAutomaticReconnect();
|
||||
await keepass.updateDatabase();
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -729,18 +729,10 @@ keepass.setCryptoKey = function(id, key) {
|
|||
//--------------------------------------------------------------------------
|
||||
|
||||
keepass.enableAutomaticReconnect = function() {
|
||||
// Disable for Windows if KeePassXC is older than 2.3.4
|
||||
if (!page.settings.autoReconnect
|
||||
|| (navigator.platform.toLowerCase().includes('win')
|
||||
&& keepass.currentKeePassXC
|
||||
&& !keepass.compareVersion('2.3.4', keepass.currentKeePassXC))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (keepass.reconnectLoop === null) {
|
||||
keepass.reconnectLoop = setInterval(async () => {
|
||||
if (!keepass.isKeePassXCAvailable) {
|
||||
keepass.reconnect();
|
||||
keepassClient.connectToNative();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
|
@ -752,14 +744,18 @@ keepass.disableAutomaticReconnect = function() {
|
|||
};
|
||||
|
||||
keepass.reconnect = async function(tab, connectionTimeout) {
|
||||
keepassClient.connectToNative();
|
||||
console.log('reconnect()');
|
||||
keepass.isConnected = true;
|
||||
keepass.generateNewKeyPair();
|
||||
|
||||
const keyChangeResult = await keepass.changePublicKeys(tab, true, connectionTimeout).catch((e) => {
|
||||
console.log('Error changing keys');
|
||||
return false;
|
||||
});
|
||||
|
||||
// Change public keys timeout
|
||||
if (!keyChangeResult) {
|
||||
console.log('Key change timeout');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue