From 479b848a585362379fb13e1cc2a7f12dd86ff83d Mon Sep 17 00:00:00 2001 From: Mikhail Lukashov Date: Sun, 5 May 2024 08:34:35 +0300 Subject: [PATCH 01/20] bump version to 24.5.0.602 --- ChangeLog | 19 +++++++++++++++++++ src/NetBox/NetBox.rc | 4 ++-- src/NetBox/plugin_version.hpp | 6 +++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 343a1d91a..dd665b7c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,25 @@ # for this file format description, # see https://github.com/olivierlacan/keep-a-changelog +## [24.5.0.602] - 2024-05-05 + +### Changes +* gh-467 Update PuTTY to 0.81 +* gh-461 Tell AppVeyour to keep build artifacts + +### Fixes + +Thanks to ssvine https://github.com/ssvine +* gh-469 Fix log time format +* gh-468 Fix MFC termination +* gh-466 Fix Charset encoding for filenames +* gh-465 Fix dialog message +* gh-463 Fix freeze on exit +* gh-462 Fix possible crashes on lost connections while modal dialog is shown +* gh-459 Fix ssh crash on reconnect +* gh-458 Fix broken terminal output +* gh-457 Fix properties implementation + ## [24.4.1.601] - 2024-04-10 ### Fixes diff --git a/src/NetBox/NetBox.rc b/src/NetBox/NetBox.rc index 3aa2bb163..65f8d8a18 100644 --- a/src/NetBox/NetBox.rc +++ b/src/NetBox/NetBox.rc @@ -12,13 +12,13 @@ FILETYPE 0x2 { VALUE "CompanyName", "Mikhail Lukashov\0" VALUE "FileDescription", "NetBox: SFTP/FTP/FTPS/SCP/WebDAV/S3 client for Far Manager 3.0\0" - VALUE "FileVersion", "24.4.1.601\0" + VALUE "FileVersion", "24.5.0.602\0" VALUE "InternalName", "FarNetBox\0" VALUE "LegalCopyright", "(c) 2011, 2024 Mikhail Lukashov\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "NetBox.dll\0" VALUE "ProductName", "NetBox\0" - VALUE "ProductVersion", "24.4.1.601\0" + VALUE "ProductVersion", "24.5.0.602\0" VALUE "ReleaseType", "beta\0" VALUE "WWW", "https://github.com/michaellukashov/Far-NetBox\0" } diff --git a/src/NetBox/plugin_version.hpp b/src/NetBox/plugin_version.hpp index bcc5b308b..294567778 100644 --- a/src/NetBox/plugin_version.hpp +++ b/src/NetBox/plugin_version.hpp @@ -5,6 +5,6 @@ #pragma once #define NETBOX_VERSION_MAJOR 24 -#define NETBOX_VERSION_MINOR 4 -#define NETBOX_VERSION_PATCH 1 -#define NETBOX_VERSION_BUILD 601 +#define NETBOX_VERSION_MINOR 5 +#define NETBOX_VERSION_PATCH 0 +#define NETBOX_VERSION_BUILD 602 From 0f377432e19997dc90c8b8b3f9ce3bcb76d72c3b Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Wed, 8 May 2024 05:52:55 +0300 Subject: [PATCH 02/20] Fix error when uploading an existing directory Revert commit 1ed9b3 in favour of commit 2d9d9d. The latter one actually resolves both issues. --- src/core/Terminal.cpp | 6 +++--- src/core/Terminal.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/Terminal.cpp b/src/core/Terminal.cpp index cb710f5d9..e9d6444f6 100644 --- a/src/core/Terminal.cpp +++ b/src/core/Terminal.cpp @@ -4104,12 +4104,12 @@ TRemoteFile * TTerminal::ReadFile(const UnicodeString & AFileName) return File.release(); } -TRemoteFile * TTerminal::TryReadFile(const UnicodeString & AFileName, bool AExceptionOnFail) +TRemoteFile * TTerminal::TryReadFile(const UnicodeString & AFileName) { TRemoteFile * File; try { - SetExceptionOnFail(AExceptionOnFail); + SetExceptionOnFail(true); try__finally { File = ReadFile(base::UnixExcludeTrailingBackslash(AFileName)); @@ -7808,7 +7808,7 @@ void TTerminal::SourceRobust( bool TTerminal::CreateTargetDirectory( const UnicodeString & ADirectoryPath, uint32_t Attrs, const TCopyParamType * CopyParam) { - std::unique_ptr File(TryReadFile(ADirectoryPath, false)); + std::unique_ptr File(TryReadFile(ADirectoryPath)); const bool DoCreate = (File == nullptr) || !File->IsDirectory; // just try to create and make it fail diff --git a/src/core/Terminal.h b/src/core/Terminal.h index 2102c553f..7d25af3a8 100644 --- a/src/core/Terminal.h +++ b/src/core/Terminal.h @@ -600,7 +600,7 @@ friend class TParallelOperation; TRemoteFileList * CustomReadDirectoryListing(const UnicodeString & Directory, bool UseCache); TRemoteFile * ReadFileListing(const UnicodeString & APath); TRemoteFile * ReadFile(const UnicodeString & AFileName); - TRemoteFile * TryReadFile(const UnicodeString & AFileName, bool AExceptionOnFail = true); + TRemoteFile * TryReadFile(const UnicodeString & AFileName); bool FileExists(const UnicodeString & AFileName); void ReadSymlink(TRemoteFile * SymlinkFile, TRemoteFile *& AFile); bool CopyToLocal( From 9346715cc5f2786cc087e6a04644198ac87d1217 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 16:03:29 +0300 Subject: [PATCH 03/20] Fix copying of exception messages --- src/base/Exceptions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/base/Exceptions.cpp b/src/base/Exceptions.cpp index f40ef220a..83fa7c79e 100644 --- a/src/base/Exceptions.cpp +++ b/src/base/Exceptions.cpp @@ -302,8 +302,9 @@ ExtException::ExtException(const Exception * E, const UnicodeString & Msg, const } ExtException::ExtException(TObjectClassId Kind, const Exception * E, int32_t Ident) : - Exception(Kind, E, Ident) + Exception(Kind, L"", Ident) { + AddMoreMessages(E); } ExtException::ExtException(TObjectClassId Kind, const UnicodeString & Msg, const Exception * E) : @@ -464,7 +465,7 @@ EOSExtException::EOSExtException(TObjectClassId Kind, const UnicodeString & Msg, } EFatal::EFatal(TObjectClassId Kind, const UnicodeString & Msg, const Exception * E) : - ExtException(Kind, Msg) + ExtException(Kind, Msg, E) { const EFatal * F = rtti::dyn_cast_or_null(E); if (F != nullptr) From 85570d7f9dcff971e08eca9eb009d7faad0e3262 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 16:04:02 +0300 Subject: [PATCH 04/20] ExtException: don't append the same message twice --- src/base/Exceptions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/base/Exceptions.cpp b/src/base/Exceptions.cpp index 83fa7c79e..d09c8afe7 100644 --- a/src/base/Exceptions.cpp +++ b/src/base/Exceptions.cpp @@ -319,13 +319,17 @@ ExtException::ExtException(TObjectClassId Kind, const UnicodeString & Msg, const { Message = Msg; } - else + else if (Message != Msg) { if (FMoreMessages == nullptr) { FMoreMessages = new TStringList(); } - FMoreMessages->Append(UnformatMessage(Msg)); + const auto PreparedMessage = UnformatMessage(Msg); + if (FMoreMessages->IndexOf(PreparedMessage) == nb::NPOS) + { + FMoreMessages->Append(PreparedMessage); + } } } // FHelpKeyword = MergeHelpKeyword(GetExceptionHelpKeyword(E), HelpKeyword); From ff989deb9c560b5e24b5a1ae58e8f6d78d69a45c Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 16:04:24 +0300 Subject: [PATCH 05/20] Do not duplicate FTP error messages --- src/core/FtpFileSystem.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/FtpFileSystem.cpp b/src/core/FtpFileSystem.cpp index b6a445575..2de3d3ff8 100644 --- a/src/core/FtpFileSystem.cpp +++ b/src/core/FtpFileSystem.cpp @@ -3453,6 +3453,15 @@ UnicodeString TFTPFileSystem::GotReply(uint32_t Reply, uint32_t Flags, MoreMessages->Delete(0); } + if (MoreMessages != nullptr) + { + auto ErrorIndex = MoreMessages->IndexOf(Error); + if (ErrorIndex != nb::NPOS) + { + MoreMessages->Delete(ErrorIndex); + } + } + if (Disconnected) { if (DoClose) From 3119992cd601b2e60a10b4362217357e8ed5b981 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 16:05:45 +0300 Subject: [PATCH 06/20] Fix: clicking abort in retry dialog shouldn't show any other messages --- src/base/Exceptions.h | 10 ++++++++++ src/core/Terminal.cpp | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/base/Exceptions.h b/src/base/Exceptions.h index 024b9800d..49fded9ae 100644 --- a/src/base/Exceptions.h +++ b/src/base/Exceptions.h @@ -265,6 +265,16 @@ inline void ThrowNotImplemented(int32_t ErrorId) Error(SNotImplemented, ErrorId); } +template +inline void TryReplaceAndThrow(Exception & E) +{ + if (rtti::isa(&E)) + { + throw To(E.Message); + } + throw; //NOSONAR +} + NB_CORE_EXPORT Exception * CloneException(Exception * E); NB_CORE_EXPORT void RethrowException(Exception * E); NB_CORE_EXPORT UnicodeString GetExceptionHelpKeyword(const Exception * E); diff --git a/src/core/Terminal.cpp b/src/core/Terminal.cpp index cb710f5d9..45a4154d2 100644 --- a/src/core/Terminal.cpp +++ b/src/core/Terminal.cpp @@ -3828,7 +3828,14 @@ void TTerminal::CustomReadDirectory(TRemoteFileList * AFileList) if ((FOpening > 0) || !RobustLoop.TryReopen(E)) { - throw; + if (FOpening == 0) + { + TryReplaceAndThrow(E); + } + else + { + throw; + } } } } @@ -7787,7 +7794,7 @@ void TTerminal::SourceRobust( { RollbackAction(Action, AOperationProgress, &E); } - throw; + TryReplaceAndThrow(E); } } @@ -8402,7 +8409,7 @@ void TTerminal::SinkRobust( { RollbackAction(Action, AOperationProgress, &E); } - throw; + TryReplaceAndThrow(E); } } From 3b88fc5355b30c18a27d0ab15cd9f66d3aa2fe86 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 16:06:08 +0300 Subject: [PATCH 07/20] Fix crash when reconnecting to inacessible FTP --- src/core/Terminal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Terminal.cpp b/src/core/Terminal.cpp index 45a4154d2..d08ae7e99 100644 --- a/src/core/Terminal.cpp +++ b/src/core/Terminal.cpp @@ -1964,7 +1964,7 @@ void TTerminal::Reopen(int32_t Params) // only peek, we may not be connected at all atm, // so make sure we do not try retrieving current directory from the server // (particularly with FTP) - const UnicodeString CurrentDirectoryPeeked = CurrentDirectory(); + const UnicodeString CurrentDirectoryPeeked = PeekCurrentDirectory(); if (!CurrentDirectoryPeeked.IsEmpty()) { GetSessionData()->SetRemoteDirectory(CurrentDirectoryPeeked); From 33d435a836ede3c8e2ad56fb9904259037312d11 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 16:06:50 +0300 Subject: [PATCH 08/20] Close panel on EAbort in HandleException --- src/NetBox/WinSCPFileSystem.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/NetBox/WinSCPFileSystem.cpp b/src/NetBox/WinSCPFileSystem.cpp index d33f40b22..88330126b 100644 --- a/src/NetBox/WinSCPFileSystem.cpp +++ b/src/NetBox/WinSCPFileSystem.cpp @@ -310,6 +310,8 @@ TWinSCPFileSystem::~TWinSCPFileSystem() noexcept void TWinSCPFileSystem::HandleException(Exception * E, OPERATION_MODES OpMode) { + bool DoClose = false; + if ((GetTerminal() != nullptr) && rtti::isa(E)) { const bool Reopen = GetTerminal()->QueryReopen(E, 0, nullptr); @@ -319,17 +321,23 @@ void TWinSCPFileSystem::HandleException(Exception * E, OPERATION_MODES OpMode) } else { - if (GetTerminal()) - GetTerminal()->ShowExtendedException(E); - if (!GetClosed()) - { - ClosePanel(); - } + GetTerminal()->ShowExtendedException(E); + DoClose = true; } } + else if ((GetTerminal() != nullptr) && rtti::isa(E)) + { + DoClose = true; + } else { TCustomFarFileSystem::HandleException(E, OpMode); + return; + } + + if (DoClose && !GetClosed()) + { + ClosePanel(); } } From afac8c62984c04b64f24512014d728fe6b515f6b Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:11:42 +0300 Subject: [PATCH 09/20] Fix key value alignment --- src/NetBox/WinSCPDialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index 7ace29d61..be0c5e7f2 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -6399,7 +6399,7 @@ void TFileSystemInfoDialog::ControlsAddItem(TObject * AControl, TFarText * Text = List->GetAs(FLastListItem); FLastListItem++; - Text->SetCaption(FORMAT("%d-%s %s", List->MaxLen, GetMsg(Label), Value)); + Text->SetCaption(FORMAT("%*s %s", List->MaxLen, GetMsg(Label).c_str(), Value)); } } } From 3d9d4ecd70978f6e55321a4b1faf6213e2735283 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:11:50 +0300 Subject: [PATCH 10/20] Keep text inside dialog borders --- src/NetBox/WinSCPDialogs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index be0c5e7f2..a148ceeb1 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -6400,6 +6400,7 @@ void TFileSystemInfoDialog::ControlsAddItem(TObject * AControl, FLastListItem++; Text->SetCaption(FORMAT("%*s %s", List->MaxLen, GetMsg(Label).c_str(), Value)); + Text->SetWidth(GetWidth() - 10); } } } From 0cbca62da88d855e52c0b2074f17a139df5a7c9b Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:11:54 +0300 Subject: [PATCH 11/20] Fix style of text messages --- src/NetBox/NetBoxEng.lng | 8 ++++---- src/NetBox/NetBoxPol.lng | 8 ++++---- src/NetBox/NetBoxRus.lng | 8 ++++---- src/NetBox/NetBoxSpa.lng | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/NetBox/NetBoxEng.lng b/src/NetBox/NetBoxEng.lng index 7d795fc19..5ea03af12 100644 --- a/src/NetBox/NetBoxEng.lng +++ b/src/NetBox/NetBoxEng.lng @@ -1,4 +1,4 @@ -.Language=English,English +.Language=English,English "NetBox" "NetBox" @@ -595,10 +595,10 @@ "Capa&bilities" "Space &available" "&Copy to Clipboard" -"Remote system" -"Session protocol" +"Remote system:" +"Session protocol:" "Protocol commands only" -"Can calculate file checksum" +"Can calculate file checksum:" "&Putty path" "&Remember session password and pass it to PuTTY" diff --git a/src/NetBox/NetBoxPol.lng b/src/NetBox/NetBoxPol.lng index 523e66440..d93a3bb75 100644 --- a/src/NetBox/NetBoxPol.lng +++ b/src/NetBox/NetBoxPol.lng @@ -1,4 +1,4 @@ -.Language=Polish,Polish (Polski) +.Language=Polish,Polish (Polski) "NetBox" "NetBox" @@ -595,10 +595,10 @@ "&Możliwości" "&Dostępne miejsce" "&Kopiuj do Schowka" -"Zdalny system" -"Protokół sesji" +"Zdalny system:" +"Protokół sesji:" "Tylko polecenia protokołu" -"Można obliczać sumy kontrolne" +"Można obliczać sumy kontrolne:" "Ścieżka do &Putty " "&Zapamiętaj hasło i przekaż do PuTTY" diff --git a/src/NetBox/NetBoxRus.lng b/src/NetBox/NetBoxRus.lng index 150ee26fe..86c43d9af 100644 --- a/src/NetBox/NetBoxRus.lng +++ b/src/NetBox/NetBoxRus.lng @@ -1,4 +1,4 @@ -.Language=Russian,Russian (Русский) +.Language=Russian,Russian (Русский) "NetBox" "NetBox" @@ -595,10 +595,10 @@ "Capa&bilities" "Space &available" "&Copy to Clipboard" -"Remote system" -"Session protocol" +"Remote system:" +"Session protocol:" "Protocol commands only" -"Can calculate file checksum" +"Can calculate file checksum:" "Путь к &Putty" "&Помнить пароль сессии и передавать его PuTTY" diff --git a/src/NetBox/NetBoxSpa.lng b/src/NetBox/NetBoxSpa.lng index 87960b4cb..d8bd92649 100644 --- a/src/NetBox/NetBoxSpa.lng +++ b/src/NetBox/NetBoxSpa.lng @@ -1,4 +1,4 @@ -.Language=Spanish,Spanish (Español) +.Language=Spanish,Spanish (Español) "NetBox" "NetBox" @@ -595,10 +595,10 @@ "Capa&cidades" "Esp&acio disponible" "&Copiar al Portapapeles" -"Sistema remoto" -"Protocolo de sesión" +"Sistema remoto:" +"Protocolo de sesión:" "Sólo comandos de protocolo" -"Poder calcular checksum de archivo" +"Poder calcular checksum de archivo:" "Ruta &Putty" "&Recordar contraseña de sesión y pasarlo a PuTTY" From b1d8fc4250769b9de68d505b70dfb854c316c63f Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:11:57 +0300 Subject: [PATCH 12/20] Show SSH and SSL fingerprints 1. Display MD5 SSH hostkey fingerprint in addition to an already shown SHA256. 2. Display SHA1 and SHA256 server certificate fingerprints of SSL/TLS encrypted sessions. --- src/NetBox/NetBoxEng.lng | 7 +++- src/NetBox/NetBoxPol.lng | 7 +++- src/NetBox/NetBoxRus.lng | 7 +++- src/NetBox/NetBoxSpa.lng | 7 +++- src/NetBox/WinSCPDialogs.cpp | 75 ++++++++++++++++++++++++++++-------- src/base/MsgIDs.h | 5 ++- 6 files changed, 82 insertions(+), 26 deletions(-) diff --git a/src/NetBox/NetBoxEng.lng b/src/NetBox/NetBoxEng.lng index 5ea03af12..4671f2cb6 100644 --- a/src/NetBox/NetBoxEng.lng +++ b/src/NetBox/NetBoxEng.lng @@ -1,4 +1,4 @@ -.Language=English,English +.Language=English,English "NetBox" "NetBox" @@ -571,7 +571,10 @@ "Encryption algorithm:" "Compression:" "File transfer protocol:" -"Server host key fingerprint:" +"Server host key fingerprint (MD5):" +"Server host key fingerprint (SHA256):" +"Server certificate fingerprint (SHA1):" +"Server certificate fingerprint (SHA256):" " Protocol capabilities/information " "Can change permissions:" "Can change owner/group:" diff --git a/src/NetBox/NetBoxPol.lng b/src/NetBox/NetBoxPol.lng index d93a3bb75..ee26904a5 100644 --- a/src/NetBox/NetBoxPol.lng +++ b/src/NetBox/NetBoxPol.lng @@ -1,4 +1,4 @@ -.Language=Polish,Polish (Polski) +.Language=Polish,Polish (Polski) "NetBox" "NetBox" @@ -571,7 +571,10 @@ "Algorytm szyfrowania:" "Kompresja:" "Protokół przesyłania plików:" -"Odcisk palca klucza serwera:" +"Odcisk palca klucza serwera (MD5):" +"Odcisk palca klucza serwera (SHA256):" +"Server certificate fingerprint (SHA1):" +"Server certificate fingerprint (SHA256):" " Możliwości protokołu/informacje " "Można zmieniać uprawnienia:" "Można zmieniać właściciela/grupę:" diff --git a/src/NetBox/NetBoxRus.lng b/src/NetBox/NetBoxRus.lng index 86c43d9af..4da5cfb40 100644 --- a/src/NetBox/NetBoxRus.lng +++ b/src/NetBox/NetBoxRus.lng @@ -1,4 +1,4 @@ -.Language=Russian,Russian (Русский) +.Language=Russian,Russian (Русский) "NetBox" "NetBox" @@ -571,7 +571,10 @@ "Encryption algorithm:" "Compression:" "File transfer protocol:" -"Server host key fingerprint:" +"Server host key fingerprint (MD5):" +"Server host key fingerprint (SHA256):" +"Server certificate fingerprint (SHA1):" +"Server certificate fingerprint (SHA256):" " Protocol capabilities/information " "Can change permissions:" "Can change owner/group:" diff --git a/src/NetBox/NetBoxSpa.lng b/src/NetBox/NetBoxSpa.lng index d8bd92649..b483fcdad 100644 --- a/src/NetBox/NetBoxSpa.lng +++ b/src/NetBox/NetBoxSpa.lng @@ -1,4 +1,4 @@ -.Language=Spanish,Spanish (Español) +.Language=Spanish,Spanish (Español) "NetBox" "NetBox" @@ -571,7 +571,10 @@ "Algoritmo de codificación:" "Compresión:" "Protocolo de transferencia de archivo:" -"Server host key fingerprint:" +"Server host key fingerprint (MD5):" +"Server host key fingerprint (SHA256):" +"Server certificate fingerprint (SHA1):" +"Server certificate fingerprint (SHA256):" " Capacidades/información de protocolo" "Cambiar permisos:" "Cambiar dueño/grupo:" diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index a148ceeb1..17ca04ead 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -6110,6 +6110,7 @@ class TFileSystemInfoDialog final : public TTabbedDialog void NeedSpaceAvailable(); bool SpaceAvailableSupported() const; virtual bool Key(TFarDialogItem * Item, intptr_t KeyCode) override; + void TFileSystemInfoDialog::SetFingerprintControl(const TFeedFileSystemDataEvent & AddItem, const TObject * AControl); private: TGetSpaceAvailableEvent FOnGetSpaceAvailable; @@ -6125,8 +6126,10 @@ class TFileSystemInfoDialog final : public TTabbedDialog gsl::owner ProtocolLabels{nullptr}; gsl::owner SpaceAvailableLabels{nullptr}; TTabButton * SpaceAvailableTab{nullptr}; - TFarText * HostKeyFingerprintLabel{nullptr}; - TFarEdit * HostKeyFingerprintEdit{nullptr}; + TFarText * ServerFingerprintLabel{nullptr}; + TFarEdit * ServerFingerprintEdit{nullptr}; + TFarText * AdditionalServerFingerprintLabel{nullptr}; + TFarEdit * AdditionalServerFingerprintEdit{nullptr}; TFarText * InfoLabel{nullptr}; TFarSeparator * InfoSeparator{nullptr}; TFarLister * InfoLister{nullptr}; @@ -6184,10 +6187,13 @@ TFileSystemInfoDialog::TFileSystemInfoDialog(TCustomFarPlugin * AFarPlugin, MakeOwnedObject(this); - HostKeyFingerprintLabel = MakeOwnedObject(this); - HostKeyFingerprintLabel->SetCaption(GetMsg(NB_SERVER_HOST_KEY)); - HostKeyFingerprintEdit = MakeOwnedObject(this); - HostKeyFingerprintEdit->SetReadOnly(true); + ServerFingerprintLabel = MakeOwnedObject(this); + ServerFingerprintEdit = MakeOwnedObject(this); + ServerFingerprintEdit->SetReadOnly(true); + AdditionalServerFingerprintLabel = MakeOwnedObject(this); + AdditionalServerFingerprintLabel->Move(0, 1); + AdditionalServerFingerprintEdit = MakeOwnedObject(this); + AdditionalServerFingerprintEdit->SetReadOnly(true); // Protocol tab @@ -6326,7 +6332,8 @@ void TFileSystemInfoDialog::Feed(TFeedFileSystemDataEvent && AddItem) AddItem(ServerLabels, NB_SERVER_FS_PROTOCOL, FFileSystemInfo.ProtocolName); } - AddItem(HostKeyFingerprintEdit, 0, FSessionInfo.HostKeyFingerprintSHA256); + SetFingerprintControl(AddItem, ServerFingerprintEdit); + SetFingerprintControl(AddItem, AdditionalServerFingerprintEdit); AddItem(ProtocolLabels, NB_PROTOCOL_MODE_CHANGING, CapabilityStr(fcModeChanging)); AddItem(ProtocolLabels, NB_PROTOCOL_OWNER_GROUP_CHANGING, CapabilityStr(fcGroupChanging)); @@ -6366,16 +6373,20 @@ void TFileSystemInfoDialog::ControlsAddItem(TObject * AControl, FLastListItem = 0; } - if (AControl == HostKeyFingerprintEdit) + if (AControl == ServerFingerprintEdit || + AControl == AdditionalServerFingerprintEdit) { - HostKeyFingerprintEdit->SetText(Value); - HostKeyFingerprintEdit->SetEnabled(!Value.IsEmpty()); - if (!HostKeyFingerprintEdit->GetEnabled()) + auto Control = cast_to(AControl); + Control->SetText(Value); + Control->SetEnabled(!Value.IsEmpty()); + if (!Control->GetEnabled()) { - HostKeyFingerprintEdit->SetVisible(false); - HostKeyFingerprintEdit->SetGroup(0); - HostKeyFingerprintLabel->SetVisible(false); - HostKeyFingerprintLabel->SetGroup(0); + Control->SetVisible(false); + Control->SetGroup(0); + auto CtlLabel = (AControl == ServerFingerprintEdit) ? + ServerFingerprintLabel : AdditionalServerFingerprintLabel; + CtlLabel->SetVisible(false); + CtlLabel->SetGroup(0); } } else if (AControl == InfoLister) @@ -6441,9 +6452,13 @@ void TFileSystemInfoDialog::ClipboardAddItem(TObject * AControl, bool UseNewline = true; UnicodeString LabelStr; - if (AControl == HostKeyFingerprintEdit) + if (AControl == ServerFingerprintEdit) { - LabelStr = GetMsg(NB_SERVER_HOST_KEY); + LabelStr = ServerFingerprintLabel->GetCaption(); + } + else if (AControl == AdditionalServerFingerprintEdit) + { + LabelStr = AdditionalServerFingerprintLabel->GetCaption(); } else if (AControl == InfoLister) { @@ -6602,6 +6617,32 @@ bool TFileSystemInfoDialog::SpaceAvailableSupported() const return (FOnGetSpaceAvailable); } +void TFileSystemInfoDialog::SetFingerprintControl(const TFeedFileSystemDataEvent & AddItem, const TObject * AControl) +{ +#define SET_CONTROLS(CONTROL, HOST_HASH, CERT_HASH) \ +do { \ + const auto UseCertificate = FSessionInfo.HostKeyFingerprint ## HOST_HASH.IsEmpty(); \ + CONTROL ## Label->SetCaption(GetMsg(UseCertificate ? \ + NB_SERVER_CERT_ ## CERT_HASH : NB_SERVER_HOST_KEY_ ## HOST_HASH)); \ + AddItem(CONTROL ## Edit, 0, UseCertificate ? \ + FSessionInfo.CertificateFingerprint ## CERT_HASH : FSessionInfo.HostKeyFingerprint ## HOST_HASH); \ +} while (0) + + if (AControl == ServerFingerprintEdit) + { + SET_CONTROLS(ServerFingerprint, MD5, SHA1); + } + else if (AControl == AdditionalServerFingerprintEdit) + { + SET_CONTROLS(AdditionalServerFingerprint, SHA256, SHA256); + } + else + { + DebugFail(); + } +#undef SET_CONTROLS +} + void TWinSCPFileSystem::FileSystemInfoDialog( const TSessionInfo & SessionInfo, const TFileSystemInfo & FileSystemInfo, const UnicodeString & SpaceAvailablePath, TGetSpaceAvailableEvent && OnGetSpaceAvailable) diff --git a/src/base/MsgIDs.h b/src/base/MsgIDs.h index fa4881644..b6f490fc0 100644 --- a/src/base/MsgIDs.h +++ b/src/base/MsgIDs.h @@ -571,7 +571,10 @@ enum MsgIDs { NB_SERVER_CIPHER, NB_SERVER_COMPRESSION, NB_SERVER_FS_PROTOCOL, - NB_SERVER_HOST_KEY, + NB_SERVER_HOST_KEY_MD5, + NB_SERVER_HOST_KEY_SHA256, + NB_SERVER_CERT_SHA1, + NB_SERVER_CERT_SHA256, NB_PROTOCOL_INFORMATION_GROUP, NB_PROTOCOL_MODE_CHANGING, NB_PROTOCOL_OWNER_GROUP_CHANGING, From 9def184b22f281f832f56811906a3323c37bd03f Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:12:00 +0300 Subject: [PATCH 13/20] Fix text style 1. Encryption algorithm can contain new line, so strip it 2. Do not copy empty properties to clipboard --- src/NetBox/WinSCPDialogs.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index 17ca04ead..35e411e57 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -6314,10 +6314,10 @@ void TFileSystemInfoDialog::Feed(TFeedFileSystemDataEvent && AddItem) AddItem(ServerLabels, NB_SERVER_SESSION_PROTOCOL, FSessionInfo.ProtocolName); AddItem(ServerLabels, NB_SERVER_SSH_IMPLEMENTATION, FSessionInfo.SshImplementation); - UnicodeString Str = FSessionInfo.CSCipher; + UnicodeString Str = ::TrimRight(FSessionInfo.CSCipher); if (FSessionInfo.CSCipher != FSessionInfo.SCCipher) { - Str += FORMAT("/%s", FSessionInfo.SCCipher); + Str += FORMAT("/%s", ::TrimRight(FSessionInfo.SCCipher)); } AddItem(ServerLabels, NB_SERVER_CIPHER, Str); @@ -6439,7 +6439,8 @@ void TFileSystemInfoDialog::ClipboardAddItem(TObject * AControl, if ((!Value.IsEmpty() && ((Control == nullptr) || Control->GetEnabled()) && (AControl != SpaceAvailableLabels)) || - SpaceAvailableSupported()) + SpaceAvailableSupported() && + (AControl == SpaceAvailableLabels)) { if (FLastFedControl != AControl) { From 034d2169df1b0f4607acf5cfd12e47e1899c79a5 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:12:06 +0300 Subject: [PATCH 14/20] Fix TFarLister scrolling with mouse wheel --- src/NetBox/FarDialog.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/NetBox/FarDialog.cpp b/src/NetBox/FarDialog.cpp index 7c626b6b7..2c2b299ad 100644 --- a/src/NetBox/FarDialog.cpp +++ b/src/NetBox/FarDialog.cpp @@ -2783,7 +2783,17 @@ intptr_t TFarLister::ItemProc(intptr_t Msg, void * Param) { Result = TFarDialogItem::ItemProc(Msg, Param); } - else + else if (FLAGSET(Event->dwEventFlags, MOUSE_WHEELED)) + { + auto WheelDelta = (nb::ToInt(Event->dwButtonState) >> 16) / 120; + int32_t NewTopIndex = GetTopIndex() - WheelDelta; + if (NewTopIndex >= 0 && NewTopIndex <= GetItems()->GetCount() - GetHeight()) + { + SetTopIndex(NewTopIndex); + } + Result = 1; + } + else if (Event->dwEventFlags == 0) { int32_t NewTopIndex = GetTopIndex(); From 91fc6250fbe0bf2c028994aeb452ae46708c0421 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:13:23 +0300 Subject: [PATCH 15/20] Show S3 key labels in Session Edit dialog --- src/NetBox/WinSCPDialogs.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index 7ace29d61..949b0affc 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -1592,8 +1592,10 @@ class TSessionDialog final : public TTabbedDialog TFarEdit * HostNameEdit{nullptr}; TFarEdit * PortNumberEdit{nullptr}; TFarText * UserNameLabel{nullptr}; + TFarText * S3AccessKeyIDLabel{nullptr}; TFarEdit * UserNameEdit{nullptr}; TFarText * PasswordLabel{nullptr}; + TFarText * S3SecretAccessKeyLabel{nullptr}; TFarEdit * PasswordEdit{nullptr}; TFarEdit * PrivateKeyEdit{nullptr}; TFarComboBox * TransferProtocolCombo{nullptr}; @@ -1897,6 +1899,12 @@ TSessionDialog::TSessionDialog(TCustomFarPlugin * AFarPlugin, TSessionActionEnum UserNameLabel->SetCaption(GetMsg(NB_LOGIN_USER_NAME)); UserNameLabel->SetWidth(20); + SetNextItemPosition(ipSame); + S3AccessKeyIDLabel = MakeOwnedObject(this); + S3AccessKeyIDLabel->SetCaption(GetMsg(NB_LOGIN_S3_ACCESS_KEY)); + S3AccessKeyIDLabel->SetWidth(20); + S3AccessKeyIDLabel->SetVisible(false); + SetNextItemPosition(ipRight); UserNameEdit = MakeOwnedObject(this); @@ -1914,6 +1922,12 @@ TSessionDialog::TSessionDialog(TCustomFarPlugin * AFarPlugin, TSessionActionEnum PasswordLabel->SetWidth(20); PasswordLabel->SetVisible(true); + SetNextItemPosition(ipSame); + S3SecretAccessKeyLabel = MakeOwnedObject(this); + S3SecretAccessKeyLabel->SetCaption(GetMsg(NB_LOGIN_S3_SECRET_ACCESS_KEY)); + S3SecretAccessKeyLabel->SetWidth(20); + S3SecretAccessKeyLabel->SetVisible(false); + SetNextItemPosition(ipRight); PasswordEdit = MakeOwnedObject(this); @@ -3048,10 +3062,10 @@ void TSessionDialog::UpdateControls() UserNameEdit->SetEnabled(!LoginAnonymous); PasswordEdit->SetEnabled(!LoginAnonymous); - UserNameLabel->SetVisible(IsMainTab && !lS3Protocol); - UserNameEdit->SetVisible(IsMainTab); - PasswordLabel->SetVisible(IsMainTab && !lS3Protocol); - PasswordEdit->SetVisible(IsMainTab); + UserNameLabel->SetVisible(!lS3Protocol); + S3AccessKeyIDLabel->SetVisible(lS3Protocol); + PasswordLabel->SetVisible(!lS3Protocol); + S3SecretAccessKeyLabel->SetVisible(lS3Protocol); // Connection sheet FtpPasvModeCheck->SetEnabled(lFtpProtocol); From 7d0fbb9da460298730c5eedf90846f7a14670aba Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:13:56 +0300 Subject: [PATCH 16/20] Fix behaviour when connecting session with empty hostname 1. Use real session data instead of empty one 2. Pressing Cancel prevents connection 3. Pressing Ok acts the same as Connect 4. Remove redundant code --- src/NetBox/WinSCPFileSystem.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/NetBox/WinSCPFileSystem.cpp b/src/NetBox/WinSCPFileSystem.cpp index d33f40b22..f74614174 100644 --- a/src/NetBox/WinSCPFileSystem.cpp +++ b/src/NetBox/WinSCPFileSystem.cpp @@ -631,7 +631,7 @@ void TWinSCPFileSystem::EditConnectSession(TSessionData * Data, bool Edit) { const bool NewData = !Data; const bool FillInConnect = !Edit && Data && !Data->GetCanLogin(); - if (NewData || FillInConnect) + if (NewData) { Data = new TSessionData(L""); } @@ -642,7 +642,7 @@ void TWinSCPFileSystem::EditConnectSession(TSessionData * Data, bool Edit) } __finally { - if (NewData || FillInConnect) + if (NewData) { SAFE_DESTROY(Data); } @@ -651,19 +651,22 @@ void TWinSCPFileSystem::EditConnectSession(TSessionData * Data, bool Edit) void TWinSCPFileSystem::EditConnectSession(TSessionData * Data, bool Edit, bool NewData, bool FillInConnect) { - TSessionData * OrigData = Data; - if (FillInConnect && Data) - { - Data->Assign(OrigData); - Data->SetName(L""); - } - TSessionActionEnum Action; if (Edit || FillInConnect) { - Action = (FillInConnect ? saConnect : (OrigData == nullptr ? saAdd : saEdit)); + Action = (FillInConnect ? saConnect : (Data == nullptr ? saAdd : saEdit)); if (SessionDialog(Data, Action)) { + if (FillInConnect) + { + // nothing to add/edit, just connect + Action = saConnect; + // but check if we can login + if (Data && !Data->GetCanLogin()) + { + return; + } + } if ((!NewData && !FillInConnect) || (Action != saConnect)) { const TSessionData * SelectSession = nullptr; @@ -693,12 +696,6 @@ void TWinSCPFileSystem::EditConnectSession(TSessionData * Data, bool Edit, bool } } } - else if (FillInConnect && OrigData) - { - const UnicodeString OrigName = OrigData->GetName(); - OrigData->Assign(Data); - OrigData->SetName(OrigName); - } // modified only, explicit GetStoredSessions()->Save(false, true); @@ -714,6 +711,10 @@ void TWinSCPFileSystem::EditConnectSession(TSessionData * Data, bool Edit, bool } } } + else + { + return; + } } else { From 14023fae2721a1fee991404552804c3f4283b7ed Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:14:22 +0300 Subject: [PATCH 17/20] Fix IP protocol selection --- src/NetBox/WinSCPDialogs.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index 7ace29d61..318ca1b9a 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -3065,7 +3065,9 @@ void TSessionDialog::UpdateControls() } SshBufferSizeCheck->SetEnabled(lSshProtocol); PingNullPacketButton->SetEnabled(lSshProtocol); - IPAutoButton->SetEnabled(lSshProtocol); + IPAutoButton->SetEnabled(lSshProtocol || lFtpProtocol); + IPv4Button->SetEnabled(lSshProtocol || lFtpProtocol); + IPv6Button->SetEnabled(lSshProtocol || lFtpProtocol); // SFTP tab SftpTab->SetEnabled(lSftpProtocol); From e93fe7f910c90bba5c47dc2c5596f093be7ccc7b Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 17:14:52 +0300 Subject: [PATCH 18/20] Do not spoil default CopyParam --- src/NetBox/WinSCPDialogs.cpp | 6 +++--- src/NetBox/WinSCPFileSystem.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index 7ace29d61..4aabffb38 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -566,7 +566,7 @@ bool TWinSCPPlugin::TransferConfigurationDialog() const UnicodeString Caption = FORMAT("%s - %s", GetMsg(NB_PLUGIN_TITLE), ::StripHotkey(GetMsg(NB_CONFIG_TRANSFER))); - TGUICopyParamType & CopyParam = GetGUIConfiguration()->GetDefaultCopyParam(); + TGUICopyParamType CopyParam(GetGUIConfiguration()->GetDefaultCopyParam()); const bool Result = CopyParamDialog(Caption, CopyParam, 0); if (Result) { @@ -677,7 +677,7 @@ bool TWinSCPPlugin::EnduranceConfigurationDialog() Dialog->AddStandardButtons(); - TGUICopyParamType & CopyParam = GetGUIConfiguration()->GetDefaultCopyParam(); + TGUICopyParamType CopyParam(GetGUIConfiguration()->GetDefaultCopyParam()); ResumeOnButton->SetChecked(CopyParam.GetResumeSupport() == rsOn); ResumeSmartButton->SetChecked(CopyParam.GetResumeSupport() == rsSmart); ResumeOffButton->SetChecked(CopyParam.GetResumeSupport() == rsOff); @@ -778,7 +778,7 @@ bool TWinSCPPlugin::QueueConfigurationDialog() GetConfiguration()->BeginUpdate(); try__finally { - TGUICopyParamType & CopyParam = GetGUIConfiguration()->GetDefaultCopyParam(); + TGUICopyParamType CopyParam(GetGUIConfiguration()->GetDefaultCopyParam()); FarConfiguration->SetQueueTransfersLimit(QueueTransferLimitEdit->GetAsInteger()); CopyParam.SetQueue(QueueCheck->GetChecked()); diff --git a/src/NetBox/WinSCPFileSystem.cpp b/src/NetBox/WinSCPFileSystem.cpp index d33f40b22..d68aa3294 100644 --- a/src/NetBox/WinSCPFileSystem.cpp +++ b/src/NetBox/WinSCPFileSystem.cpp @@ -1306,7 +1306,8 @@ void TWinSCPFileSystem::ApplyCommand() UnicodeString TempDir; - TemporarilyDownloadFiles(FileList.get(), GetGUIConfiguration()->GetDefaultCopyParam(), TempDir); + TGUICopyParamType CopyParam(GetGUIConfiguration()->GetDefaultCopyParam()); + TemporarilyDownloadFiles(FileList.get(), CopyParam, TempDir); try__finally { RemoteFileList = std::make_unique(); From 663abe678246f7eff707c35cfadd1e43f569e967 Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Sat, 25 May 2024 22:23:30 +0300 Subject: [PATCH 19/20] Return back the ability to change file names on upload --- src/NetBox/WinSCPDialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetBox/WinSCPDialogs.cpp b/src/NetBox/WinSCPDialogs.cpp index 7ace29d61..b1044b6bd 100644 --- a/src/NetBox/WinSCPDialogs.cpp +++ b/src/NetBox/WinSCPDialogs.cpp @@ -5808,7 +5808,7 @@ bool TCopyDialog::Execute(UnicodeString & TargetDirectory, UnicodeString NewTargetDirectory; if (FToRemote) { - // Params->SetFileMask(base::UnixExtractFileName(DirectoryEdit->GetText())); + Params->SetFileMask(base::UnixExtractFileName(DirectoryEdit->GetText())); NewTargetDirectory = base::UnixExtractFilePath(DirectoryEdit->GetText()); if (!NewTargetDirectory.IsEmpty()) TargetDirectory = NewTargetDirectory; From 8de73f4ec6cb2a7bdefeba5b04c158730a7b153d Mon Sep 17 00:00:00 2001 From: ssvine <79405160+ssvine@users.noreply.github.com> Date: Mon, 27 May 2024 23:06:00 +0300 Subject: [PATCH 20/20] Fix updating session on import --- src/core/SessionData.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/SessionData.cpp b/src/core/SessionData.cpp index fabfdb519..a265394a8 100644 --- a/src/core/SessionData.cpp +++ b/src/core/SessionData.cpp @@ -5409,6 +5409,11 @@ void TStoredSessionList::Load(THierarchicalStorage * Storage, SessionData->Load(Storage, PuttyImport); // gh-364 Add(SessionData); } + else if (AsModified) + { + // import existing session: just update + SessionData->Load(Storage, PuttyImport); + } Loaded->Add(SessionData); // line moved up, gh-364: SessionData->Load(Storage, PuttyImport); if (AsModified)