OSDN Git Service

Fix bugs of corruption on resuming downloading files larger than 4GB.
[ffftp/ffftp.git] / connect.c
index 7e1e819..904fd0d 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -927,24 +927,15 @@ static void SaveCurrentSetToHistory(void)
 int ReConnectCmdSkt(void)\r
 {\r
        int Sts;\r
-       SOCKET s;\r
 \r
 \r
        // 同時接続対応\r
 //     if(CmdCtrlSocket != TrnCtrlSocket)\r
-//             do_closesocket(TrnCtrlSocket);\r
-//     TrnCtrlSocket = INVALID_SOCKET;\r
-       s = TrnCtrlSocket;\r
+       if(CmdCtrlSocket != TrnCtrlSocket && TrnCtrlSocket != INVALID_SOCKET)\r
+               do_closesocket(TrnCtrlSocket);\r
        TrnCtrlSocket = INVALID_SOCKET;\r
-       if(CmdCtrlSocket != s && s != INVALID_SOCKET)\r
-               do_closesocket(s);\r
 \r
-       // 同時接続対応\r
-//     Sts = ReConnectSkt(&CmdCtrlSocket);\r
-       s = CmdCtrlSocket;\r
-       CmdCtrlSocket = INVALID_SOCKET;\r
-       Sts = ReConnectSkt(&s);\r
-       CmdCtrlSocket = s;\r
+       Sts = ReConnectSkt(&CmdCtrlSocket);\r
 \r
        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
@@ -1271,7 +1262,8 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                        Fwall = FWALL_NONE;\r
 \r
                TryConnect = YES;\r
-               CancelFlg = NO;\r
+               // 暗号化通信対応\r
+//             CancelFlg = NO;\r
 #if 0\r
 //             WSASetBlockingHook(BlkHookFnc);\r
 #endif\r
@@ -1303,20 +1295,10 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
 //                                     ;\r
                                if(CryptMode == CRYPT_FTPIS)\r
                                {\r
-                                       if(AttachSSL(ContSock))\r
+                                       if(AttachSSL(ContSock, INVALID_SOCKET))\r
                                        {\r
                                                while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)\r
                                                        ;\r
-                                               if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)\r
-                                               {\r
-                                                       if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)\r
-                                                       {\r
-                                                       }\r
-                                                       else\r
-                                                               Sts = FTP_ERROR;\r
-                                               }\r
-                                               else\r
-                                                       Sts = FTP_ERROR;\r
                                        }\r
                                        else\r
                                                Sts = FTP_ERROR;\r
@@ -1418,7 +1400,7 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                {\r
                                                                        if(IsOpenSSLLoaded() && (Sts = command(ContSock, Reply, &CancelFlg, "AUTH TLS")) == 234)\r
                                                                        {\r
-                                                                               if(AttachSSL(ContSock))\r
+                                                                               if(AttachSSL(ContSock, INVALID_SOCKET))\r
                                                                                {\r
                                                                                        if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)\r
                                                                                        {\r
@@ -1567,25 +1549,26 @@ static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass,
 {\r
        SOCKET ContSock;\r
        ContSock = INVALID_SOCKET;\r
-       if(ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)\r
+       CancelFlg = NO;\r
+       if(CancelFlg == NO && ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)\r
        {\r
                SetTaskMsg(MSGJPN317);\r
                if((ContSock = DoConnectCrypt(CRYPT_SFTP, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
                        HostData->CryptMode = CRYPT_SFTP;\r
        }\r
-//     if(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(ContSock == INVALID_SOCKET && HostData->UseFTPES == YES)\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
                if((ContSock = DoConnectCrypt(CRYPT_FTPES, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
                        HostData->CryptMode = CRYPT_FTPES;\r
        }\r
-       if(ContSock == INVALID_SOCKET && HostData->UseNoEncryption == YES)\r
+       if(CancelFlg == NO && ContSock == INVALID_SOCKET && HostData->UseNoEncryption == YES)\r
        {\r
                SetTaskMsg(MSGJPN314);\r
                if((ContSock = DoConnectCrypt(CRYPT_NONE, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
@@ -2352,6 +2335,11 @@ int AskUseSFTP(void)
        return(CurHost.UseSFTP);\r
 }\r
 \r
+char *AskPrivateKey(void)\r
+{\r
+       return(CurHost.PrivateKey);\r
+}\r
+\r
 // 同時接続対応\r
 int AskMaxThreadCount(void)\r
 {\r