-
-
Notifications
You must be signed in to change notification settings - Fork 226
Added option for connection timeout used when browser extension is trying to connect to KeePassXC #2752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Added option for connection timeout used when browser extension is trying to connect to KeePassXC #2752
Changes from all commits
5923319
1c82121
5a06415
0b63edb
a7ef451
511b9ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ const defaultSettings = { | |
| bannerPosition: BannerPosition.TOP, | ||
| checkUpdateKeePassXC: CHECK_UPDATE_NEVER, | ||
| clearCredentialsTimeout: 10, | ||
| connectionTimeout: CONNECTION_TIMEOUT, | ||
| colorTheme: 'system', | ||
| credentialSorting: SORT_BY_GROUP_AND_TITLE, | ||
| debugLogging: false, | ||
|
|
@@ -47,6 +48,7 @@ page.autoSubmitPerformed = false; | |
| page.attributeMenuItems = []; | ||
| page.blockedTabs = []; | ||
| page.clearCredentialsTimeout = null; | ||
| page.connectionTimeout = null; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable is not used, and not needed. |
||
| page.currentRequest = {}; | ||
| page.currentTabId = -1; | ||
| page.isFirefox = false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ options.initGeneralSettings = async function() { | |
| $('#tab-general-settings input[type=radio]#checkUpdateOneMonth').value = CHECK_UPDATE_ONE_MONTH; | ||
| $('#tab-general-settings input[type=radio]#checkUpdateNever').value = CHECK_UPDATE_NEVER; | ||
|
|
||
| $('#tab-general-settings input[type=range]').value = options.settings['redirectAllowance']; | ||
| $('#tab-general-settings #redirectAllowance').value = options.settings['redirectAllowance']; | ||
| $('#redirectAllowanceLabel').textContent = tr('optionsRedirectAllowance', | ||
| options.settings['redirectAllowance'] === 11 ? 'Infinite' : String(options.settings['redirectAllowance'])); | ||
|
|
||
|
|
@@ -124,6 +124,9 @@ options.initGeneralSettings = async function() { | |
| $('#tab-general-settings input#defaultGroup').value = options.settings['defaultGroup']; | ||
| $('#tab-general-settings input#defaultPasskeyGroup').value = options.settings['defaultPasskeyGroup']; | ||
| $('#tab-general-settings input#clearCredentialTimeout').value = options.settings['clearCredentialsTimeout']; | ||
| const connectionTimeout = (options.settings['connectionTimeout']/1000); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't do this. Just retrieve the value from settings and do any modifications to it when inserting it as element value. |
||
| $('#tab-general-settings input#connectionTimeout').value = connectionTimeout; | ||
| $('#connectionTimeoutLabel').textContent = tr('optionsConnectionTimeout', String(connectionTimeout)); | ||
|
|
||
| const generalSettingsRadioInputs = document.querySelectorAll('#tab-general-settings input[type=radio]'); | ||
| for (const radio of generalSettingsRadioInputs) { | ||
|
|
@@ -173,7 +176,17 @@ options.initGeneralSettings = async function() { | |
| }); | ||
|
|
||
| // Change label text dynamically with the range input | ||
| $('#tab-general-settings input[type=range]').addEventListener('input', function(e) { | ||
| $('#tab-general-settings input#connectionTimeout').addEventListener('input', function(e) { | ||
| $('#connectionTimeoutLabel').textContent = tr('optionsConnectionTimeout', e.target.value); | ||
| }); | ||
|
|
||
| $('#tab-general-settings input#connectionTimeout').addEventListener('change', async function(e) { | ||
| options.settings['connectionTimeout'] = Math.min(60000, Math.max(CONNECTION_TIMEOUT, e.target.valueAsNumber * 1000)) | ||
| await options.saveSettings(); | ||
| }); | ||
|
|
||
| // Change label text dynamically with the range input | ||
| $('#tab-general-settings input#redirectAllowance').addEventListener('input', function(e) { | ||
| const currentValue = e.target.valueAsNumber === 11 ? 'Infinite' : e.target.value; | ||
| $('#redirectAllowanceLabel').textContent = tr('optionsRedirectAllowance', currentValue); | ||
| }); | ||
|
|
@@ -726,7 +739,7 @@ options.initSitePreferences = function() { | |
|
|
||
| // Page URL | ||
| row.children[0].children[0].children[0].value = url; | ||
| row.children[0].children[0]?.addEventListener('dblclick', (e) => | ||
| row.children[0].children[0]?.addEventListener('dblclick', (e) => | ||
| enterEditMode(e, row, inputField, editButton, cancelButton, saveButton) | ||
| ); | ||
|
|
||
|
|
@@ -891,7 +904,7 @@ const getBrowserId = function(userAgent) { | |
| return `${query.name} ${getVersion(userAgent, query.findStr)}`; | ||
| } | ||
| } | ||
|
|
||
| return 'Other/Unknown'; | ||
| }; | ||
|
|
||
|
|
@@ -919,7 +932,7 @@ const updateDropdownPosition = function(e, dropdown) { | |
| if (!rect) { | ||
| return; | ||
| } | ||
|
|
||
| const zoom = getComputedStyle(document.body).zoom || 1; | ||
| const scrollTop = document.defaultView.scrollY / zoom; | ||
| const scrollLeft = document.defaultView?.scrollX / zoom; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code block is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my point of view it is the most important part of the change as it makes sure to use the user configured timeout if no argument is provided. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value
CONNECTION_TIMEOUTin the function is already setting that to the value if no argument is provided.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONNECTION_TIMEOUT is set to a hard value of 1500 in global.js. The user defined value in the settings is not the same value. We need to make sure that if a developer has not provided any value to the second argument of "reconnect" we are considering the settings value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By definition, by allowing a connectionTimeout parameter at all we can ignore the setting value. You can set it to whatever you want with a direct call. If we don't want that behavior then you need to remove the parameter altogether and always use the settings value (defaulting to CONNECTION_TIMEOUT if invalid or unset).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea behind the implementation was to keep the backward compatibility of the "reconnect" method calls to not require the second parameter and still use the user setting value. I am aware that passing the settings value with every call would be possible too, but that means that in the future a developer needs to remember to pass the settings value when a new call to "reconnect" is made. To avoid this dependency I decided to handle it in "reconnect" directly. Do you think passing the settings value with every "reconnect" call is a better solution?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference is to drop the parameter altogether and use the settings value directly in this function, falling back to the default value if unset. This is an internal function call and there is no reason to retain any compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think dropping this parameter is an option. Looking at background/init.js there we are using this exact parameter to pass a different timeout. It is the only place I found, but I assume this was changed for a reason :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest solution for this is to:
connectionTimeout = CONNECTION_TIMEOUTin the function. It doesn't hurt to keep the default here.init.jsthe parameter is overridden with5000(we should make this a const too).kpxcEvent.onReconnect()where thepage.settings.connectionTimeoutmust be used as a parameter.keepass.enableAutomaticReconnect(). This function is not used at the point, but it should also includepage.settings.connectionTimeoutas the parameter.