OSDN Git Service

Fix bugs of displaying icons in the local file list.
[ffftp/ffftp.git] / connect.c
index af55002..3e17909 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -35,7 +35,9 @@
 #include <string.h>\r
 #include <mbstring.h>\r
 #include <time.h>\r
 #include <string.h>\r
 #include <mbstring.h>\r
 #include <time.h>\r
-#include <winsock.h>\r
+// IPv6対応\r
+//#include <winsock.h>\r
+#include <winsock2.h>\r
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 \r
 #include <windowsx.h>\r
 #include <commctrl.h>\r
 \r
 \r
 /*===== プロトタイプ =====*/\r
 \r
 \r
 /*===== プロトタイプ =====*/\r
 \r
-static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
-static int SendInitCommand(char *Cmd);\r
+// 64ビット対応\r
+//static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+static INT_PTR CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
+// 同時接続対応\r
+//static int SendInitCommand(char *Cmd);\r
+static int SendInitCommand(SOCKET Socket, char *Cmd, int *CancelCheckWork);\r
 static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List);\r
 static void SaveCurrentSetToHistory(void);\r
 static int ReConnectSkt(SOCKET *Skt);\r
 // 暗号化通信対応\r
 static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List);\r
 static void SaveCurrentSetToHistory(void);\r
 static int ReConnectSkt(SOCKET *Skt);\r
 // 暗号化通信対応\r
+// 同時接続対応\r
 //static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);\r
 //static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);\r
-static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);\r
-static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);\r
+static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork);\r
+static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork);\r
 static int CheckOneTimePassword(char *Pass, char *Reply, int Type);\r
 static BOOL CALLBACK BlkHookFnc(void);\r
 static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulong IP, char *Host, ushort Port);\r
 static int CheckOneTimePassword(char *Pass, char *Reply, int Type);\r
 static BOOL CALLBACK BlkHookFnc(void);\r
 static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulong IP, char *Host, ushort Port);\r
+// IPv6対応\r
+static int Socks5MakeCmdPacketIPv6(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, char *IP, char *Host, ushort Port);\r
 static int SocksSendCmd(SOCKET Socket, void *Data, int Size, int *CancelCheckWork);\r
 static int SocksSendCmd(SOCKET Socket, void *Data, int Size, int *CancelCheckWork);\r
-static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet);\r
-static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet);\r
+// 同時接続対応\r
+//static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet);\r
+static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet, int *CancelCheckWork);\r
+// 同時接続対応\r
+//static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet);\r
+static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet, int *CancelCheckWork);\r
 static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork);\r
 \r
 /*===== 外部参照 =====*/\r
 static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork);\r
 \r
 /*===== 外部参照 =====*/\r
@@ -100,12 +113,21 @@ static HOSTDATA CurHost;
 \r
 /* 接続中の接続先、SOCKSサーバのアドレス情報を保存しておく */\r
 /* この情報はlistenソケットを取得する際に用いる */\r
 \r
 /* 接続中の接続先、SOCKSサーバのアドレス情報を保存しておく */\r
 /* この情報はlistenソケットを取得する際に用いる */\r
-static struct sockaddr_in SocksSockAddr;       /* SOCKSサーバのアドレス情報 */\r
-static struct sockaddr_in CurSockAddr;         /* 接続先ホストのアドレス情報 */\r
+// IPv6対応\r
+//static struct sockaddr_in SocksSockAddr;     /* SOCKSサーバのアドレス情報 */\r
+//static struct sockaddr_in CurSockAddr;               /* 接続先ホストのアドレス情報 */\r
+static struct sockaddr_in SocksSockAddrIPv4;   /* SOCKSサーバのアドレス情報 */\r
+static struct sockaddr_in CurSockAddrIPv4;             /* 接続先ホストのアドレス情報 */\r
+static struct sockaddr_in6 SocksSockAddrIPv6;  /* SOCKSサーバのアドレス情報 */\r
+static struct sockaddr_in6 CurSockAddrIPv6;            /* 接続先ホストのアドレス情報 */\r
+static const struct in6_addr IN6ADDR_NONE = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};\r
 \r
 static int UseIPadrs;\r
 static char DomainName[HOST_ADRS_LEN+1];\r
 \r
 \r
 static int UseIPadrs;\r
 static char DomainName[HOST_ADRS_LEN+1];\r
 \r
+#if defined(HAVE_TANDEM)\r
+static int Oss = NO;  /* OSS ファイルシステムへアクセスしている場合は YES */\r
+#endif\r
 \r
 \r
 \r
 \r
 \r
 \r
@@ -143,6 +165,10 @@ void ConnectProc(int Type, int Num)
 \r
                InitPWDcommand();\r
                CopyHostFromList(AskCurrentHost(), &CurHost);\r
 \r
                InitPWDcommand();\r
                CopyHostFromList(AskCurrentHost(), &CurHost);\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
 \r
                if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
@@ -163,17 +189,58 @@ void ConnectProc(int Type, int Num)
 \r
                        DisableUserOpe();\r
                        // 暗号化通信対応\r
 \r
                        DisableUserOpe();\r
                        // 暗号化通信対応\r
+                       // 同時接続対応\r
 //                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);\r
 //                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);\r
-                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);\r
+                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
+                               // 暗号化通信対応\r
+                               switch(CurHost.CryptMode)\r
+                               {\r
+                               case CRYPT_NONE:\r
+                                       if(CurHost.UseFTPIS != NO || CurHost.UseSFTP != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), CurHost.UseNoEncryption, CurHost.UseFTPES, NO, NO);\r
+                                       }\r
+                                       break;\r
+                               case CRYPT_FTPES:\r
+                                       if(CurHost.UseNoEncryption != NO || CurHost.UseFTPIS != NO || CurHost.UseSFTP != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), NO, CurHost.UseFTPES, NO, NO);\r
+                                       }\r
+                                       break;\r
+                               case CRYPT_FTPIS:\r
+                                       if(CurHost.UseNoEncryption != NO || CurHost.UseFTPES != NO || CurHost.UseSFTP != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), NO, NO, CurHost.UseFTPIS, NO);\r
+                                       }\r
+                                       break;\r
+                               case CRYPT_SFTP:\r
+                                       if(CurHost.UseNoEncryption != NO || CurHost.UseFTPES != NO || CurHost.UseFTPIS != NO)\r
+                                       {\r
+                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savecrypt_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                       SetHostExcryption(AskCurrentHost(), NO, NO, NO, CurHost.UseSFTP);\r
+                                       }\r
+                                       break;\r
+                               }\r
+\r
+                               // UTF-8対応\r
+                               if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
+                               {\r
+                                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                               CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                               }\r
+\r
                                strcpy(TitleHostName, CurHost.HostName);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
 \r
                                strcpy(TitleHostName, CurHost.HostName);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
 \r
-                               SendInitCommand(CurHost.InitCmd);\r
+                               SendInitCommand(CmdCtrlSocket, CurHost.InitCmd, &CancelFlg);\r
 \r
                                if(strlen(CurHost.LocalInitDir) > 0)\r
                                {\r
 \r
                                if(strlen(CurHost.LocalInitDir) > 0)\r
                                {\r
@@ -225,6 +292,10 @@ void QuickConnectProc(void)
 \r
                InitPWDcommand();\r
                CopyDefaultHost(&CurHost);\r
 \r
                InitPWDcommand();\r
                CopyDefaultHost(&CurHost);\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
                if(SplitUNCpath(Tmp, CurHost.HostAdrs, CurHost.RemoteInitDir, File, CurHost.UserName, CurHost.PassWord, &CurHost.Port) == FFFTP_SUCCESS)\r
                {\r
                        if(strlen(CurHost.UserName) == 0)\r
                if(SplitUNCpath(Tmp, CurHost.HostAdrs, CurHost.RemoteInitDir, File, CurHost.UserName, CurHost.PassWord, &CurHost.Port) == FFFTP_SUCCESS)\r
                {\r
                        if(strlen(CurHost.UserName) == 0)\r
@@ -244,12 +315,20 @@ void QuickConnectProc(void)
 \r
                        DisableUserOpe();\r
                        // 暗号化通信対応\r
 \r
                        DisableUserOpe();\r
                        // 暗号化通信対応\r
+                       // 同時接続対応\r
 //                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
 //                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
-                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
+                               // UTF-8対応\r
+                               if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
+                               {\r
+                                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                               CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                               }\r
+\r
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
@@ -286,7 +365,9 @@ void QuickConnectProc(void)
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
 *              BOOL TRUE/FALSE\r
 *----------------------------------------------------------------------------*/\r
 \r
-static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+// 64ビット対応\r
+//static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
 {\r
        static char *Buf;\r
        int i;\r
 {\r
        static char *Buf;\r
        int i;\r
@@ -405,6 +486,10 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
                CurHost.KanaCnv = Kana;\r
                CurHost.NameKanjiCode = Fkanji;\r
                CurHost.KanaCnv = YES;                  /* とりあえず */\r
                CurHost.KanaCnv = Kana;\r
                CurHost.NameKanjiCode = Fkanji;\r
                CurHost.KanaCnv = YES;                  /* とりあえず */\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                SetHostKanaCnvImm(CurHost.KanaCnv);\r
                SetHostKanjiCodeImm(CurHost.KanjiCode);\r
 \r
                SetHostKanaCnvImm(CurHost.KanaCnv);\r
                SetHostKanjiCodeImm(CurHost.KanjiCode);\r
@@ -418,12 +503,20 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
 \r
                DisableUserOpe();\r
                // 暗号化通信対応\r
 \r
                DisableUserOpe();\r
                // 暗号化通信対応\r
+               // 同時接続対応\r
 //             CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
 //             CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
-               CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+               CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                if(CmdCtrlSocket != INVALID_SOCKET)\r
                {\r
                TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                if(CmdCtrlSocket != INVALID_SOCKET)\r
                {\r
+                       // UTF-8対応\r
+                       if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
+                       {\r
+                               if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                       CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                       }\r
+\r
                        strcpy(TitleHostName, CurHost.HostAdrs);\r
                        DispWindowTitle();\r
                        SoundPlay(SND_CONNECT);\r
                        strcpy(TitleHostName, CurHost.HostAdrs);\r
                        DispWindowTitle();\r
                        SoundPlay(SND_CONNECT);\r
@@ -479,6 +572,10 @@ void HistoryConnectProc(int MenuCmd)
 \r
                InitPWDcommand();\r
                CopyHistoryToHost(&Hist, &CurHost);\r
 \r
                InitPWDcommand();\r
                CopyHistoryToHost(&Hist, &CurHost);\r
+               // UTF-8対応\r
+               CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;\r
+               // IPv6対応\r
+               CurHost.CurNetType = CurHost.NetType;\r
 \r
                if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
 \r
                if(ConnectRas(CurHost.Dialup, CurHost.DialupAlways, CurHost.DialupNotify, CurHost.DialEntry) == FFFTP_SUCCESS)\r
                {\r
@@ -496,17 +593,25 @@ void HistoryConnectProc(int MenuCmd)
 \r
                        DisableUserOpe();\r
                        // 暗号化通信対応\r
 \r
                        DisableUserOpe();\r
                        // 暗号化通信対応\r
+                       // 同時接続対応\r
 //                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
 //                     CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
-                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);\r
+                       CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
                        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
                        if(CmdCtrlSocket != INVALID_SOCKET)\r
                        {\r
+                               // UTF-8対応\r
+                               if(CurHost.CurNameKanjiCode == KANJI_AUTO)\r
+                               {\r
+                                       if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
+                                               CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+                               }\r
+\r
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
 \r
                                strcpy(TitleHostName, CurHost.HostAdrs);\r
                                DispWindowTitle();\r
                                SoundPlay(SND_CONNECT);\r
 \r
-                               SendInitCommand(CurHost.InitCmd);\r
+                               SendInitCommand(CmdCtrlSocket, CurHost.InitCmd, &CancelFlg);\r
 \r
                                DoLocalCWD(CurHost.LocalInitDir);\r
                                GetLocalDirForWnd();\r
 \r
                                DoLocalCWD(CurHost.LocalInitDir);\r
                                GetLocalDirForWnd();\r
@@ -545,7 +650,9 @@ void HistoryConnectProc(int MenuCmd)
 *                      cmd1\r\ncmd2\r\n\0\r
 *----------------------------------------------------------------------------*/\r
 \r
 *                      cmd1\r\ncmd2\r\n\0\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int SendInitCommand(char *Cmd)\r
+// 同時接続対応\r
+//static int SendInitCommand(char *Cmd)\r
+static int SendInitCommand(SOCKET Socket, char *Cmd, int *CancelCheckWork)\r
 {\r
        char Tmp[INITCMD_LEN+1];\r
        char *Pos;\r
 {\r
        char Tmp[INITCMD_LEN+1];\r
        char *Pos;\r
@@ -556,7 +663,8 @@ static int SendInitCommand(char *Cmd)
                if((Pos = strchr(Tmp, '\r')) != NULL)\r
                        *Pos = NUL;\r
                if(strlen(Tmp) > 0)\r
                if((Pos = strchr(Tmp, '\r')) != NULL)\r
                        *Pos = NUL;\r
                if(strlen(Tmp) > 0)\r
-                       DoQUOTE(Tmp);\r
+//                     DoQUOTE(Tmp);\r
+                       DoQUOTE(Socket, Tmp, CancelCheckWork);\r
 \r
                if((Cmd = strchr(Cmd, '\n')) != NULL)\r
                        Cmd++;\r
 \r
                if((Cmd = strchr(Cmd, '\n')) != NULL)\r
                        Cmd++;\r
@@ -586,7 +694,8 @@ static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List)
 \r
        *Fire = FwallDefault;\r
        *Pasv = PasvDefault;\r
 \r
        *Fire = FwallDefault;\r
        *Pasv = PasvDefault;\r
-       *List = NO;\r
+       // NLSTを送ってしまうバグ修正(ただしNLSTを使うべきホストへクイック接続できなくなる)\r
+//     *List = NO;\r
 \r
        i = 0;\r
        while(CopyHostFromList(i, &Tmp) == FFFTP_SUCCESS)\r
 \r
        i = 0;\r
        while(CopyHostFromList(i, &Tmp) == FFFTP_SUCCESS)\r
@@ -644,10 +753,12 @@ int AskHostPort(void)
 \r
 int AskHostNameKanji(void)\r
 {\r
 \r
 int AskHostNameKanji(void)\r
 {\r
-       if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
-               CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
-\r
-       return(CurHost.NameKanjiCode);\r
+       // UTF-8対応\r
+//     if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
+//             CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+//\r
+//     return(CurHost.NameKanjiCode);\r
+       return(CurHost.CurNameKanjiCode);\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -792,6 +903,14 @@ int AskHostType(void)
        if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
                CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
 \r
        if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
                CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
 \r
+#if defined(HAVE_TANDEM)\r
+       /* OSS ファイルシステムは UNIX ファイルシステムと同じでいいので AUTO を返す\r
+          ただし、Guardian ファイルシステムに戻ったときにおかしくならないように\r
+          CurHost.HostType 変数は更新しない */\r
+       if(CurHost.HostType == HTYPE_TANDEM && Oss == YES)\r
+               return(HTYPE_AUTO);\r
+#endif\r
+\r
        return(CurHost.HostType);\r
 }\r
 \r
        return(CurHost.HostType);\r
 }\r
 \r
@@ -926,24 +1045,13 @@ static void SaveCurrentSetToHistory(void)
 int ReConnectCmdSkt(void)\r
 {\r
        int Sts;\r
 int ReConnectCmdSkt(void)\r
 {\r
        int Sts;\r
-       SOCKET s;\r
 \r
 \r
 \r
 \r
-       // 同時接続対応\r
-//     if(CmdCtrlSocket != TrnCtrlSocket)\r
-//             do_closesocket(TrnCtrlSocket);\r
-//     TrnCtrlSocket = INVALID_SOCKET;\r
-       s = TrnCtrlSocket;\r
+       if(CmdCtrlSocket != TrnCtrlSocket)\r
+               do_closesocket(TrnCtrlSocket);\r
        TrnCtrlSocket = INVALID_SOCKET;\r
        TrnCtrlSocket = INVALID_SOCKET;\r
-       if(CmdCtrlSocket != s && s != INVALID_SOCKET)\r
-               do_closesocket(s);\r
 \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
 \r
        TrnCtrlSocket = CmdCtrlSocket;\r
 \r
@@ -966,7 +1074,7 @@ int ReConnectCmdSkt(void)
 //     return(ReConnectSkt(&TrnCtrlSocket));\r
 //}\r
 // 同時接続対応\r
 //     return(ReConnectSkt(&TrnCtrlSocket));\r
 //}\r
 // 同時接続対応\r
-int ReConnectTrnSkt(SOCKET *Skt)\r
+int ReConnectTrnSkt(SOCKET *Skt, int *CancelCheckWork)\r
 {\r
 //     char Path[FMAX_PATH+1];\r
        int Sts;\r
 {\r
 //     char Path[FMAX_PATH+1];\r
        int Sts;\r
@@ -992,9 +1100,18 @@ int ReConnectTrnSkt(SOCKET *Skt)
                HostData.UseFTPIS = NO;\r
        if(HostData.CryptMode != CRYPT_SFTP)\r
                HostData.UseSFTP = NO;\r
                HostData.UseFTPIS = NO;\r
        if(HostData.CryptMode != CRYPT_SFTP)\r
                HostData.UseSFTP = NO;\r
+       // UTF-8対応\r
+       HostData.CurNameKanjiCode = HostData.NameKanjiCode;\r
+       // IPv6対応\r
+       HostData.CurNetType = HostData.NetType;\r
+       // 同時接続対応\r
+       HostData.NoDisplayUI = YES;\r
+       // 暗号化通信対応\r
+       // 同時接続対応\r
 //     if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
 //     if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
-       if((*Skt = DoConnect(&HostData, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
+       if((*Skt = DoConnect(&HostData, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, CancelCheckWork)) != INVALID_SOCKET)\r
        {\r
        {\r
+               SendInitCommand(*Skt, CurHost.InitCmd, CancelCheckWork);\r
 //             AskRemoteCurDir(Path, FMAX_PATH);\r
 //             DoCWD(Path, YES, YES, YES);\r
                Sts = FFFTP_SUCCESS;\r
 //             AskRemoteCurDir(Path, FMAX_PATH);\r
 //             DoCWD(Path, YES, YES, YES);\r
                Sts = FFFTP_SUCCESS;\r
@@ -1032,9 +1149,11 @@ static int ReConnectSkt(SOCKET *Skt)
                do_closesocket(*Skt);\r
        /* 再接続 */\r
        // 暗号化通信対応\r
                do_closesocket(*Skt);\r
        /* 再接続 */\r
        // 暗号化通信対応\r
+       // 同時接続対応\r
 //     if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
 //     if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
-       if((*Skt = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)\r
+       if((*Skt = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg)) != INVALID_SOCKET)\r
        {\r
        {\r
+               SendInitCommand(*Skt, CurHost.InitCmd, &CancelFlg);\r
                AskRemoteCurDir(Path, FMAX_PATH);\r
                DoCWD(Path, YES, YES, YES);\r
                Sts = FFFTP_SUCCESS;\r
                AskRemoteCurDir(Path, FMAX_PATH);\r
                DoCWD(Path, YES, YES, YES);\r
                Sts = FFFTP_SUCCESS;\r
@@ -1094,10 +1213,13 @@ void SktShareProh(void)
 //SetTaskMsg("############### SktShareProh");\r
 \r
                // 同時接続対応\r
 //SetTaskMsg("############### SktShareProh");\r
 \r
                // 同時接続対応\r
-               // 転送スレッドがソケットを各自で用意\r
-               // TrnCtrlSocketはメインスレッド以外から使用されない\r
 //             CmdCtrlSocket = INVALID_SOCKET;\r
 //             ReConnectSkt(&CmdCtrlSocket);\r
 //             CmdCtrlSocket = INVALID_SOCKET;\r
 //             ReConnectSkt(&CmdCtrlSocket);\r
+               if(CurHost.ReuseCmdSkt == YES)\r
+               {\r
+                       CmdCtrlSocket = INVALID_SOCKET;\r
+                       ReConnectSkt(&CmdCtrlSocket);\r
+               }\r
        }\r
        return;\r
 }\r
        }\r
        return;\r
 }\r
@@ -1118,8 +1240,10 @@ int AskShareProh(void)
        int Sts;\r
 \r
        Sts = YES;\r
        int Sts;\r
 \r
        Sts = YES;\r
+       // 同時接続対応\r
 //     if(CmdCtrlSocket == TrnCtrlSocket)\r
 //     if(CmdCtrlSocket == TrnCtrlSocket)\r
-//             Sts = NO;\r
+       if(CmdCtrlSocket == TrnCtrlSocket || TrnCtrlSocket == INVALID_SOCKET)\r
+               Sts = NO;\r
 \r
        return(Sts);\r
 }\r
 \r
        return(Sts);\r
 }\r
@@ -1210,6 +1334,62 @@ int AskConnecting(void)
 }\r
 \r
 \r
 }\r
 \r
 \r
+#if defined(HAVE_TANDEM)\r
+/*----- 接続している本当のホストのホストタイプを返す --------------------------\r
+*\r
+*      Parameter\r
+*              なし\r
+*\r
+*      Return Value\r
+*              char *ファイル名/オプション\r
+*----------------------------------------------------------------------------*/\r
+\r
+int AskRealHostType(void)\r
+{\r
+       if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
+               CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+\r
+       return(CurHost.HostType);\r
+}\r
+\r
+/*----- OSS ファイルシステムにアクセスしているかどうかのフラグを変更する ------\r
+*\r
+*      Parameter\r
+*              int ステータス (YES/NO)\r
+*\r
+*      Return Value\r
+*              int ステータス (YES/NO)\r
+*----------------------------------------------------------------------------*/\r
+\r
+int SetOSS(int wkOss)\r
+{\r
+       if(Oss != wkOss) {\r
+               if (wkOss == YES) {\r
+                       strcpy(CurHost.InitCmd, "OSS");\r
+               } else {\r
+                       strcpy(CurHost.InitCmd, "GUARDIAN");\r
+               }\r
+       }\r
+       Oss = wkOss;\r
+       return(Oss);\r
+}\r
+\r
+/*----- OSS ファイルシステムにアクセスしているかどうかを返す ------------------\r
+*\r
+*      Parameter\r
+*              なし\r
+*\r
+*      Return Value\r
+*              int ステータス (YES/NO)\r
+*----------------------------------------------------------------------------*/\r
+\r
+int AskOSS(void)\r
+{\r
+       return(Oss);\r
+}\r
+#endif /* HAVE_TANDEM */\r
+\r
+\r
 /*----- ホストへ接続する ------------------------------------------------------\r
 *\r
 *      Parameter\r
 /*----- ホストへ接続する ------------------------------------------------------\r
 *\r
 *      Parameter\r
@@ -1243,7 +1423,7 @@ int AskConnecting(void)
 *----------------------------------------------------------------------------*/\r
 \r
 // 暗号化通信対応\r
 *----------------------------------------------------------------------------*/\r
 \r
 // 暗号化通信対応\r
-static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)\r
+static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork)\r
 {\r
        int Sts;\r
        int Flg;\r
 {\r
        int Sts;\r
        int Flg;\r
@@ -1270,7 +1450,8 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                        Fwall = FWALL_NONE;\r
 \r
                TryConnect = YES;\r
                        Fwall = FWALL_NONE;\r
 \r
                TryConnect = YES;\r
-               CancelFlg = NO;\r
+               // 暗号化通信対応\r
+//             CancelFlg = NO;\r
 #if 0\r
 //             WSASetBlockingHook(BlkHookFnc);\r
 #endif\r
 #if 0\r
 //             WSASetBlockingHook(BlkHookFnc);\r
 #endif\r
@@ -1289,7 +1470,9 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
 \r
                if(strlen(Tmp) != 0)\r
                {\r
 \r
                if(strlen(Tmp) != 0)\r
                {\r
-                       if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)\r
+                       // 同時接続対応\r
+//                     if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)\r
+                       if((ContSock = connectsock(Tmp, Port, "", CancelCheckWork)) != INVALID_SOCKET)\r
                        {\r
                                // バッファを無効\r
 #ifdef DISABLE_CONTROL_NETWORK_BUFFERS\r
                        {\r
                                // バッファを無効\r
 #ifdef DISABLE_CONTROL_NETWORK_BUFFERS\r
@@ -1302,27 +1485,17 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
 //                                     ;\r
                                if(CryptMode == CRYPT_FTPIS)\r
                                {\r
 //                                     ;\r
                                if(CryptMode == CRYPT_FTPIS)\r
                                {\r
-                                       if(AttachSSL(ContSock))\r
+                                       if(AttachSSL(ContSock, INVALID_SOCKET, CancelCheckWork))\r
                                        {\r
                                        {\r
-                                               while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)\r
+                                               while((Sts = ReadReplyMessage(ContSock, Buf, 1024, CancelCheckWork, TmpBuf) / 100) == FTP_PRELIM)\r
                                                        ;\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
                                }\r
                                else\r
                                {\r
                                        }\r
                                        else\r
                                                Sts = FTP_ERROR;\r
                                }\r
                                else\r
                                {\r
-                                       while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)\r
+                                       while((Sts = ReadReplyMessage(ContSock, Buf, 1024, CancelCheckWork, TmpBuf) / 100) == FTP_PRELIM)\r
                                                ;\r
                                }\r
 \r
                                                ;\r
                                }\r
 \r
@@ -1352,15 +1525,21 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                           (Fwall == FWALL_FU_FP_USER) ||\r
                                           (Fwall == FWALL_FU_FP))\r
                                        {\r
                                           (Fwall == FWALL_FU_FP_USER) ||\r
                                           (Fwall == FWALL_FU_FP))\r
                                        {\r
-                                               if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", FwallUser) / 100) == FTP_CONTINUE)\r
+                                               // 同時接続対応\r
+//                                             if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", FwallUser) / 100) == FTP_CONTINUE)\r
+                                               if((Sts = command(ContSock, Reply, CancelCheckWork, "USER %s", FwallUser) / 100) == FTP_CONTINUE)\r
                                                {\r
                                                        CheckOneTimePassword(FwallPass, Reply, FwallSecurity);\r
                                                {\r
                                                        CheckOneTimePassword(FwallPass, Reply, FwallSecurity);\r
-                                                       Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                                       // 同時接続対応\r
+//                                                     Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                                       Sts = command(ContSock, NULL, CancelCheckWork, "PASS %s", Reply) / 100;\r
                                                }\r
                                        }\r
                                        else if(Fwall == FWALL_SIDEWINDER)\r
                                        {\r
                                                }\r
                                        }\r
                                        else if(Fwall == FWALL_SIDEWINDER)\r
                                        {\r
-                                               Sts = command(ContSock, Reply, &CancelFlg, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;\r
+                                               // 同時接続対応\r
+//                                             Sts = command(ContSock, Reply, &CancelFlg, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;\r
+                                               Sts = command(ContSock, Reply, CancelCheckWork, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;\r
                                        }\r
                                        if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
                                        {\r
                                        }\r
                                        if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
                                        {\r
@@ -1379,9 +1558,13 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                Flg++;\r
 \r
                                                        if(HostPort == PORT_NOR)\r
                                                                Flg++;\r
 \r
                                                        if(HostPort == PORT_NOR)\r
-                                                               Sts = command(ContSock, NULL, &CancelFlg, "%s %s", SiteTbl[Flg], Host) / 100;\r
+                                                               // 同時接続対応\r
+//                                                             Sts = command(ContSock, NULL, &CancelFlg, "%s %s", SiteTbl[Flg], Host) / 100;\r
+                                                               Sts = command(ContSock, NULL, CancelCheckWork, "%s %s", SiteTbl[Flg], Host) / 100;\r
                                                        else\r
                                                        else\r
-                                                               Sts = command(ContSock, NULL, &CancelFlg, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;\r
+                                                               // 同時接続対応\r
+//                                                             Sts = command(ContSock, NULL, &CancelFlg, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;\r
+                                                               Sts = command(ContSock, NULL, CancelCheckWork, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;\r
                                                }\r
 \r
                                                if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
                                                }\r
 \r
                                                if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))\r
@@ -1393,8 +1576,11 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                else\r
                                                {\r
                                                        Anony = NO;\r
                                                else\r
                                                {\r
                                                        Anony = NO;\r
+                                                       // 同時接続対応\r
+//                                                     if((strlen(User) != 0) || \r
+//                                                        (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
                                                        if((strlen(User) != 0) || \r
                                                        if((strlen(User) != 0) || \r
-                                                          (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                          ((HostData->NoDisplayUI == NO) && (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                        {\r
                                                                if(Anony == YES)\r
                                                                {\r
                                                        {\r
                                                                if(Anony == YES)\r
                                                                {\r
@@ -1415,13 +1601,13 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                // FTPES対応\r
                                                                if(CryptMode == CRYPT_FTPES)\r
                                                                {\r
                                                                // FTPES対応\r
                                                                if(CryptMode == CRYPT_FTPES)\r
                                                                {\r
-                                                                       if(IsOpenSSLLoaded() && (Sts = command(ContSock, Reply, &CancelFlg, "AUTH TLS")) == 234)\r
+                                                                       if(IsOpenSSLLoaded() && (Sts = command(ContSock, Reply, CancelCheckWork, "AUTH TLS")) == 234)\r
                                                                        {\r
                                                                        {\r
-                                                                               if(AttachSSL(ContSock))\r
+                                                                               if(AttachSSL(ContSock, INVALID_SOCKET, CancelCheckWork))\r
                                                                                {\r
                                                                                {\r
-                                                                                       if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)\r
+                                                                                       if((Sts = command(ContSock, Reply, CancelCheckWork, "PBSZ 0")) == 200)\r
                                                                                        {\r
                                                                                        {\r
-                                                                                               if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)\r
+                                                                                               if((Sts = command(ContSock, Reply, CancelCheckWork, "PROT P")) == 200)\r
                                                                                                {\r
                                                                                                }\r
                                                                                                else\r
                                                                                                {\r
                                                                                                }\r
                                                                                                else\r
@@ -1437,6 +1623,18 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                Sts = FTP_ERROR;\r
                                                                }\r
 \r
                                                                                Sts = FTP_ERROR;\r
                                                                }\r
 \r
+                                                               // FTPIS対応\r
+                                                               // "PBSZ 0"と"PROT P"は黙示的に設定されているはずだが念のため\r
+                                                               if(CryptMode == CRYPT_FTPIS)\r
+                                                               {\r
+                                                                       if((Sts = command(ContSock, Reply, CancelCheckWork, "PBSZ 0")) == 200)\r
+                                                                       {\r
+                                                                               if((Sts = command(ContSock, Reply, CancelCheckWork, "PROT P")) == 200)\r
+                                                                               {\r
+                                                                               }\r
+                                                                       }\r
+                                                               }\r
+\r
                                                                ReInPass = NO;\r
                                                                do\r
                                                                {\r
                                                                ReInPass = NO;\r
                                                                do\r
                                                                {\r
@@ -1444,10 +1642,15 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                        if(Sts == FTP_ERROR)\r
                                                                                break;\r
                                                                        Continue = NO;\r
                                                                        if(Sts == FTP_ERROR)\r
                                                                                break;\r
                                                                        Continue = NO;\r
-                                                                       if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", Buf) / 100) == FTP_CONTINUE)\r
+                                                                       // 同時接続対応\r
+//                                                                     if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", Buf) / 100) == FTP_CONTINUE)\r
+                                                                       if((Sts = command(ContSock, Reply, CancelCheckWork, "USER %s", Buf) / 100) == FTP_CONTINUE)\r
                                                                        {\r
                                                                        {\r
+                                                                               // 同時接続対応\r
+//                                                                             if((strlen(Pass) != 0) || \r
+//                                                                                (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
                                                                                if((strlen(Pass) != 0) || \r
                                                                                if((strlen(Pass) != 0) || \r
-                                                                                  (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                                                  ((HostData->NoDisplayUI == NO) && (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                                                {\r
                                                                                        CheckOneTimePassword(Pass, Reply, Security);\r
 \r
                                                                                {\r
                                                                                        CheckOneTimePassword(Pass, Reply, Security);\r
 \r
@@ -1455,11 +1658,15 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                        if(strcmp(Reply, " ") == 0)\r
                                                                                                strcpy(Reply, "");\r
 \r
                                                                                        if(strcmp(Reply, " ") == 0)\r
                                                                                                strcpy(Reply, "");\r
 \r
-                                                                                       Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                                                                       // 同時接続対応\r
+//                                                                                     Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;\r
+                                                                                       Sts = command(ContSock, NULL, CancelCheckWork, "PASS %s", Reply) / 100;\r
                                                                                        if(Sts == FTP_ERROR)\r
                                                                                        {\r
                                                                                                strcpy(Pass, "");\r
                                                                                        if(Sts == FTP_ERROR)\r
                                                                                        {\r
                                                                                                strcpy(Pass, "");\r
-                                                                                               if(InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)\r
+                                                                                               // 同時接続対応\r
+//                                                                                             if(InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)\r
+                                                                                               if(HostData->NoDisplayUI == NO && InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)\r
                                                                                                        Continue = YES;\r
                                                                                                else\r
                                                                                                        DoPrintf("No password specified.");\r
                                                                                                        Continue = YES;\r
                                                                                                else\r
                                                                                                        DoPrintf("No password specified.");\r
@@ -1467,10 +1674,15 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                        }\r
                                                                                        else if(Sts == FTP_CONTINUE)\r
                                                                                        {\r
                                                                                        }\r
                                                                                        else if(Sts == FTP_CONTINUE)\r
                                                                                        {\r
+                                                                                               // 同時接続対応\r
+//                                                                                             if((strlen(Acct) != 0) || \r
+//                                                                                                (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
                                                                                                if((strlen(Acct) != 0) || \r
                                                                                                if((strlen(Acct) != 0) || \r
-                                                                                                  (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))\r
+                                                                                                  ((HostData->NoDisplayUI == NO) && (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)))\r
                                                                                                {\r
                                                                                                {\r
-                                                                                                       Sts = command(ContSock, NULL, &CancelFlg, "ACCT %s", Acct) / 100;\r
+                                                                                                       // 同時接続対応\r
+//                                                                                                     Sts = command(ContSock, NULL, &CancelFlg, "ACCT %s", Acct) / 100;\r
+                                                                                                       Sts = command(ContSock, NULL, CancelCheckWork, "ACCT %s", Acct) / 100;\r
                                                                                                }\r
                                                                                                else\r
                                                                                                        DoPrintf("No account specified");\r
                                                                                                }\r
                                                                                                else\r
                                                                                                        DoPrintf("No account specified");\r
@@ -1482,6 +1694,9 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                                                        DoPrintf("No password specified.");\r
                                                                                }\r
                                                                        }\r
                                                                                        DoPrintf("No password specified.");\r
                                                                                }\r
                                                                        }\r
+                                                                       // FTPES対応\r
+                                                                       if(Continue == YES)\r
+                                                                               Sts = FTP_COMPLETE;\r
                                                                }\r
                                                                while(Continue == YES);\r
                                                        }\r
                                                                }\r
                                                                while(Continue == YES);\r
                                                        }\r
@@ -1499,7 +1714,9 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                                        }\r
                                                        else if((SavePass == YES) && (ReInPass == YES))\r
                                                        {\r
                                                        }\r
                                                        else if((SavePass == YES) && (ReInPass == YES))\r
                                                        {\r
-                                                               if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                               // 同時接続対応\r
+//                                                             if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
+                                                               if(HostData->NoDisplayUI == NO && DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
                                                                        SetHostPassword(AskCurrentHost(), Pass);\r
                                                        }\r
                                                }\r
                                                                        SetHostPassword(AskCurrentHost(), Pass);\r
                                                        }\r
                                                }\r
@@ -1533,7 +1750,7 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                // ホストの機能を確認\r
                if(ContSock != INVALID_SOCKET)\r
                {\r
                // ホストの機能を確認\r
                if(ContSock != INVALID_SOCKET)\r
                {\r
-                       if((Sts = command(ContSock, Reply, &CancelFlg, "FEAT")) == 211)\r
+                       if((Sts = command(ContSock, Reply, CancelCheckWork, "FEAT")) == 211)\r
                        {\r
                                // 改行文字はReadReplyMessageで消去されるため区切り文字に空白を使用\r
                                // UTF-8対応\r
                        {\r
                                // 改行文字はReadReplyMessageで消去されるため区切り文字に空白を使用\r
                                // UTF-8対応\r
@@ -1542,49 +1759,109 @@ static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char
                                // MLST対応\r
                                if(strstr(Reply, " MLST ") || strstr(Reply, " MLSD "))\r
                                        HostData->Feature |= FEATURE_MLSD;\r
                                // MLST対応\r
                                if(strstr(Reply, " MLST ") || strstr(Reply, " MLSD "))\r
                                        HostData->Feature |= FEATURE_MLSD;\r
+                               // IPv6対応\r
+                               if(strstr(Reply, " EPRT ") || strstr(Reply, " EPSV "))\r
+                                       HostData->Feature |= FEATURE_EPRT | FEATURE_EPSV;\r
                        }\r
                        // UTF-8対応\r
                        }\r
                        // UTF-8対応\r
-                       if(HostData->NameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))\r
+                       if(HostData->CurNameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))\r
                        {\r
                        {\r
-                               if((Sts = command(ContSock, Reply, &CancelFlg, "OPTS UTF8 ON")) == 200)\r
-                               {\r
-                               }\r
+                               if((Sts = command(ContSock, Reply, CancelCheckWork, "OPTS UTF8 ON")) == 200)\r
+                                       HostData->CurNameKanjiCode = KANJI_UTF8N;\r
                        }\r
                }\r
        }\r
        else if(CryptMode == CRYPT_SFTP)\r
        {\r
                        }\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
 \r
        }\r
 \r
        return(ContSock);\r
 }\r
 \r
-static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)\r
+// 同時接続対応\r
+//static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)\r
+static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security, int *CancelCheckWork)\r
 {\r
        SOCKET ContSock;\r
        ContSock = INVALID_SOCKET;\r
 {\r
        SOCKET ContSock;\r
        ContSock = INVALID_SOCKET;\r
-       if(ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)\r
+       *CancelCheckWork = NO;\r
+       if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)\r
        {\r
                SetTaskMsg(MSGJPN317);\r
        {\r
                SetTaskMsg(MSGJPN317);\r
-               if((ContSock = DoConnectCrypt(CRYPT_SFTP, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\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
                        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(*CancelCheckWork == 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, CancelCheckWork)) != INVALID_SOCKET)\r
+                       HostData->CryptMode = CRYPT_FTPIS;\r
+       }\r
+       if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseFTPES == YES)\r
        {\r
                SetTaskMsg(MSGJPN315);\r
        {\r
                SetTaskMsg(MSGJPN315);\r
-               if((ContSock = DoConnectCrypt(CRYPT_FTPES, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
+               if((ContSock = DoConnectCrypt(CRYPT_FTPES, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
                        HostData->CryptMode = CRYPT_FTPES;\r
        }\r
                        HostData->CryptMode = CRYPT_FTPES;\r
        }\r
-       if(ContSock == INVALID_SOCKET && HostData->UseNoEncryption == YES)\r
+       if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseNoEncryption == YES)\r
        {\r
                SetTaskMsg(MSGJPN314);\r
        {\r
                SetTaskMsg(MSGJPN314);\r
-               if((ContSock = DoConnectCrypt(CRYPT_NONE, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)\r
+               if((ContSock = DoConnectCrypt(CRYPT_NONE, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
                        HostData->CryptMode = CRYPT_NONE;\r
        }\r
        return ContSock;\r
                        HostData->CryptMode = CRYPT_NONE;\r
        }\r
        return ContSock;\r
@@ -1716,8 +1993,36 @@ static int CheckOneTimePassword(char *Pass, char *Reply, int Type)
 *              SOCKET ソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
 *              SOCKET ソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
+// IPv6対応\r
 SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
 {\r
 SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
 {\r
+       SOCKET Result;\r
+       Result = INVALID_SOCKET;\r
+       switch(CurHost.CurNetType)\r
+       {\r
+       case NTYPE_AUTO:\r
+               if((Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
+                       CurHost.CurNetType = NTYPE_IPV4;\r
+               else if((Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork)) != INVALID_SOCKET)\r
+                       CurHost.CurNetType = NTYPE_IPV6;\r
+               break;\r
+       case NTYPE_IPV4:\r
+               Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork);\r
+               CurHost.CurNetType = NTYPE_IPV4;\r
+               break;\r
+       case NTYPE_IPV6:\r
+               Result = connectsockIPv6(host, port, PreMsg, CancelCheckWork);\r
+               CurHost.CurNetType = NTYPE_IPV6;\r
+               break;\r
+       }\r
+       return Result;\r
+}\r
+\r
+\r
+// IPv6対応\r
+//SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+SOCKET connectsockIPv4(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+{\r
        struct sockaddr_in saSockAddr;\r
        char HostEntry[MAXGETHOSTSTRUCT];\r
        struct hostent *pHostEntry;\r
        struct sockaddr_in saSockAddr;\r
        char HostEntry[MAXGETHOSTSTRUCT];\r
        struct hostent *pHostEntry;\r
@@ -1741,10 +2046,15 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
 \r
        UseIPadrs = YES;\r
        strcpy(DomainName, host);\r
 \r
        UseIPadrs = YES;\r
        strcpy(DomainName, host);\r
-       memset(&CurSockAddr, 0, sizeof(CurSockAddr));\r
-       CurSockAddr.sin_port = htons((u_short)port);\r
-       CurSockAddr.sin_family = AF_INET;\r
-       if((CurSockAddr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)\r
+       // IPv6対応\r
+//     memset(&CurSockAddr, 0, sizeof(CurSockAddr));\r
+//     CurSockAddr.sin_port = htons((u_short)port);\r
+//     CurSockAddr.sin_family = AF_INET;\r
+//     if((CurSockAddr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)\r
+       memset(&CurSockAddrIPv4, 0, sizeof(CurSockAddrIPv4));\r
+       CurSockAddrIPv4.sin_port = htons((u_short)port);\r
+       CurSockAddrIPv4.sin_family = AF_INET;\r
+       if((CurSockAddrIPv4.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)\r
        {\r
                // ホスト名が指定された\r
                // ホスト名からアドレスを求める\r
        {\r
                // ホスト名が指定された\r
                // ホスト名からアドレスを求める\r
@@ -1758,20 +2068,27 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                {\r
                        // アドレスを取得\r
                        SetTaskMsg(MSGJPN016, DomainName);\r
                {\r
                        // アドレスを取得\r
                        SetTaskMsg(MSGJPN016, DomainName);\r
-                       pHostEntry = do_gethostbyname(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
+                       // IPv6対応\r
+//                     pHostEntry = do_gethostbyname(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
+                       pHostEntry = do_gethostbynameIPv4(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
                }\r
 \r
                if(pHostEntry != NULL)\r
                {\r
                }\r
 \r
                if(pHostEntry != NULL)\r
                {\r
-                       memcpy((char *)&CurSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
-                       SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+                       // IPv6対応\r
+//                     memcpy((char *)&CurSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+//                     SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+                       memcpy((char *)&CurSockAddrIPv4.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddrIPv4.sin_addr), ntohs(CurSockAddrIPv4.sin_port));\r
                }\r
                else\r
                {\r
                        if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
                        {\r
                                UseIPadrs = NO;\r
                }\r
                else\r
                {\r
                        if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
                        {\r
                                UseIPadrs = NO;\r
-                               SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port));\r
+                               // IPv6対応\r
+//                             SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port));\r
+                               SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddrIPv4.sin_port));\r
                        }\r
                        else\r
                        {\r
                        }\r
                        else\r
                        {\r
@@ -1781,7 +2098,9 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                }\r
        }\r
        else\r
                }\r
        }\r
        else\r
-               SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+               // IPv6対応\r
+//             SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port));\r
+               SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddrIPv4.sin_addr), ntohs(CurSockAddrIPv4.sin_port));\r
 \r
        if((Fwall == FWALL_SOCKS4) || (Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
        {\r
 \r
        if((Fwall == FWALL_SOCKS4) || (Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
        {\r
@@ -1791,37 +2110,56 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                {\r
                        Socks4Cmd.Ver = SOCKS4_VER;\r
                        Socks4Cmd.Cmd = SOCKS4_CMD_CONNECT;\r
                {\r
                        Socks4Cmd.Ver = SOCKS4_VER;\r
                        Socks4Cmd.Cmd = SOCKS4_CMD_CONNECT;\r
-                       Socks4Cmd.Port = CurSockAddr.sin_port;\r
-                       Socks4Cmd.AdrsInt = CurSockAddr.sin_addr.s_addr;\r
+                       // IPv6対応\r
+//                     Socks4Cmd.Port = CurSockAddr.sin_port;\r
+//                     Socks4Cmd.AdrsInt = CurSockAddr.sin_addr.s_addr;\r
+                       Socks4Cmd.Port = CurSockAddrIPv4.sin_port;\r
+                       Socks4Cmd.AdrsInt = CurSockAddrIPv4.sin_addr.s_addr;\r
                        strcpy(Socks4Cmd.UserID, FwallUser);\r
                        Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
                }\r
                else\r
                {\r
                        strcpy(Socks4Cmd.UserID, FwallUser);\r
                        Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
                }\r
                else\r
                {\r
-                       Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
+                       // IPv6対応\r
+//                     Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
+                       Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, CurSockAddrIPv4.sin_addr.s_addr, DomainName, CurSockAddrIPv4.sin_port);\r
                }\r
 \r
                }\r
 \r
-               memset(&SocksSockAddr, 0, sizeof(SocksSockAddr));\r
-               if((SocksSockAddr.sin_addr.s_addr = inet_addr(FwallHost)) == INADDR_NONE)\r
+               // IPv6対応\r
+//             memset(&SocksSockAddr, 0, sizeof(SocksSockAddr));\r
+//             if((SocksSockAddr.sin_addr.s_addr = inet_addr(FwallHost)) == INADDR_NONE)\r
+               memset(&SocksSockAddrIPv4, 0, sizeof(SocksSockAddrIPv4));\r
+               if((SocksSockAddrIPv4.sin_addr.s_addr = inet_addr(FwallHost)) == INADDR_NONE)\r
                {\r
                {\r
-                       if((pHostEntry = do_gethostbyname(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
-                               memcpy((char *)&SocksSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       // IPv6対応\r
+//                     if((pHostEntry = do_gethostbyname(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
+//                             memcpy((char *)&SocksSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       if((pHostEntry = do_gethostbynameIPv4(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
+                               memcpy((char *)&SocksSockAddrIPv4.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
                        else\r
                        {\r
                                SetTaskMsg(MSGJPN021, FwallHost);\r
                                return INVALID_SOCKET;\r
                        }\r
                }\r
                        else\r
                        {\r
                                SetTaskMsg(MSGJPN021, FwallHost);\r
                                return INVALID_SOCKET;\r
                        }\r
                }\r
-               SocksSockAddr.sin_port = htons((u_short)FwallPort);\r
-               SocksSockAddr.sin_family = AF_INET;\r
-               SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddr.sin_addr), ntohs(SocksSockAddr.sin_port));\r
+               // IPv6対応\r
+//             SocksSockAddr.sin_port = htons((u_short)FwallPort);\r
+//             SocksSockAddr.sin_family = AF_INET;\r
+//             SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddr.sin_addr), ntohs(SocksSockAddr.sin_port));\r
+               SocksSockAddrIPv4.sin_port = htons((u_short)FwallPort);\r
+               SocksSockAddrIPv4.sin_family = AF_INET;\r
+               SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddrIPv4.sin_addr), ntohs(SocksSockAddrIPv4.sin_port));\r
                // connectで接続する先はSOCKSサーバ\r
                // connectで接続する先はSOCKSサーバ\r
-               memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
+               // IPv6対応\r
+//             memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
+               memcpy(&saSockAddr, &SocksSockAddrIPv4, sizeof(SocksSockAddrIPv4));\r
        }\r
        else\r
        {\r
                // connectで接続するのは接続先のホスト\r
        }\r
        else\r
        {\r
                // connectで接続するのは接続先のホスト\r
-               memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\r
+               // IPv6対応\r
+//             memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\r
+               memcpy(&saSockAddr, &CurSockAddrIPv4, sizeof(CurSockAddrIPv4));\r
        }\r
 \r
        /////////////\r
        }\r
 \r
        /////////////\r
@@ -1835,8 +2173,12 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                        if(Fwall == FWALL_SOCKS4)\r
                        {\r
                                Socks4Reply.Result = -1;\r
                        if(Fwall == FWALL_SOCKS4)\r
                        {\r
                                Socks4Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(sSocket, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks4GetCmdReply(sSocket, &Socks4Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                if((SocksSendCmd(sSocket, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                                if((SocksSendCmd(sSocket, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
-                                  (Socks4GetCmdReply(sSocket, &Socks4Reply) != FFFTP_SUCCESS) || \r
+                                  (Socks4GetCmdReply(sSocket, &Socks4Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN023, Socks4Reply.Result);\r
                                   (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN023, Socks4Reply.Result);\r
@@ -1853,8 +2195,161 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
                                }\r
 \r
                                Socks5Reply.Result = -1;\r
                                }\r
 \r
                                Socks5Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(sSocket, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks5GetCmdReply(sSocket, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
+                                  (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               {\r
+                                       SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
+                                       DoClose(sSocket);\r
+                                       sSocket = INVALID_SOCKET;\r
+                               }\r
+\r
+                       }\r
+\r
+                       if(sSocket != INVALID_SOCKET)\r
+                               SetTaskMsg(MSGJPN025);\r
+               }\r
+               else\r
+               {\r
+//#pragma aaa\r
+                       SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/);\r
+                       DoClose(sSocket);\r
+                       sSocket = INVALID_SOCKET;\r
+               }\r
+       }\r
+       else\r
+               SetTaskMsg(MSGJPN027);\r
+\r
+       return(sSocket);\r
+}\r
+\r
+\r
+SOCKET connectsockIPv6(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
+{\r
+       struct sockaddr_in6 saSockAddr;\r
+       char HostEntry[MAXGETHOSTSTRUCT];\r
+       struct hostent *pHostEntry;\r
+       SOCKET sSocket;\r
+       int Len;\r
+       int Fwall;\r
+       SOCKS5REQUEST Socks5Cmd;\r
+       SOCKS5REPLY Socks5Reply;\r
+\r
+       //////////////////////////////\r
+       // ホスト名解決と接続の準備\r
+       //////////////////////////////\r
+\r
+       Fwall = FWALL_NONE;\r
+       if(AskHostFireWall() == YES)\r
+               Fwall = FwallType;\r
+\r
+       sSocket = INVALID_SOCKET;\r
+\r
+       UseIPadrs = YES;\r
+       strcpy(DomainName, host);\r
+       memset(&CurSockAddrIPv6, 0, sizeof(CurSockAddrIPv6));\r
+       CurSockAddrIPv6.sin6_port = htons((u_short)port);\r
+       CurSockAddrIPv6.sin6_family = AF_INET6;\r
+       CurSockAddrIPv6.sin6_addr = inet6_addr(host);\r
+       if(memcmp(&CurSockAddrIPv6.sin6_addr, &IN6ADDR_NONE, sizeof(struct in6_addr)) == 0)\r
+       {\r
+               // ホスト名が指定された\r
+               // ホスト名からアドレスを求める\r
+               if(((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER)) &&\r
+                  (FwallResolv == YES))\r
+               {\r
+                       // ホスト名解決はSOCKSサーバに任せる\r
+                       pHostEntry = NULL;\r
+               }\r
+               else\r
+               {\r
+                       // アドレスを取得\r
+                       SetTaskMsg(MSGJPN016, DomainName);\r
+                       pHostEntry = do_gethostbynameIPv6(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
+               }\r
+\r
+               if(pHostEntry != NULL)\r
+               {\r
+                       memcpy((char *)&CurSockAddrIPv6.sin6_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet6_ntoa(CurSockAddrIPv6.sin6_addr), ntohs(CurSockAddrIPv6.sin6_port));\r
+               }\r
+               else\r
+               {\r
+                       if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+                       {\r
+                               UseIPadrs = NO;\r
+                               SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddrIPv6.sin6_port));\r
+                       }\r
+                       else\r
+                       {\r
+                               SetTaskMsg(MSGJPN019, host);\r
+                               return(INVALID_SOCKET);\r
+                       }\r
+               }\r
+       }\r
+       else\r
+               SetTaskMsg(MSGJPN020, PreMsg, inet6_ntoa(CurSockAddrIPv6.sin6_addr), ntohs(CurSockAddrIPv6.sin6_port));\r
+\r
+       if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+       {\r
+               // SOCKSを使う\r
+               // SOCKSに接続する準備\r
+               {\r
+                       Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, (char*)&CurSockAddrIPv6.sin6_addr, DomainName, CurSockAddrIPv6.sin6_port);\r
+               }\r
+\r
+               memset(&SocksSockAddrIPv6, 0, sizeof(SocksSockAddrIPv6));\r
+               SocksSockAddrIPv6.sin6_addr = inet6_addr(FwallHost);\r
+               if(memcmp(&SocksSockAddrIPv6.sin6_addr, &IN6ADDR_NONE, sizeof(struct in6_addr)) == 0)\r
+               {\r
+                       if((pHostEntry = do_gethostbynameIPv6(FwallHost, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork)) != NULL)\r
+                               memcpy((char *)&SocksSockAddrIPv6.sin6_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+                       else\r
+                       {\r
+                               SetTaskMsg(MSGJPN021, FwallHost);\r
+                               return INVALID_SOCKET;\r
+                       }\r
+               }\r
+               SocksSockAddrIPv6.sin6_port = htons((u_short)FwallPort);\r
+               SocksSockAddrIPv6.sin6_family = AF_INET6;\r
+               SetTaskMsg(MSGJPN022, inet6_ntoa(SocksSockAddrIPv6.sin6_addr), ntohs(SocksSockAddrIPv6.sin6_port));\r
+               // connectで接続する先はSOCKSサーバ\r
+               memcpy(&saSockAddr, &SocksSockAddrIPv6, sizeof(SocksSockAddrIPv6));\r
+       }\r
+       else\r
+       {\r
+               // connectで接続するのは接続先のホスト\r
+               memcpy(&saSockAddr, &CurSockAddrIPv6, sizeof(CurSockAddrIPv6));\r
+       }\r
+\r
+       /////////////\r
+       // 接続実行\r
+       /////////////\r
+\r
+       inet6_ntoa(saSockAddr.sin6_addr);\r
+       if((sSocket = do_socket(AF_INET6, SOCK_STREAM, TCP_PORT)) != INVALID_SOCKET)\r
+       {\r
+               if(do_connect(sSocket, (struct sockaddr *)&saSockAddr, sizeof(saSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+               {\r
+                       if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+                       {\r
+                               if(Socks5SelMethod(sSocket, CancelCheckWork) == FFFTP_FAIL)\r
+                               {\r
+                                       DoClose(sSocket);\r
+                                       sSocket = INVALID_SOCKET;\r
+                               }\r
+\r
+                               Socks5Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(sSocket, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                                if((SocksSendCmd(sSocket, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
-                                  (Socks5GetCmdReply(sSocket, &Socks5Reply) != FFFTP_SUCCESS) || \r
+                                  (Socks5GetCmdReply(sSocket, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
                                   (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
@@ -1891,8 +2386,28 @@ SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)
 *              SOCKET リッスンソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
 *              SOCKET リッスンソケット\r
 *----------------------------------------------------------------------------*/\r
 \r
+// IPv6対応\r
 SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)\r
 {\r
 SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)\r
 {\r
+       SOCKET Result;\r
+       Result = INVALID_SOCKET;\r
+       switch(CurHost.CurNetType)\r
+       {\r
+       case NTYPE_IPV4:\r
+               Result = GetFTPListenSocketIPv4(ctrl_skt, CancelCheckWork);\r
+               break;\r
+       case NTYPE_IPV6:\r
+               Result = GetFTPListenSocketIPv6(ctrl_skt, CancelCheckWork);\r
+               break;\r
+       }\r
+       return Result;\r
+}\r
+\r
+\r
+// IPv6対応\r
+//SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)\r
+SOCKET GetFTPListenSocketIPv4(SOCKET ctrl_skt, int *CancelCheckWork)\r
+{\r
     SOCKET listen_skt;\r
     int iLength;\r
     char *a,*p;\r
     SOCKET listen_skt;\r
     int iLength;\r
     char *a,*p;\r
@@ -1916,18 +2431,27 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                {\r
                        /*===== SOCKS4を使う =====*/\r
                        DoPrintf("Use SOCKS4 BIND");\r
                {\r
                        /*===== SOCKS4を使う =====*/\r
                        DoPrintf("Use SOCKS4 BIND");\r
-                       if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+                       // IPv6対応\r
+//                     if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+                       if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddrIPv4, sizeof(SocksSockAddrIPv4), CancelCheckWork) != SOCKET_ERROR)\r
                        {\r
                                Socks4Cmd.Ver = SOCKS4_VER;\r
                                Socks4Cmd.Cmd = SOCKS4_CMD_BIND;\r
                        {\r
                                Socks4Cmd.Ver = SOCKS4_VER;\r
                                Socks4Cmd.Cmd = SOCKS4_CMD_BIND;\r
-                               Socks4Cmd.Port = CurSockAddr.sin_port;\r
-                               Socks4Cmd.AdrsInt = CurSockAddr.sin_addr.s_addr;\r
+                               // IPv6対応\r
+//                             Socks4Cmd.Port = CurSockAddr.sin_port;\r
+//                             Socks4Cmd.AdrsInt = CurSockAddr.sin_addr.s_addr;\r
+                               Socks4Cmd.Port = CurSockAddrIPv4.sin_port;\r
+                               Socks4Cmd.AdrsInt = CurSockAddrIPv4.sin_addr.s_addr;\r
                                strcpy(Socks4Cmd.UserID, FwallUser);\r
                                Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
 \r
                                Socks4Reply.Result = -1;\r
                                strcpy(Socks4Cmd.UserID, FwallUser);\r
                                Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
 \r
                                Socks4Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(listen_skt, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks4GetCmdReply(listen_skt, &Socks4Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                if((SocksSendCmd(listen_skt, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                                if((SocksSendCmd(listen_skt, &Socks4Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
-                                  (Socks4GetCmdReply(listen_skt, &Socks4Reply) != FFFTP_SUCCESS) || \r
+                                  (Socks4GetCmdReply(listen_skt, &Socks4Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN028, Socks4Reply.Result);\r
                                   (Socks4Reply.Result != SOCKS4_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN028, Socks4Reply.Result);\r
@@ -1936,7 +2460,9 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                                }\r
 \r
                                if(Socks4Reply.AdrsInt == 0)\r
                                }\r
 \r
                                if(Socks4Reply.AdrsInt == 0)\r
-                                       Socks4Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
+                                       // IPv6対応\r
+//                                     Socks4Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
+                                       Socks4Reply.AdrsInt = SocksSockAddrIPv4.sin_addr.s_addr;\r
 \r
                                a = (char *)&Socks4Reply.AdrsInt;\r
                                p = (char *)&Socks4Reply.Port;\r
 \r
                                a = (char *)&Socks4Reply.AdrsInt;\r
                                p = (char *)&Socks4Reply.Port;\r
@@ -1946,7 +2472,9 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                {\r
                        /*===== SOCKS5を使う =====*/\r
                        DoPrintf("Use SOCKS5 BIND");\r
                {\r
                        /*===== SOCKS5を使う =====*/\r
                        DoPrintf("Use SOCKS5 BIND");\r
-                       if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+                       // IPv6対応\r
+//                     if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
+                       if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddrIPv4, sizeof(SocksSockAddrIPv4), CancelCheckWork) != SOCKET_ERROR)\r
                        {\r
                                if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
                                {\r
                        {\r
                                if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
                                {\r
@@ -1955,11 +2483,17 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                                        return(listen_skt);\r
                                }\r
 \r
                                        return(listen_skt);\r
                                }\r
 \r
-                               Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
+                               // IPv6対応\r
+//                             Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
+                               Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, CurSockAddrIPv4.sin_addr.s_addr, DomainName, CurSockAddrIPv4.sin_port);\r
 \r
                                Socks5Reply.Result = -1;\r
 \r
                                Socks5Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(listen_skt, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                                if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
-                                  (Socks5GetCmdReply(listen_skt, &Socks5Reply) != FFFTP_SUCCESS) || \r
+                                  (Socks5GetCmdReply(listen_skt, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
                                   (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
                                   (Socks5Reply.Result != SOCKS5_RES_OK))\r
                                {\r
                                        SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
@@ -1967,11 +2501,15 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
                                        listen_skt = INVALID_SOCKET;\r
                                }\r
 \r
                                        listen_skt = INVALID_SOCKET;\r
                                }\r
 \r
-                               if(Socks5Reply.AdrsInt == 0)\r
-                                       Socks5Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
+                               // IPv6対応\r
+//                             if(Socks5Reply.AdrsInt == 0)\r
+//                                     Socks5Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
 \r
 \r
-                               a = (char *)&Socks5Reply.AdrsInt;\r
-                               p = (char *)&Socks5Reply.Port;\r
+                               // IPv6対応\r
+//                             a = (char *)&Socks5Reply.AdrsInt;\r
+//                             p = (char *)&Socks5Reply.Port;\r
+                               a = (char *)&Socks5Reply._dummy[0];\r
+                               p = (char *)&Socks5Reply._dummy[4];\r
                        }\r
                }\r
                else\r
                        }\r
                }\r
                else\r
@@ -2027,7 +2565,11 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
        if(listen_skt != INVALID_SOCKET)\r
        {\r
 #define  UC(b)  (((int)b)&0xff)\r
        if(listen_skt != INVALID_SOCKET)\r
        {\r
 #define  UC(b)  (((int)b)&0xff)\r
-               if((command(ctrl_skt,NULL, &CancelFlg, "PORT %d,%d,%d,%d,%d,%d",\r
+               // 同時接続対応\r
+//             if((command(ctrl_skt,NULL, &CancelFlg, "PORT %d,%d,%d,%d,%d,%d",\r
+//                             UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),\r
+//                             UC(p[0]), UC(p[1])) / 100) != FTP_COMPLETE)\r
+               if((command(ctrl_skt,NULL, CancelCheckWork, "PORT %d,%d,%d,%d,%d,%d",\r
                                UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),\r
                                UC(p[0]), UC(p[1])) / 100) != FTP_COMPLETE)\r
                {\r
                                UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),\r
                                UC(p[0]), UC(p[1])) / 100) != FTP_COMPLETE)\r
                {\r
@@ -2043,6 +2585,140 @@ SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)
 }\r
 \r
 \r
 }\r
 \r
 \r
+SOCKET GetFTPListenSocketIPv6(SOCKET ctrl_skt, int *CancelCheckWork)\r
+{\r
+    SOCKET listen_skt;\r
+    int iLength;\r
+    char *a,*p;\r
+       struct sockaddr_in6 saCtrlAddr;\r
+       struct sockaddr_in6 saTmpAddr;\r
+       SOCKS5REQUEST Socks5Cmd;\r
+       SOCKS5REPLY Socks5Reply;\r
+\r
+       int Len;\r
+       int Fwall;\r
+\r
+       char Adrs[40];\r
+\r
+       Fwall = FWALL_NONE;\r
+       if(AskHostFireWall() == YES)\r
+               Fwall = FwallType;\r
+\r
+       if((listen_skt = do_socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) != INVALID_SOCKET)\r
+       {\r
+               if((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
+               {\r
+                       /*===== SOCKS5を使う =====*/\r
+                       DoPrintf("Use SOCKS5 BIND");\r
+                       if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddrIPv6, sizeof(SocksSockAddrIPv6), CancelCheckWork) != SOCKET_ERROR)\r
+                       {\r
+                               if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
+                               {\r
+                                       DoClose(listen_skt);\r
+                                       listen_skt = INVALID_SOCKET;\r
+                                       return(listen_skt);\r
+                               }\r
+\r
+                               Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, (char*)&CurSockAddrIPv6.sin6_addr, DomainName, CurSockAddrIPv6.sin6_port);\r
+\r
+                               Socks5Reply.Result = -1;\r
+                               // 同時接続対応\r
+//                             if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                                (Socks5GetCmdReply(listen_skt, &Socks5Reply) != FFFTP_SUCCESS) || \r
+//                                (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               if((SocksSendCmd(listen_skt, &Socks5Cmd, Len, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+                                  (Socks5GetCmdReply(listen_skt, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
+                                  (Socks5Reply.Result != SOCKS5_RES_OK))\r
+                               {\r
+                                       SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
+                                       DoClose(listen_skt);\r
+                                       listen_skt = INVALID_SOCKET;\r
+                               }\r
+\r
+                               // IPv6対応\r
+//                             if(Socks5Reply.AdrsInt == 0)\r
+//                                     Socks5Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
+\r
+                               // IPv6対応\r
+//                             a = (char *)&Socks5Reply.AdrsInt;\r
+//                             p = (char *)&Socks5Reply.Port;\r
+                               a = (char *)&Socks5Reply._dummy[0];\r
+                               p = (char *)&Socks5Reply._dummy[16];\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       /*===== SOCKSを使わない =====*/\r
+                       DoPrintf("Use normal BIND");\r
+                       saCtrlAddr.sin6_port = htons(0);\r
+                       saCtrlAddr.sin6_family = AF_INET6;\r
+                       memset(&saCtrlAddr.sin6_addr, 0, 16);\r
+\r
+                       if(bind(listen_skt, (struct sockaddr *)&saCtrlAddr, sizeof(struct sockaddr_in6)) != SOCKET_ERROR)\r
+                       {\r
+                               iLength = sizeof(saCtrlAddr);\r
+                               if(getsockname(listen_skt, (struct sockaddr *)&saCtrlAddr, &iLength) != SOCKET_ERROR)\r
+                               {\r
+                                       if(do_listen(listen_skt, 1) == 0)\r
+                                       {\r
+                                               iLength = sizeof(saTmpAddr);\r
+                                               if(getsockname(ctrl_skt, (struct sockaddr *)&saTmpAddr, &iLength) == SOCKET_ERROR)\r
+                                                       ReportWSError("getsockname", WSAGetLastError());\r
+\r
+                                               a = (char *)&saTmpAddr.sin6_addr;\r
+                                               p = (char *)&saCtrlAddr.sin6_port;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               ReportWSError("listen", WSAGetLastError());\r
+                                               do_closesocket(listen_skt);\r
+                                               listen_skt = INVALID_SOCKET;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       ReportWSError("getsockname", WSAGetLastError());\r
+                                       do_closesocket(listen_skt);\r
+                                       listen_skt = INVALID_SOCKET;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               ReportWSError("bind", WSAGetLastError());\r
+                               do_closesocket(listen_skt);\r
+                               listen_skt = INVALID_SOCKET;\r
+                       }\r
+\r
+                       if(listen_skt == INVALID_SOCKET)\r
+                               SetTaskMsg(MSGJPN030);\r
+               }\r
+       }\r
+       else\r
+               ReportWSError("socket create", WSAGetLastError());\r
+\r
+       if(listen_skt != INVALID_SOCKET)\r
+       {\r
+#define  UC(b)  (((int)b)&0xff)\r
+               // 同時接続対応\r
+//             if((command(ctrl_skt,NULL, &CancelFlg, "PORT %d,%d,%d,%d,%d,%d",\r
+//                             UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]),\r
+//                             UC(p[0]), UC(p[1])) / 100) != FTP_COMPLETE)\r
+               if((command(ctrl_skt,NULL, CancelCheckWork, "EPRT |2|%s|%d|",\r
+                               AddressToStringIPv6(Adrs, a),\r
+                               (UC(p[0]) << 8) | UC(p[1])) / 100) != FTP_COMPLETE)\r
+               {\r
+                       SetTaskMsg(MSGJPN031);\r
+                       do_closesocket(listen_skt);\r
+                       listen_skt = INVALID_SOCKET;\r
+               }\r
+//             else\r
+//                     DoPrintf("Skt=%u : listener %s port %u",listen_skt,inet_ntoa(saCtrlAddr.sin_addr),ntohs(saCtrlAddr.sin_port));\r
+       }\r
+\r
+       return(listen_skt);\r
+}\r
+\r
+\r
 /*----- ホストへ接続処理中かどうかを返す---------------------------------------\r
 *\r
 *      Parameter\r
 /*----- ホストへ接続処理中かどうかを返す---------------------------------------\r
 *\r
 *      Parameter\r
@@ -2136,6 +2812,44 @@ static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulo
 }\r
 \r
 \r
 }\r
 \r
 \r
+// IPv6対応\r
+static int Socks5MakeCmdPacketIPv6(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, char *IP, char *Host, ushort Port)\r
+{\r
+       uchar *Pos;\r
+       int Len;\r
+       int TotalLen;\r
+\r
+       Pos = (uchar *)Packet;\r
+       Pos += SOCKS5REQUEST_SIZE;\r
+       TotalLen = SOCKS5REQUEST_SIZE + 2;      /* +2はポートの分 */\r
+\r
+       Packet->Ver = SOCKS5_VER;\r
+       Packet->Cmd = Cmd;\r
+       Packet->Rsv = 0;\r
+       if(ValidIP == YES)\r
+       {\r
+               /* IPアドレスを指定 */\r
+               Packet->Type = SOCKS5_ADRS_IPV6;\r
+               memcpy(Pos, IP, 16);\r
+               Pos += 16;\r
+               TotalLen += 16;\r
+       }\r
+       else\r
+       {\r
+               /* ホスト名を指定 */\r
+               Packet->Type = SOCKS5_ADRS_NAME;\r
+               Len = strlen(Host);\r
+               *Pos++ = Len;\r
+               strcpy(Pos, Host);\r
+               Pos += Len;\r
+               TotalLen += Len + 1;\r
+       }\r
+       *((ushort *)Pos) = Port;\r
+\r
+       return(TotalLen);\r
+}\r
+\r
+\r
 /*----- SOCKSのコマンドを送る -------------------------------------------------\r
 *\r
 *      Parameter\r
 /*----- SOCKSのコマンドを送る -------------------------------------------------\r
 *\r
 *      Parameter\r
@@ -2170,7 +2884,9 @@ static int SocksSendCmd(SOCKET Socket, void *Data, int Size, int *CancelCheckWor
 *              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
 *              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)\r
+// 同時接続対応\r
+//static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)\r
+static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet, int *CancelCheckWork)\r
 {\r
        uchar *Pos;\r
        int Len;\r
 {\r
        uchar *Pos;\r
        int Len;\r
@@ -2179,15 +2895,19 @@ static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)
        Pos = (uchar *)Packet;\r
        Pos += SOCKS5REPLY_SIZE;\r
 \r
        Pos = (uchar *)Packet;\r
        Pos += SOCKS5REPLY_SIZE;\r
 \r
-       if((Ret = ReadNchar(Socket, (char *)Packet, SOCKS5REPLY_SIZE, &CancelFlg)) == FFFTP_SUCCESS)\r
+       // 同時接続対応\r
+//     if((Ret = ReadNchar(Socket, (char *)Packet, SOCKS5REPLY_SIZE, &CancelFlg)) == FFFTP_SUCCESS)\r
+       if((Ret = ReadNchar(Socket, (char *)Packet, SOCKS5REPLY_SIZE, CancelCheckWork)) == FFFTP_SUCCESS)\r
        {\r
                if(Packet->Type == SOCKS5_ADRS_IPV4)\r
                        Len = 4 + 2;\r
                else if(Packet->Type == SOCKS5_ADRS_IPV6)\r
        {\r
                if(Packet->Type == SOCKS5_ADRS_IPV4)\r
                        Len = 4 + 2;\r
                else if(Packet->Type == SOCKS5_ADRS_IPV6)\r
-                       Len = 6 + 2;\r
+                       Len = 16 + 2;\r
                else\r
                {\r
                else\r
                {\r
-                       if((Ret = ReadNchar(Socket, (char *)Pos, 1, &CancelFlg)) == FFFTP_SUCCESS)\r
+                       // 同時接続対応\r
+//                     if((Ret = ReadNchar(Socket, (char *)Pos, 1, &CancelFlg)) == FFFTP_SUCCESS)\r
+                       if((Ret = ReadNchar(Socket, (char *)Pos, 1, CancelCheckWork)) == FFFTP_SUCCESS)\r
                        {\r
                                Len = *Pos + 2;\r
                                Pos++;\r
                        {\r
                                Len = *Pos + 2;\r
                                Pos++;\r
@@ -2195,7 +2915,9 @@ static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)
                }\r
 \r
                if(Ret == FFFTP_SUCCESS)\r
                }\r
 \r
                if(Ret == FFFTP_SUCCESS)\r
-                       Ret = ReadNchar(Socket, (char *)Pos, Len, &CancelFlg);\r
+                       // 同時接続対応\r
+//                     Ret = ReadNchar(Socket, (char *)Pos, Len, &CancelFlg);\r
+                       Ret = ReadNchar(Socket, (char *)Pos, Len, CancelCheckWork);\r
        }\r
 \r
        if(Ret != FFFTP_SUCCESS)\r
        }\r
 \r
        if(Ret != FFFTP_SUCCESS)\r
@@ -2215,11 +2937,15 @@ static int Socks5GetCmdReply(SOCKET Socket, SOCKS5REPLY *Packet)
 *              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
 *              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
-static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet)\r
+// 同時接続対応\r
+//static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet)\r
+static int Socks4GetCmdReply(SOCKET Socket, SOCKS4REPLY *Packet, int *CancelCheckWork)\r
 {\r
        int Ret;\r
 \r
 {\r
        int Ret;\r
 \r
-       Ret = ReadNchar(Socket, (char *)Packet, SOCKS4REPLY_SIZE, &CancelFlg);\r
+       // 同時接続対応\r
+//     Ret = ReadNchar(Socket, (char *)Packet, SOCKS4REPLY_SIZE, &CancelFlg);\r
+       Ret = ReadNchar(Socket, (char *)Packet, SOCKS4REPLY_SIZE, CancelCheckWork);\r
 \r
        if(Ret != FFFTP_SUCCESS)\r
                DoPrintf(MSGJPN035);\r
 \r
        if(Ret != FFFTP_SUCCESS)\r
                DoPrintf(MSGJPN035);\r
@@ -2255,8 +2981,12 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
        else\r
                Socks5Method.Methods[0] = SOCKS5_AUTH_USER;\r
 \r
        else\r
                Socks5Method.Methods[0] = SOCKS5_AUTH_USER;\r
 \r
+       // 同時接続対応\r
+//     if((SocksSendCmd(Socket, &Socks5Method, SOCKS5METHODREQUEST_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//        (ReadNchar(Socket, (char *)&Socks5MethodReply, SOCKS5METHODREPLY_SIZE, &CancelFlg) != FFFTP_SUCCESS) ||\r
+//        (Socks5MethodReply.Method == (uchar)0xFF))\r
        if((SocksSendCmd(Socket, &Socks5Method, SOCKS5METHODREQUEST_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
        if((SocksSendCmd(Socket, &Socks5Method, SOCKS5METHODREQUEST_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
-          (ReadNchar(Socket, (char *)&Socks5MethodReply, SOCKS5METHODREPLY_SIZE, &CancelFlg) != FFFTP_SUCCESS) ||\r
+          (ReadNchar(Socket, (char *)&Socks5MethodReply, SOCKS5METHODREPLY_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
           (Socks5MethodReply.Method == (uchar)0xFF))\r
        {\r
                SetTaskMsg(MSGJPN036);\r
           (Socks5MethodReply.Method == (uchar)0xFF))\r
        {\r
                SetTaskMsg(MSGJPN036);\r
@@ -2273,8 +3003,12 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
                Buf[2 + Len] = Len2;\r
                strcpy(Buf+3+Len, FwallPass);\r
 \r
                Buf[2 + Len] = Len2;\r
                strcpy(Buf+3+Len, FwallPass);\r
 \r
+               // 同時接続対応\r
+//             if((SocksSendCmd(Socket, &Buf, Len+Len2+3, CancelCheckWork) != FFFTP_SUCCESS) ||\r
+//                (ReadNchar(Socket, (char *)&Socks5Status, SOCKS5USERPASSSTATUS_SIZE, &CancelFlg) != FFFTP_SUCCESS) ||\r
+//                (Socks5Status.Status != 0))\r
                if((SocksSendCmd(Socket, &Buf, Len+Len2+3, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                if((SocksSendCmd(Socket, &Buf, Len+Len2+3, CancelCheckWork) != FFFTP_SUCCESS) ||\r
-                  (ReadNchar(Socket, (char *)&Socks5Status, SOCKS5USERPASSSTATUS_SIZE, &CancelFlg) != FFFTP_SUCCESS) ||\r
+                  (ReadNchar(Socket, (char *)&Socks5Status, SOCKS5USERPASSSTATUS_SIZE, CancelCheckWork) != FFFTP_SUCCESS) ||\r
                   (Socks5Status.Status != 0))\r
                {\r
                        SetTaskMsg(MSGJPN037);\r
                   (Socks5Status.Status != 0))\r
                {\r
                        SetTaskMsg(MSGJPN037);\r
@@ -2298,7 +3032,9 @@ static int Socks5SelMethod(SOCKET Socket, int *CancelCheckWork)
 *              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
 *              int ステータス (FFFTP_SUCCESS/FFFTP_FAIL)\r
 *----------------------------------------------------------------------------*/\r
 \r
-int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data)\r
+// 同時接続対応\r
+//int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data)\r
+int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data, int *CancelCheckWork)\r
 {\r
        int Ret;\r
        char Buf[300];\r
 {\r
        int Ret;\r
        char Buf[300];\r
@@ -2306,14 +3042,18 @@ int SocksGet2ndBindReply(SOCKET Socket, SOCKET *Data)
        Ret = FFFTP_FAIL;\r
        if((AskHostFireWall() == YES) && (FwallType == FWALL_SOCKS4))\r
        {\r
        Ret = FFFTP_FAIL;\r
        if((AskHostFireWall() == YES) && (FwallType == FWALL_SOCKS4))\r
        {\r
-               Socks4GetCmdReply(Socket, (SOCKS4REPLY *)Buf);\r
+               // 同時接続対応\r
+//             Socks4GetCmdReply(Socket, (SOCKS4REPLY *)Buf);\r
+               Socks4GetCmdReply(Socket, (SOCKS4REPLY *)Buf, CancelCheckWork);\r
                *Data = Socket;\r
                Ret = FFFTP_SUCCESS;\r
        }\r
        else if((AskHostFireWall() == YES) &&\r
                        ((FwallType == FWALL_SOCKS5_NOAUTH) || (FwallType == FWALL_SOCKS5_USER)))\r
        {\r
                *Data = Socket;\r
                Ret = FFFTP_SUCCESS;\r
        }\r
        else if((AskHostFireWall() == YES) &&\r
                        ((FwallType == FWALL_SOCKS5_NOAUTH) || (FwallType == FWALL_SOCKS5_USER)))\r
        {\r
-               Socks5GetCmdReply(Socket, (SOCKS5REPLY *)Buf);\r
+               // 同時接続対応\r
+//             Socks5GetCmdReply(Socket, (SOCKS5REPLY *)Buf);\r
+               Socks5GetCmdReply(Socket, (SOCKS5REPLY *)Buf, CancelCheckWork);\r
                *Data = Socket;\r
                Ret = FFFTP_SUCCESS;\r
        }\r
                *Data = Socket;\r
                Ret = FFFTP_SUCCESS;\r
        }\r
@@ -2348,12 +3088,22 @@ int AskUseSFTP(void)
        return(CurHost.UseSFTP);\r
 }\r
 \r
        return(CurHost.UseSFTP);\r
 }\r
 \r
+char *AskPrivateKey(void)\r
+{\r
+       return(CurHost.PrivateKey);\r
+}\r
+\r
 // 同時接続対応\r
 int AskMaxThreadCount(void)\r
 {\r
        return(CurHost.MaxThreadCount);\r
 }\r
 \r
 // 同時接続対応\r
 int AskMaxThreadCount(void)\r
 {\r
        return(CurHost.MaxThreadCount);\r
 }\r
 \r
+int AskReuseCmdSkt(void)\r
+{\r
+       return(CurHost.ReuseCmdSkt);\r
+}\r
+\r
 // FEAT対応\r
 int AskHostFeature(void)\r
 {\r
 // FEAT対応\r
 int AskHostFeature(void)\r
 {\r
@@ -2366,3 +3116,26 @@ int AskUseMLSD(void)
        return(CurHost.UseMLSD);\r
 }\r
 \r
        return(CurHost.UseMLSD);\r
 }\r
 \r
+// IPv6対応\r
+int AskCurNetType(void)\r
+{\r
+       return(CurHost.CurNetType);\r
+}\r
+\r
+// 自動切断対策\r
+int AskNoopInterval(void)\r
+{\r
+       return(CurHost.NoopInterval);\r
+}\r
+\r
+// 再転送対応\r
+int AskTransferErrorMode(void)\r
+{\r
+       return(CurHost.TransferErrorMode);\r
+}\r
+\r
+int AskTransferErrorNotify(void)\r
+{\r
+       return(CurHost.TransferErrorNotify);\r
+}\r
+\r