OSDN Git Service

Add support for FTP over Implicit SSL/TLS (untested and please set the port number...
authors_kawamoto <s_kawamoto@users.sourceforge.jp>
Fri, 28 Oct 2011 11:34:32 +0000 (20:34 +0900)
committers_kawamoto <s_kawamoto@users.sourceforge.jp>
Fri, 28 Oct 2011 11:34:32 +0000 (20:34 +0900)
FFFTP_Eng_Release/FFFTP.exe
Release/FFFTP.exe
connect.c
hostman.c
main.c
socket.c
socketwrapper.c

index 6598780..6c2c885 100644 (file)
Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
index 82c59a3..1bdc64a 100644 (file)
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
index 186bfca..aec0444 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -1303,6 +1303,8 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                {\r
                                                        if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)\r
                                                        {\r
+                                                               while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)\r
+                                                                       ;\r
                                                        }\r
                                                        else\r
                                                                Sts = FTP_ERROR;\r
@@ -1566,12 +1568,12 @@ static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass,
                if((ContSock = DoConnectCrypt(CRYPT_SFTP, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
                        HostData->CryptMode = CRYPT_SFTP;\r
        }\r
-//     if(CancelFlg == NO && ContSock == INVALID_SOCKET && HostData->UseFTPIS == YES)\r
-//     {\r
-//             SetTaskMsg(MSGJPN316);\r
-//             if((ContSock = DoConnectCrypt(CRYPT_FTPIS, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
-//                     HostData->CryptMode = CRYPT_FTPIS;\r
-//     }\r
+       if(CancelFlg == NO && ContSock == INVALID_SOCKET && HostData->UseFTPIS == YES)\r
+       {\r
+               SetTaskMsg(MSGJPN316);\r
+               if((ContSock = DoConnectCrypt(CRYPT_FTPIS, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
+                       HostData->CryptMode = CRYPT_FTPIS;\r
+       }\r
        if(CancelFlg == NO && ContSock == INVALID_SOCKET && HostData->UseFTPES == YES)\r
        {\r
                SetTaskMsg(MSGJPN315);\r
index 767e7d3..96b1099 100644 (file)
--- a/hostman.c
+++ b/hostman.c
@@ -2163,9 +2163,6 @@ static BOOL CALLBACK CryptSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, L
                        }\r
                        SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, TmpHost.UseSFTP, 0);\r
                        SendDlgItemMessage(hDlg, HSET_PRIVATE_KEY, WM_SETTEXT, 0, (LPARAM)TmpHost.PrivateKey);\r
-                       // TODO: FTPIS対応\r
-                       SendDlgItemMessage(hDlg, HSET_FTPIS, BM_SETCHECK, BST_UNCHECKED, 0);\r
-                       EnableWindow(GetDlgItem(hDlg, HSET_FTPIS), FALSE);\r
                        // TODO: SFTP対応\r
                        SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, BST_UNCHECKED, 0);\r
                        EnableWindow(GetDlgItem(hDlg, HSET_SFTP), FALSE);\r
@@ -2180,8 +2177,7 @@ static BOOL CALLBACK CryptSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, L
                                        if(IsOpenSSLLoaded())\r
                                        {\r
                                                TmpHost.UseFTPES = SendDlgItemMessage(hDlg, HSET_FTPES, BM_GETCHECK, 0, 0);\r
-                                               // TODO: FTPIS対応\r
-//                                             TmpHost.UseFTPIS = SendDlgItemMessage(hDlg, HSET_FTPIS, BM_GETCHECK, 0, 0);\r
+                                               TmpHost.UseFTPIS = SendDlgItemMessage(hDlg, HSET_FTPIS, BM_GETCHECK, 0, 0);\r
                                        }\r
                                        // TODO: SFTP対応\r
 //                                     TmpHost.UseSFTP = SendDlgItemMessage(hDlg, HSET_SFTP, BM_GETCHECK, 0, 0);\r
diff --git a/main.c b/main.c
index 161c73e..42a7534 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2856,12 +2856,8 @@ BOOL __stdcall SSLTimeoutCallback()
        Sleep(1);\r
        if(BackgrndMessageProc() == YES)\r
                return TRUE;\r
-       // 念のためツールバーのMENU_ABORTも確認\r
-//     if(MainTransPkt.Abort != ABORT_NONE)\r
-//     {\r
-//             MainTransPkt.Abort = ABORT_NONE;\r
-//             return TRUE;\r
-//     }\r
+       if(CancelFlg == YES)\r
+               return TRUE;\r
        return FALSE;\r
 }\r
 \r
index fb04a0f..1051425 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -779,12 +779,7 @@ int do_connect(SOCKET s, const struct sockaddr *name, int namelen, int *CancelCh
        Ret = WSAAsyncSelect(s, hWndSocket, WM_ASYNC_SOCKET, FD_CONNECT | FD_CLOSE | FD_ACCEPT | FD_READ | FD_WRITE);\r
        if(Ret != SOCKET_ERROR)\r
        {\r
-               // FTPS対応\r
-//             Ret = connect(s, name, namelen);\r
-               if(AskCryptMode() == CRYPT_FTPIS)\r
-                       Ret = connectS(s, name, namelen);\r
-               else\r
-                       Ret = connect(s, name, namelen);\r
+               Ret = connect(s, name, namelen);\r
                if(Ret == SOCKET_ERROR)\r
                {\r
                        do\r
@@ -878,12 +873,7 @@ SOCKET do_accept(SOCKET s, struct sockaddr *addr, int *addrlen)
        {\r
                do\r
                {\r
-                       // FTPS対応\r
-//                     Ret2 = accept(s, addr, addrlen);\r
-                       if(AskCryptMode() == CRYPT_FTPIS)\r
-                               Ret2 = acceptS(s, addr, addrlen);\r
-                       else\r
-                               Ret2 = accept(s, addr, addrlen);\r
+                       Ret2 = accept(s, addr, addrlen);\r
                        if(Ret2 != INVALID_SOCKET)\r
                        {\r
 #if DBG_MSG\r
index a43f5bf..612218e 100644 (file)
@@ -340,6 +340,8 @@ BOOL AttachSSL(SOCKET s, SOCKET parent)
        SSL** ppSSL;\r
        SSL** ppSSLParent;\r
        SSL_SESSION* pSession;\r
+       int Return;\r
+       int Error;\r
        if(!g_bOpenSSLLoaded)\r
                return FALSE;\r
        r = FALSE;\r
@@ -369,17 +371,21 @@ BOOL AttachSSL(SOCKET s, SOCKET parent)
                                        }\r
                                        // SSLのネゴシエーションには時間がかかる場合がある\r
                                        r = TRUE;\r
-                                       while(p_SSL_connect(*ppSSL) != 1)\r
+                                       while(r)\r
                                        {\r
-                                               LeaveCriticalSection(&g_OpenSSLLock);\r
-                                               if(g_pOpenSSLTimeoutCallback() || (g_OpenSSLTimeout > 0 && timeGetTime() - Time >= g_OpenSSLTimeout))\r
+                                               Return = p_SSL_connect(*ppSSL);\r
+                                               if(Return == 1)\r
+                                                       break;\r
+                                               Error = p_SSL_get_error(*ppSSL, Return);\r
+                                               if(Error == SSL_ERROR_WANT_READ || Error == SSL_ERROR_WANT_WRITE)\r
                                                {\r
-                                                       DetachSSL(s);\r
-                                                       r = FALSE;\r
+                                                       LeaveCriticalSection(&g_OpenSSLLock);\r
+                                                       if(g_pOpenSSLTimeoutCallback() || (g_OpenSSLTimeout > 0 && timeGetTime() - Time >= g_OpenSSLTimeout))\r
+                                                               r = FALSE;\r
                                                        EnterCriticalSection(&g_OpenSSLLock);\r
-                                                       break;\r
                                                }\r
-                                               EnterCriticalSection(&g_OpenSSLLock);\r
+                                               else\r
+                                                       r = FALSE;\r
                                        }\r
                                        if(r)\r
                                        {\r
@@ -394,6 +400,12 @@ BOOL AttachSSL(SOCKET s, SOCKET parent)
                                                        EnterCriticalSection(&g_OpenSSLLock);\r
                                                }\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               LeaveCriticalSection(&g_OpenSSLLock);\r
+                                               DetachSSL(s);\r
+                                               EnterCriticalSection(&g_OpenSSLLock);\r
+                                       }\r
                                }\r
                                else\r
                                {\r