keepass2android icon indicating copy to clipboard operation
keepass2android copied to clipboard

User-defined SFTP connection timeout

Open hyproman opened this issue 3 years ago • 2 comments

Problem

The current method of connecting to an SFTP server uses the Jsch library's default timeout behavior, which is 120 seconds. For scenarios where the SFTP server cannot be reached (e.g. the server is only addressable from a local network, which the phone is not connected to), this essentially results in the application hanging until that timeout has passed.

Proposed Solution

This pull request aims to make this connection timeout (optionally) user-configurable. It exposes an option when creating/editing the SFTP database details. The extra information is embedded into the "connection URL" as "query parameters" like so:

Before: sftp://<user>:<password>@<host>:<port>/path/to/initial/directory After: sftp://<user>:<password>@<host>:<port>?connectTimeout=<###>/path/to/initial/directory (additional parameters can be added/handled in future, following the typical URL query parameter format)

This additional information is extracted and used, if set, to call the JSch Session.connect(int) method, instead of Session.connect()

Related Issues

#1419

hyproman avatar Jul 26 '22 23:07 hyproman

NOTE: I have not been successful in building this project locally (not for lack of trying, on both Linux and Windows). As such I do not feel comfortable merging. It would be greatly appreciated if @PhilippC (or another in the community) could try their hand at building/trying this out at their leisure? Thanks in advance.

hyproman avatar Jul 26 '22 23:07 hyproman

@SQuIsHY7D3m Does your approval mean you were able to build/test these changes?

hyproman avatar Sep 19 '22 23:09 hyproman

thanks for the PR and sorry that I wasn't able to check this for so long. @tenzap has suggested a PR (which is merged already) which greatly simplifies building on different platforms, maybe you want to merge these changes and then do the testing yourself, @hyproman ?

PhilippC avatar Dec 19 '22 07:12 PhilippC

In case build fails due to samsungpass, you also need merge the changes in https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/2

@PhilippC maybe you want to check and merge also the pr in samsungpass https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/2 https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/3 and #2139

Targetframework is not mandatory to update iirc.

Btw the github worflow has a step where it manually patches the files of samsungpass until https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/2 is merged.

Other solution would be to completely remove Samsung pass and use 'Google API for biometric authentication' instead as suggested by samsung engineering team.

tenzap avatar Dec 19 '22 07:12 tenzap

Thanks @tenzap and @PhilippC for updates on the build environment and the helpful comments. I was finally able to get the project to build on linux via command line (make).

I've made a few more updates to my contribution; at this point I have tested the signed debug K2P apk as well as the JavaFileStorageTest-AS apk and both seem to work as intended with respect to SFTP connection timeout.

Please let me know if you have a comments or concerns.

hyproman avatar Jan 15 '23 00:01 hyproman

It seems there are a few things not quite working 100% correctly. I'll keep working on it. As such please do not merge this yet :) I'll report back with any updates.

hyproman avatar Jan 17 '23 23:01 hyproman

@PhilippC I believe I have sufficiently reworked this change-set so that it works consistently with regard to the filechooser and "Recent Databases" functionality.

Please review at your leisure and let me know of any concerns and/or ability to merge. Thanks!

hyproman avatar Jan 31 '23 20:01 hyproman

just a quick heads-up on this PR: I wanted to test this thoroughly before merging, and currently I want to get a stable version with targetSdk 31 released first, but it definitely will be merged (if everything works)!

PhilippC avatar Feb 13 '23 08:02 PhilippC

Totally understand 👍

hyproman avatar Feb 13 '23 17:02 hyproman

Probably for the better that it wasn't merged.

I had made some assumptions about how android-filechooser worked that didn't turn out to be entirely true. After spending a bunch of time debugging and learning, I have reworked how SftpStorage and android-filechooser interact with each other with respect to URIs with query parameters. This implementation retains the query parameters through all filechooser actions that require an SFTP connection.

I've also cleaned up/consolidated the commits to better reflect the end result.

hyproman avatar Feb 16 '23 00:02 hyproman

Guys, do you think this could be merged to master any time soon? I have been checking this pull request a lot :). Thank you

jakubklos77 avatar Mar 21 '23 16:03 jakubklos77

Guys, do you think this could be merged to master any time soon? I have been checking this pull request a lot :). Thank you

I want to get 1.09e published to Play Store before adding more features. Unfortunately this turns out to be much more time consuming than expected, but I think it's on a good way now.

PhilippC avatar Mar 21 '23 18:03 PhilippC

Any plans on merging this to master then? I still suffer from the issue on weekly basis. Thank you :)

jakubklos77 avatar Jun 20 '23 07:06 jakubklos77

Still hoping this would be merged to master Thank you

jakubklos77 avatar Oct 10 '23 15:10 jakubklos77

@hyproman can we close this after merging #2386 ?

PhilippC avatar Oct 23 '23 09:10 PhilippC