OSDN Git Service

Prepare for release of 1.98f.
[ffftp/ffftp.git] / connect.c
index 98f7121..122f441 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -1517,11 +1517,14 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                        if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
                                                ReportWSError("setsockopt", WSAGetLastError());\r
                                        // 切断対策\r
-                                       KeepAlive.onoff = 1;\r
-                                       KeepAlive.keepalivetime = TimeOut * 1000;\r
-                                       KeepAlive.keepaliveinterval = 1000;\r
-                                       if(WSAIoctl(ContSock, SIO_KEEPALIVE_VALS, &KeepAlive, sizeof(struct tcp_keepalive), NULL, 0, &dwTmp, NULL, NULL) == SOCKET_ERROR)\r
-                                               ReportWSError("WSAIoctl", WSAGetLastError());\r
+                                       if(TimeOut > 0)\r
+                                       {\r
+                                               KeepAlive.onoff = 1;\r
+                                               KeepAlive.keepalivetime = TimeOut * 1000;\r
+                                               KeepAlive.keepaliveinterval = 1000;\r
+                                               if(WSAIoctl(ContSock, SIO_KEEPALIVE_VALS, &KeepAlive, sizeof(struct tcp_keepalive), NULL, 0, &dwTmp, NULL, NULL) == SOCKET_ERROR)\r
+                                                       ReportWSError("WSAIoctl", WSAGetLastError());\r
+                                       }\r
                                        LingerOpt.l_onoff = 1;\r
                                        LingerOpt.l_linger = 90;\r
                                        if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR)\r
@@ -1788,64 +1791,6 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                        }\r
                }\r
        }\r
-       else if(CryptMode == CRYPT_SFTP)\r
-       {\r
-               // TODO:\r
-               // テストコード\r
-               // ログイン成功を確認\r
-#define strrcmp(_Str1, _Str2) (strcmp(strstr(_Str1, _Str2) ? strstr(_Str1, _Str2) : "", _Str2))\r
-               size_t r;\r
-               ContSock = SFTP_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);\r
-               SFTP_SetTimeoutCallback(ContSock, SSLTimeoutCallback);\r
-               while(1)\r
-               {\r
-                       r = SFTP_recv(ContSock, Reply, 1024, 0);\r
-                       if(r == SOCKET_ERROR)\r
-                               break;\r
-                       if(r <= 0)\r
-                               continue;\r
-                       Reply[r] = '\0';\r
-                       SetTaskMsg("%s", Reply);\r
-                       if(strrcmp(Reply, "psftp> ") == 0)\r
-                               break;\r
-               }\r
-               r = SFTP_send(ContSock, "open \"", strlen("open \""), 0);\r
-               r = SFTP_send(ContSock, Host, strlen(Host), 0);\r
-               r = SFTP_send(ContSock, "\"\r\n", strlen("\"\r\n"), 0);\r
-               while(1)\r
-               {\r
-                       r = SFTP_recv(ContSock, Reply, 1024, 0);\r
-                       if(r == SOCKET_ERROR)\r
-                               break;\r
-                       if(r <= 0)\r
-                               continue;\r
-                       Reply[r] = '\0';\r
-                       SetTaskMsg("%s", Reply);\r
-                       if(strrcmp(Reply, "Store key in cache? (y/n) ") == 0)\r
-                       {\r
-                               r = SFTP_send(ContSock, "n\r\n", strlen("n\r\n"), 0);\r
-                       }\r
-                       if(strrcmp(Reply, "Update cached key? (y/n, Return cancels connection) ") == 0)\r
-                       {\r
-                               r = SFTP_send(ContSock, "\r\n", strlen("\r\n"), 0);\r
-                       }\r
-                       if(strrcmp(Reply, "login as: ") == 0)\r
-                       {\r
-                               r = SFTP_send(ContSock, User, strlen(User), 0);\r
-                               r = SFTP_send(ContSock, "\r\n", strlen("\r\n"), 0);\r
-                       }\r
-                       if(strrcmp(Reply, "password: ") == 0)\r
-                       {\r
-                               r = SFTP_send(ContSock, Pass, strlen(Pass), 0);\r
-                               r = SFTP_send(ContSock, "\r\n", strlen("\r\n"), 0);\r
-                       }\r
-                       if(strrcmp(Reply, "psftp> ") == 0)\r
-                               break;\r
-                       Sleep(1);\r
-               }\r
-               SFTP_closesocket(ContSock);\r
-               ContSock = INVALID_SOCKET;\r
-       }\r
 \r
        return(ContSock);\r
 }\r
@@ -1857,12 +1802,6 @@ static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass,
        SOCKET ContSock;\r
        ContSock = INVALID_SOCKET;\r
        *CancelCheckWork = NO;\r
-       if(*CancelCheckWork == 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, CancelCheckWork)) != INVALID_SOCKET)\r
-                       HostData->CryptMode = CRYPT_SFTP;\r
-       }\r
        if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseFTPIS == YES)\r
        {\r
                SetTaskMsg(MSGJPN316);\r