Commit Graph
66 Commits
Author SHA1 Message Date
Kenneth Skovhede 40dd3c6816 Updated all license mentions to MIT 2024-02-28 15:45:30 +01:00
Kenneth Hsu de2a651763 Fix bug in PutAsync implementations.
Without await, the using statement can dispose the Stream before the
call to PutAsync completes, resulting in an ObjectDisposedException.

This fixes #4556.
2021-06-12 15:12:13 -07:00
Kenneth Hsu a5fbee0335 Simplify exception handling when testing for ECDSA support.
.NET 5 moves the responsibility to the operating system, and since
SSH.NET currently relies on the ECDsaCng class, we will simply interpret
all exceptions to mean lack of ECDSA support.
2021-05-18 12:19:49 -07:00
Kenneth Hsu c246976fbb Cache knowledge of ECDSA support using static field.
This is simpler, and would potentially allow us to query this without an
instance.
2021-05-18 10:18:14 -07:00
Kenneth Hsu 22564bb2a3 Cache knowledge of ECDSA support. 2021-05-18 10:07:33 -07:00
Kenneth Hsu bfa240c8ec Assume we have ECDSA support if our test throws exception.
It's possible that our test will no longer be valid (e.g., due to
changes in SSH.NET), so we don't want the backend to fail if our test
is no longer valid.
2021-05-18 09:06:00 -07:00
Kenneth Hsu 90dfce81b2 Construct instance of ECDsaCng to test for ECDSA support.
This more closely reflects the SSH.NET code.
2021-05-18 09:00:40 -07:00
Kenneth Hsu 3d8817608e Test for ECDSA support explicitly.
The previous implementation could possibly fail for reasons unrelated to
ECDSA support.
2021-05-16 17:29:00 -07:00
Kenneth Hsu b80845a176 Enumerate items to list before modifying collection. 2021-05-11 15:40:33 -07:00
Kenneth Hsu 3e2103335b SSH: Avoid advertising support for ECDSA algorithms with Mono.
SSH.NET relies on the System.Security.Cryptography.ECDsaCng class for
ECDSA algorithms, which is not implemented in Mono (as of 6.12.0.144).
This prevents clients from connecting if one of the ECDSA algorithms is
chosen as the host key algorithm.  In the event that this causes a
connection failure, we will prevent the client from advertising support
for ECDSA algorithms and make another connection attempt.

Related forum discussion:

	https://forum.duplicati.com/t/release-2-0-6-1-beta-2021-sftp-failure-synology/12358
2021-05-11 12:42:34 -07:00
verhoek f16ba3d49b Indentation cleanup. 2019-12-18 20:38:21 +01:00
verhoek 72b6c7b780 Esthetical changes to SSH2 backend code.
Mostly auto suggested from IDE.
2019-12-12 21:57:27 +01:00
Sean Templeton b02b19e683 Change Put method name to PutAsync 2019-03-17 18:28:45 -05:00
Sean Templeton 0c122ff550 Change IBackend and IStreamingBackend to return Task for Put() 2019-03-03 21:43:10 -06:00
Kenneth Hsu 8dd3aeaf26 Use invariant culture in calls to ToLower and ToUpper. 2018-12-11 21:21:07 -08:00
Kenneth Hsu 0143a848f5 Remove unnecessary local variable. 2018-11-21 21:21:38 -08:00
Kenneth Hsu de9750caba Use 'this' keyword to improve readability. 2018-11-21 21:03:09 -08:00
Kenneth Hsu 609c32feb2 Create parent directories as needed for SFTP backend.
If the user specifies a path with multiple directories that do not
exist, the SftpClient.CreateDirectory method does not create all the
missing parent directories.  As such, we have to do so ourselves.

This addresses issue #2080.
2018-11-21 20:38:36 -08:00
verhoek b2cc18426c Renamed Library.IO to Library.Common.IO.
Moved basic Platform functions to Library.Common.Platform.
Turned IO_OS into property within Library.Common.
2018-11-02 21:34:07 +01:00
verhoek bc053df294 Moved basic IO helper functions to Library.IO. 2018-10-27 12:17:07 +02:00
Kenneth Hsu d4d1945faf Use utility method to append trailing slash.
This removes some duplicated code.
2018-09-22 10:19:45 -07:00
Kenneth Hsu 0d23302220 Use ordinal case-insensitive comparison instead of ToLower. 2018-09-19 15:21:59 -07:00
Kenneth SkovhedeandGitHub 3b6c2b61d5 Merge pull request #3242 from warwickmm/remove_ineffective_statements
Remove ineffective statements
2018-06-04 10:40:32 +02:00
Kenneth Hsu bbe65f9dfb Remove ineffective statements.
The removed code was introduced in revision ba58651e5a ("Fix for
CreateFolder with SSH"), presumably to fix an issue where some SSH
backends did not like the trailing slash when creating new folders.
However, since we are not using the output argument of the call to
Substring, these statements have no effect.
2018-05-26 10:36:50 -07:00
Kenneth Hsu f12858e6a5 Mark fields that shouldn't be reassigned as readonly.
This makes it explicit at compile-time that these fields should not be
reassigned outside the constructor.
2018-05-25 10:04:52 -07:00
Kenneth Skovhede 842fd96543 Implemented a new logging system that is more transparent and allows a more granular way of picking log messages.
Added ID's to each log message and each exception to allow later introduction of a Knowledgebase service that explains each error in more detail.
2018-03-15 09:12:34 +01:00
Kenneth Skovhede bd863016fa Added support for returning multiple DNS names for cache invalidation.
Updated most backends to return the actual DNS names for cache invalidation.
2018-02-26 11:37:10 +01:00
Rune Henriksen fc77b476fc changed from NYI to null returns. Added check to skip DNS check if no DNSName is provided 2018-02-21 22:38:01 +01:00
Rune Henriksen 00292953c3 added DNSName getter on Backend interface and added NotImplementedException methods on each backend class 2018-02-18 00:18:44 +01:00
Kenneth SkovhedeandGitHub 36aadc4ad1 Merge pull request #2910 from warwickmm/refactor/remove_redundant_tostring
Remove redundant calls to ToString
2017-11-27 08:50:00 +01:00
Kenneth Hsu 5fb1958ceb Remove redundant calls to ToString. 2017-11-26 15:44:34 -08:00
Kenneth Hsu 8810e0130d Make string comparisons use ordinal (binary) sort rules.
These string comparisons should not be culture-aware.
2017-11-26 11:19:54 -08:00
Kenneth Skovhede 6cc70c7ae5 Added a friendly error message if the SSH key fails to parse/load.
This fixes #2856
2017-11-19 17:28:51 +01:00
Tyler Gill 38883285ee Change IBackend.List() to return IEnumerable instead of List
By changing to IEnumerable, it is possible to iterate only a portion of the list, which is useful when not all entries are needed (e.g., when testing a connection).
All existing backends have been updated, and any which were able to be changed to yield return results in a straightforward way now do.
Many backends had a try/catch in the List() method. Due to the fact that yield returns can't be placed within a try/catch block, these have been refactored to either scope the try/catch to the parts that (should) be the only places throwing exceptions, so that exceptions are still caught and handled.
Note that lazy evaluation may cause some changes in behavior - exceptions that were previously thrown at the point of invokation of List() may now be thrown while it is being enumerated.
I believe this will not be problematic though, as the only well-known exception seems to be FolderMissingException, which should be thrown by Test(), but TestList() attempts to enumerate the list to force this exception.
Any places that require the legacy behavior can get it by simply converting the lazy enumerable to a List()
2017-09-25 23:17:45 -06:00
Kenneth Skovhede 5970562022 Bugfix: better error message when there is no password for SSH backend 2017-09-23 00:15:53 +02:00
Tyler Gill 83a1dcfb64 Replace all instances of InvariantCultureIgnoreCase with OrdinalIgnoreCase in string comparisons.
InvariantCulture is useful when comparing / sorting human language strings in a culturely correct way. It handles things like accented letters in a way that makes sense to humans (e.g., 'a' should be sorted next to 'á', rather than after 'z').
Ordinal looks just at the raw code points of the characters. As such, it is recommended for use in cases when comparing system strings (file paths, command line parameters, config settings, etc.). Since it doesn't need to use the culture specific sorting rules, this method can often be faster.

For more information, see https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison (and other related questions)
2017-09-18 23:55:08 -06:00
Kenneth Skovhede 81d5b77c8e Added extra options to SSH that exposes the operation timeout and keep-alive properties. 2017-08-06 17:48:09 +02:00
Kenneth Skovhede 4c1ea6d614 Removed custom handling of the SSH fingerprints.
This fixes #2109
2016-12-03 15:16:06 +01:00
Kenneth Skovhede b69af94b3c Fixed an issue where the --ssh-accept-any-fingerprint option would cause a warning stating that it was not supported. 2016-10-13 23:21:01 +02:00
Kenneth Skovhede 0c68daff6c Fixed all whitespace to be 4 spaces instead of tabs 2016-09-15 11:39:27 +02:00
Kenneth Skovhede f3572892be Changed SSH backend to report invalid host keys via the HostKeyException 2016-08-30 10:00:48 +02:00
Max 4960fd4202 merge upstream 2016-06-28 19:52:28 +02:00
Max 9f0b3a0042 default behavior is that fingerprint needs to be specified, but can be overided 2016-06-27 19:57:36 +02:00
Max e53f5808d9 add ability to check server fingerprint 2016-06-24 15:03:08 +02:00
Max 300ef96800 fix 1341 2016-06-11 22:11:33 +02:00
Kenneth Skovhede 3149064cde Merge branch 'no_more_resx' 2015-01-20 21:45:54 +01:00
Kenneth Skovhede 8d13e698eb Updated copyright notices 2015-01-20 21:44:52 +01:00
Kenneth Skovhede 16c791f0b5 Removed all resx files, now using Duplicati.Library.Localization exclusively 2015-01-20 21:07:24 +01:00
Kenneth Skovhede 290fde1f9b Bugfix from EddiVonDerAlm@1e83373 2014-11-17 12:01:11 +01:00
Malte Neumann 4a57eed9b5 Fixed a problem with canceled backups
Was an backup canceled, a restart doesn't work. The problem was that a non existing file caused an failure. This fix handles this situation for the ssh and googledocs backend.
2014-11-14 14:41:36 +01:00