浏览代码

Protocol prefix ftpes:// for FTP over explicit TLS/SSL

Source commit: 7daf9d67f9d30d2d2b03cfa4b32e6380cfeec121
Martin Prikryl 10 年之前
父节点
当前提交
d7f2300ebe

+ 5 - 0
dotnet/SessionOptions.cs

@@ -239,6 +239,11 @@ namespace WinSCP
                 Protocol = Protocol.Ftp;
                 FtpSecure = FtpSecure.Implicit;
             }
+            else if (protocol.Equals("ftpes", StringComparison.OrdinalIgnoreCase))
+            {
+                Protocol = Protocol.Ftp;
+                FtpSecure = FtpSecure.Explicit;
+            }
             else if (protocol.Equals("http", StringComparison.OrdinalIgnoreCase))
             {
                 Protocol = Protocol.Webdav;

+ 1 - 1
source/core/Script.cpp

@@ -2061,7 +2061,7 @@ __fastcall TManagementScript::TManagementScript(TStoredSessionList * StoredSessi
 
   FCommands->Register(L"exit", SCRIPT_EXIT_DESC, SCRIPT_EXIT_HELP, &ExitProc, 0, 0, false);
   FCommands->Register(L"bye", 0, SCRIPT_EXIT_HELP, &ExitProc, 0, 0, false);
-  FCommands->Register(L"open", SCRIPT_OPEN_DESC, SCRIPT_OPEN_HELP7, &OpenProc, 0, -1, true);
+  FCommands->Register(L"open", SCRIPT_OPEN_DESC, SCRIPT_OPEN_HELP8, &OpenProc, 0, -1, true);
   FCommands->Register(L"close", SCRIPT_CLOSE_DESC, SCRIPT_CLOSE_HELP, &CloseProc, 0, 1, false);
   FCommands->Register(L"session", SCRIPT_SESSION_DESC, SCRIPT_SESSION_HELP, &SessionProc, 0, 1, false);
   FCommands->Register(L"lpwd", SCRIPT_LPWD_DESC, SCRIPT_LPWD_HELP, &LPwdProc, 0, 0, false);

+ 15 - 16
source/core/SessionData.cpp

@@ -46,6 +46,7 @@ const UnicodeString SftpProtocol(L"sftp");
 const UnicodeString ScpProtocol(L"scp");
 const UnicodeString FtpProtocol(L"ftp");
 const UnicodeString FtpsProtocol(L"ftps");
+const UnicodeString FtpesProtocol(L"ftpes");
 const UnicodeString WebDAVProtocol(L"http");
 const UnicodeString WebDAVSProtocol(L"https");
 const UnicodeString SshProtocol(L"ssh");
@@ -1041,7 +1042,7 @@ void __fastcall TSessionData::ImportFromFilezilla(_di_IXMLNode Node, const Unico
 
     case 4: // FTPES
       FSProtocol = fsFTP;
-      Ftps = ftpsExplicitSsl;
+      Ftps = ftpsExplicitTls;
       break;
   }
 
@@ -1389,6 +1390,14 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
     MoveStr(Url, MaskedUrl, ProtocolLen);
     ProtocolDefined = true;
   }
+  else if (IsProtocolUrl(Url, FtpesProtocol, ProtocolLen))
+  {
+    AFSProtocol = fsFTP;
+    AFtps = ftpsExplicitTls;
+    APortNumber = FtpPortNumber;
+    MoveStr(Url, MaskedUrl, ProtocolLen);
+    ProtocolDefined = true;
+  }
   else if (IsProtocolUrl(Url, WebDAVProtocol, ProtocolLen))
   {
     AFSProtocol = fsWebDAV;
@@ -2333,6 +2342,10 @@ UnicodeString __fastcall TSessionData::GetProtocolUrl()
       {
         Url = FtpsProtocol;
       }
+      else if ((Ftps == ftpsExplicitTls) || (Ftps == ftpsExplicitSsl))
+      {
+        Url = FtpesProtocol;
+      }
       else
       {
         Url = FtpProtocol;
@@ -2478,22 +2491,8 @@ UnicodeString __fastcall TSessionData::GenerateOpenCommandArgs()
   SessionData->UserName = FactoryDefaults->UserName;
   SessionData->Password = FactoryDefaults->Password;
   SessionData->CopyNonCoreData(FactoryDefaults.get());
+  SessionData->Ftps = FactoryDefaults->Ftps;
 
-  if (SessionData->Ftps != FactoryDefaults->Ftps)
-  {
-    switch (SessionData->Ftps)
-    {
-      case ftpsImplicit:
-        // noop, implicit encryption is reflects in protocol prefix
-        break;
-
-      case ftpsExplicitTls:
-      case ftpsExplicitSsl:
-        AddSwitch(Result, L"explicit");
-        break;
-    }
-    SessionData->Ftps = FactoryDefaults->Ftps;
-  }
   if (SessionData->HostKey != FactoryDefaults->HostKey)
   {
     UnicodeString SwitchName = AUsesSsh ? L"hostkey" : L"certificate";

+ 1 - 0
source/core/SessionData.h

@@ -67,6 +67,7 @@ extern const UnicodeString SftpProtocol;
 extern const UnicodeString ScpProtocol;
 extern const UnicodeString FtpProtocol;
 extern const UnicodeString FtpsProtocol;
+extern const UnicodeString FtpesProtocol;
 extern const UnicodeString WebDAVProtocol;
 extern const UnicodeString WebDAVSProtocol;
 extern const UnicodeString SshProtocol;

+ 2 - 2
source/core/SessionInfo.cpp

@@ -1184,12 +1184,12 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data)
             break;
 
           case ftpsExplicitSsl:
-            Ftps = L"Explicit SSL";
+            Ftps = L"Explicit SSL/TLS";
             FtpsOn = true;
             break;
 
           case ftpsExplicitTls:
-            Ftps = L"Explicit TLS";
+            Ftps = L"Explicit TLS/SSL";
             FtpsOn = true;
             break;
 

+ 1 - 1
source/resource/TextsCore.h

@@ -7,7 +7,7 @@
 
 #define SCRIPT_HELP_HELP        4
 #define SCRIPT_EXIT_HELP        5
-#define SCRIPT_OPEN_HELP7       6
+#define SCRIPT_OPEN_HELP8       6
 #define SCRIPT_CLOSE_HELP       7
 #define SCRIPT_SESSION_HELP     8
 #define SCRIPT_PWD_HELP         9

+ 4 - 4
source/resource/TextsCore2.rc

@@ -59,9 +59,9 @@ BEGIN
     "  Closes all sessions and terminates the program.\n"
     "alias:\n"
     "  bye\n"
-  SCRIPT_OPEN_HELP7,
+  SCRIPT_OPEN_HELP8,
     "open <site>\n"
-    "open sftp|scp|ftp|http[s] :// [ <user> [ :password ] @ ] <host> [ :<port> ]\n"
+    "open sftp|scp|ftp[es]|http[s] :// [ <user> [ :password ] @ ] <host> [ :<port> ]\n"
     "  Establishes connection to given host. Use either name of the site or\n"
     "  specify host, username, port and protocol directly.\n"
     "switches:\n"
@@ -72,8 +72,8 @@ BEGIN
     "                     (FTPS and WebDAVS only)\n"
     "  -passphrase=<phr>  Private key passphrase\n"
     "  -passive=on|off    Passive mode (FTP protocol only)\n"
-    "  -implicit          Implicit TLS/SSL (FTPS protocol only)\n"
-    "  -explicit          Explicit TLS/SSL (FTPS protocol only)\n"
+    "  -implicit          Implicit TLS/SSL (FTP protocol only)\n"
+    "  -explicit          Explicit TLS/SSL (FTP protocol only)\n"
     "  -timeout=<sec>     Server response timeout\n"
     "  -rawsettings setting1=value1 setting2=value2 ...\n"
     "                     Configures any site settings using raw format\n"

+ 2 - 2
source/resource/TextsWin1.rc

@@ -260,8 +260,8 @@ BEGIN
         USAGE_HOSTKEY, "Fingerprint of server SSH host key."
         USAGE_CLIENTCERT, "TLS/SSL client certificate file."
         USAGE_PASSIVE, "Passive mode (FTP protocol only)."
-        USAGE_IMPLICIT, "Implicit TLS/SSL (FTPS protocol only)."
-        USAGE_EXPLICIT, "Explicit TLS/SSL (FTPS protocol only)."
+        USAGE_IMPLICIT, "Implicit TLS/SSL (FTP protocol only)."
+        USAGE_EXPLICIT, "Explicit TLS/SSL (FTP protocol only)."
         USAGE_TIMEOUT, "Server response timeout."
         USAGE_RAWSETTINGS, "Configures any session settings using raw format as in an INI file."
         USAGE_UPDATE, "Queries application homepage for updates."

+ 1 - 2
source/windows/ConsoleRunner.cpp

@@ -2041,7 +2041,6 @@ static void __fastcall RegisterSwitch(
 //---------------------------------------------------------------------------
 void __fastcall Usage(TConsole * Console)
 {
-
   ConsolePrintLine(Console, FORMAT(L"WinSCP, %s", (Configuration->VersionStr)));
   UnicodeString Copyright =
     ReplaceText(LoadStr(WINSCP_COPYRIGHT), L"©", L"(c)");
@@ -2052,7 +2051,7 @@ void __fastcall Usage(TConsole * Console)
   if (!Console->CommandLineOnly())
   {
     PrintUsageSyntax(Console, L"site|workspace|folder");
-    PrintUsageSyntax(Console, L"(sftp|scp|ftp|http[s])://[user[:password]@]host[:port][/path/[file]]");
+    PrintUsageSyntax(Console, L"(sftp|scp|ftp[es]|http[s])://[user[:password]@]host[:port][/path/[file]]");
     PrintUsageSyntax(Console, L"[mysession] /newinstance");
     PrintUsageSyntax(Console, L"[mysession] /edit <path>");
     PrintUsageSyntax(Console, L"[mysession] /synchronize [local_dir] [remote_dir] [/defaults]");

+ 4 - 0
source/windows/Setup.cpp

@@ -566,6 +566,7 @@ static void __fastcall RegisterProtocolsForDefaultPrograms(HKEY RootKey)
 
   RegisterProtocolForDefaultPrograms(RootKey, FtpProtocol);
   RegisterProtocolForDefaultPrograms(RootKey, FtpsProtocol);
+  RegisterProtocolForDefaultPrograms(RootKey, FtpesProtocol);
   RegisterProtocolForDefaultPrograms(RootKey, SftpProtocol);
   RegisterProtocolForDefaultPrograms(RootKey, ScpProtocol);
   RegisterProtocolForDefaultPrograms(RootKey, SshProtocol);
@@ -578,6 +579,7 @@ static void __fastcall UnregisterProtocolsForDefaultPrograms(HKEY RootKey, bool
 {
   UnregisterProtocolForDefaultPrograms(RootKey, FtpProtocol, ForceHandlerUnregistration);
   UnregisterProtocolForDefaultPrograms(RootKey, FtpsProtocol, ForceHandlerUnregistration);
+  UnregisterProtocolForDefaultPrograms(RootKey, FtpesProtocol, ForceHandlerUnregistration);
   UnregisterProtocolForDefaultPrograms(RootKey, SftpProtocol, ForceHandlerUnregistration);
   UnregisterProtocolForDefaultPrograms(RootKey, ScpProtocol, ForceHandlerUnregistration);
   UnregisterProtocolForDefaultPrograms(RootKey, SshProtocol, ForceHandlerUnregistration);
@@ -627,6 +629,7 @@ void __fastcall RegisterForDefaultProtocols()
   RegisterAsNonBrowserUrlHandler(WinSCPProtocolPrefix);
   RegisterAsUrlHandler(WinSCPProtocolPrefix + FtpProtocol.UpperCase());
   RegisterAsUrlHandler(WinSCPProtocolPrefix + FtpsProtocol.UpperCase());
+  RegisterAsUrlHandler(WinSCPProtocolPrefix + FtpesProtocol.UpperCase());
   RegisterAsUrlHandler(WinSCPProtocolPrefix + WebDAVProtocol.UpperCase());
   RegisterAsUrlHandler(WinSCPProtocolPrefix + WebDAVSProtocol.UpperCase());
   RegisterAsUrlHandler(WinSCPProtocolPrefix + SshProtocol.UpperCase());
@@ -640,6 +643,7 @@ void __fastcall UnregisterForProtocols()
   UnregisterAsUrlHandlers(WinSCPProtocolPrefix, true);
   UnregisterAsUrlHandler(WinSCPProtocolPrefix + FtpProtocol.UpperCase(), true);
   UnregisterAsUrlHandler(WinSCPProtocolPrefix + FtpsProtocol.UpperCase(), true);
+  UnregisterAsUrlHandler(WinSCPProtocolPrefix + FtpesProtocol.UpperCase(), true);
   UnregisterAsUrlHandler(WinSCPProtocolPrefix + WebDAVProtocol.UpperCase(), true);
   UnregisterAsUrlHandler(WinSCPProtocolPrefix + WebDAVSProtocol.UpperCase(), true);
   UnregisterAsUrlHandler(WinSCPProtocolPrefix + SshProtocol.UpperCase(), true);