// IPv6対応\r
//#include <winsock.h>\r
#include <winsock2.h>\r
+// 切断対策\r
+#include <mstcpip.h>\r
#include <windowsx.h>\r
#include <commctrl.h>\r
\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
-static int SendInitCommand(char *Cmd);\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
extern int FwallType;\r
extern int FwallDefault;\r
extern int FwallSecurity;\r
-extern int FwallResolv;\r
+extern int FwallResolve;\r
extern int FwallLower;\r
extern int FwallDelimiter;\r
extern int PasvDefault;\r
extern int QuickAnonymous;\r
+// 切断対策\r
+extern int TimeOut;\r
+// UPnP対応\r
+extern int UPnPEnabled;\r
\r
/*===== ローカルなワーク =====*/\r
\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
+#if defined(HAVE_TANDEM)\r
+static int Oss = NO; /* OSS ファイルシステムへアクセスしている場合は YES */\r
+#endif\r
\r
\r
\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
+ SetHostEncryption(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
+ SetHostEncryption(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
+ SetHostEncryption(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
+ SetHostEncryption(AskCurrentHost(), NO, NO, NO, CurHost.UseSFTP);\r
}\r
break;\r
}\r
{\r
if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+ switch(CurHost.CurNameKanjiCode)\r
+ {\r
+ case KANJI_SJIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN346);\r
+ break;\r
+ case KANJI_JIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN347);\r
+ break;\r
+ case KANJI_EUC:\r
+ SetTaskMsg(MSGJPN344, MSGJPN348);\r
+ break;\r
+ case KANJI_UTF8N:\r
+ SetTaskMsg(MSGJPN344, MSGJPN349);\r
+ break;\r
+ case KANJI_UTF8HFSX:\r
+ SetTaskMsg(MSGJPN344, MSGJPN350);\r
+ break;\r
+ default:\r
+ SetTaskMsg(MSGJPN345);\r
+ break;\r
+ }\r
}\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(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+ switch(CurHost.CurNameKanjiCode)\r
+ {\r
+ case KANJI_SJIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN346);\r
+ break;\r
+ case KANJI_JIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN347);\r
+ break;\r
+ case KANJI_EUC:\r
+ SetTaskMsg(MSGJPN344, MSGJPN348);\r
+ break;\r
+ case KANJI_UTF8N:\r
+ SetTaskMsg(MSGJPN344, MSGJPN349);\r
+ break;\r
+ case KANJI_UTF8HFSX:\r
+ SetTaskMsg(MSGJPN344, MSGJPN350);\r
+ break;\r
+ default:\r
+ SetTaskMsg(MSGJPN345);\r
+ break;\r
+ }\r
}\r
\r
strcpy(TitleHostName, CurHost.HostAdrs);\r
EnableUserOpe();\r
\r
if(strlen(File) > 0)\r
- DirectDownLoadProc(File);\r
+ DirectDownloadProc(File);\r
}\r
else\r
{\r
{\r
if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+ switch(CurHost.CurNameKanjiCode)\r
+ {\r
+ case KANJI_SJIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN346);\r
+ break;\r
+ case KANJI_JIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN347);\r
+ break;\r
+ case KANJI_EUC:\r
+ SetTaskMsg(MSGJPN344, MSGJPN348);\r
+ break;\r
+ case KANJI_UTF8N:\r
+ SetTaskMsg(MSGJPN344, MSGJPN349);\r
+ break;\r
+ case KANJI_UTF8HFSX:\r
+ SetTaskMsg(MSGJPN344, MSGJPN350);\r
+ break;\r
+ default:\r
+ SetTaskMsg(MSGJPN345);\r
+ break;\r
+ }\r
}\r
\r
strcpy(TitleHostName, CurHost.HostAdrs);\r
EnableUserOpe();\r
\r
if(strlen(File) > 0)\r
- DirectDownLoadProc(File);\r
+ DirectDownloadProc(File);\r
else\r
ResetAutoExitFlg();\r
}\r
{\r
if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)\r
CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);\r
+ switch(CurHost.CurNameKanjiCode)\r
+ {\r
+ case KANJI_SJIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN346);\r
+ break;\r
+ case KANJI_JIS:\r
+ SetTaskMsg(MSGJPN344, MSGJPN347);\r
+ break;\r
+ case KANJI_EUC:\r
+ SetTaskMsg(MSGJPN344, MSGJPN348);\r
+ break;\r
+ case KANJI_UTF8N:\r
+ SetTaskMsg(MSGJPN344, MSGJPN349);\r
+ break;\r
+ case KANJI_UTF8HFSX:\r
+ SetTaskMsg(MSGJPN344, MSGJPN350);\r
+ break;\r
+ default:\r
+ SetTaskMsg(MSGJPN345);\r
+ break;\r
+ }\r
}\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
* 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
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
int AskHostNameKana(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
\r
- return(CurHost.NameKanaCnv);\r
+ // 同時接続対応\r
+// return(CurHost.NameKanaCnv);\r
+ return(TmpHost.NameKanaCnv);\r
}\r
\r
\r
\r
int AskListCmdMode(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(CurHost.HostType == HTYPE_VMS)\r
return(YES);\r
else\r
{\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
- return(CurHost.ListCmdOnly);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
+ // 同時接続対応\r
+// return(CurHost.ListCmdOnly);\r
+ return(TmpHost.ListCmdOnly);\r
}\r
}\r
\r
\r
int AskUseNLST_R(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
\r
- return(CurHost.UseNLST_R);\r
+ // 同時接続対応\r
+// return(CurHost.UseNLST_R);\r
+ return(TmpHost.UseNLST_R);\r
}\r
\r
\r
\r
char *AskHostChmodCmd(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
\r
- return(CurHost.ChmodCmd);\r
+ // 同時接続対応\r
+// return(CurHost.ChmodCmd);\r
+ return(TmpHost.ChmodCmd);\r
}\r
\r
\r
\r
int AskHostTimeZone(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
\r
- return(CurHost.TimeZone);\r
+ // 同時接続対応\r
+// return(CurHost.TimeZone);\r
+ return(TmpHost.TimeZone);\r
}\r
\r
\r
\r
char *AskHostLsName(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
\r
- return(CurHost.LsName);\r
+ // 同時接続対応\r
+// return(CurHost.LsName);\r
+ return(TmpHost.LsName);\r
}\r
\r
\r
\r
int AskHostType(void)\r
{\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
- CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\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
+// return(CurHost.HostType);\r
+ return(TmpHost.HostType);\r
}\r
\r
\r
int Host;\r
char LocDir[FMAX_PATH+1];\r
char HostDir[FMAX_PATH+1];\r
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
\r
if(TrnCtrlSocket != INVALID_SOCKET)\r
{\r
if((Host = AskCurrentHost()) != HOSTNUM_NOENTRY)\r
{\r
- CopyHostFromListInConnect(Host, &CurHost);\r
- if(CurHost.LastDir == YES)\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(Host, &CurHost);\r
+// if(CurHost.LastDir == YES)\r
+ CopyHostFromListInConnect(Host, &TmpHost);\r
+ if(TmpHost.LastDir == YES)\r
{\r
AskLocalCurDir(LocDir, FMAX_PATH);\r
AskRemoteCurDir(HostDir, FMAX_PATH);\r
int Sts;\r
\r
\r
- if(CmdCtrlSocket != TrnCtrlSocket)\r
- do_closesocket(TrnCtrlSocket);\r
- TrnCtrlSocket = INVALID_SOCKET;\r
+ // 同時接続対応\r
+// if(CmdCtrlSocket != TrnCtrlSocket)\r
+// do_closesocket(TrnCtrlSocket);\r
+// TrnCtrlSocket = INVALID_SOCKET;\r
+ if(CmdCtrlSocket == TrnCtrlSocket)\r
+ TrnCtrlSocket = INVALID_SOCKET;\r
\r
Sts = ReConnectSkt(&CmdCtrlSocket);\r
\r
- TrnCtrlSocket = CmdCtrlSocket;\r
+ // 同時接続対応\r
+// TrnCtrlSocket = CmdCtrlSocket;\r
+ if(TrnCtrlSocket == INVALID_SOCKET)\r
+ TrnCtrlSocket = CmdCtrlSocket;\r
\r
return(Sts);\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(&HostData, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, CancelCheckWork)) != INVALID_SOCKET)\r
{\r
+ SendInitCommand(*Skt, CurHost.InitCmd, CancelCheckWork);\r
// AskRemoteCurDir(Path, FMAX_PATH);\r
// DoCWD(Path, YES, YES, YES);\r
Sts = FFFTP_SUCCESS;\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, &CancelFlg)) != INVALID_SOCKET)\r
{\r
+ SendInitCommand(*Skt, CurHost.InitCmd, &CancelFlg);\r
AskRemoteCurDir(Path, FMAX_PATH);\r
DoCWD(Path, YES, YES, YES);\r
Sts = FFFTP_SUCCESS;\r
// ReConnectSkt(&CmdCtrlSocket);\r
if(CurHost.ReuseCmdSkt == YES)\r
{\r
+ CurHost.ReuseCmdSkt = NO;\r
CmdCtrlSocket = INVALID_SOCKET;\r
ReConnectSkt(&CmdCtrlSocket);\r
}\r
\r
if((CmdCtrlSocket != INVALID_SOCKET) && (CmdCtrlSocket != TrnCtrlSocket))\r
{\r
- DoQUIT(CmdCtrlSocket);\r
+ // 同時接続対応\r
+// DoQUIT(CmdCtrlSocket);\r
+ DoQUIT(CmdCtrlSocket, &CancelFlg);\r
DoClose(CmdCtrlSocket);\r
}\r
\r
if(TrnCtrlSocket != INVALID_SOCKET)\r
{\r
- DoQUIT(TrnCtrlSocket);\r
+ // 同時接続対応\r
+// DoQUIT(TrnCtrlSocket);\r
+ DoQUIT(TrnCtrlSocket, &CancelFlg);\r
DoClose(TrnCtrlSocket);\r
\r
SaveCurrentSetToHistory();\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
+ // 同時接続対応\r
+ HOSTDATA TmpHost;\r
+ TmpHost = CurHost;\r
+\r
+ if(AskCurrentHost() != HOSTNUM_NOENTRY)\r
+ // 同時接続対応\r
+// CopyHostFromListInConnect(AskCurrentHost(), &CurHost);\r
+ CopyHostFromListInConnect(AskCurrentHost(), &TmpHost);\r
+\r
+ // 同時接続対応\r
+// return(CurHost.HostType);\r
+ return(TmpHost.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
static const char *SiteTbl[4] = { "SITE", "site", "OPEN", "open" };\r
char TmpBuf[ONELINE_BUF_SIZE];\r
struct linger LingerOpt;\r
+ struct tcp_keepalive KeepAlive;\r
+ DWORD dwTmp;\r
\r
// 暗号化通信対応\r
ContSock = INVALID_SOCKET;\r
Flg = 1;\r
if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)\r
ReportWSError("setsockopt", WSAGetLastError());\r
+ // 切断対策\r
+ if(TimeOut > 0)\r
+ {\r
+ KeepAlive.onoff = 1;\r
+ KeepAlive.keepalivetime = TimeOut * 1000;\r
+ KeepAlive.keepaliveinterval = 1000;\r
+ if(WSAIoctl(ContSock, SIO_KEEPALIVE_VALS, &KeepAlive, sizeof(struct tcp_keepalive), NULL, 0, &dwTmp, NULL, NULL) == SOCKET_ERROR)\r
+ ReportWSError("WSAIoctl", WSAGetLastError());\r
+ }\r
LingerOpt.l_onoff = 1;\r
LingerOpt.l_linger = 90;\r
if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR)\r
// FTPES対応\r
if(CryptMode == CRYPT_FTPES)\r
{\r
- if(IsOpenSSLLoaded() && (Sts = command(ContSock, Reply, CancelCheckWork, "AUTH TLS")) == 234)\r
+ if(IsOpenSSLLoaded() && ((Sts = command(ContSock, Reply, CancelCheckWork, "AUTH TLS")) == 234 || (Sts = command(ContSock, Reply, CancelCheckWork, "AUTH SSL")) == 234))\r
{\r
if(AttachSSL(ContSock, INVALID_SOCKET, CancelCheckWork))\r
{\r
// IPv6対応\r
if(strstr(Reply, " EPRT ") || strstr(Reply, " EPSV "))\r
HostData->Feature |= FEATURE_EPRT | FEATURE_EPSV;\r
+ // ホスト側の日時取得\r
+ if(strstr(Reply, " MDTM "))\r
+ HostData->Feature |= FEATURE_MDTM;\r
+ // ホスト側の日時設定\r
+ if(strstr(Reply, " MFMT "))\r
+ HostData->Feature |= FEATURE_MFMT;\r
}\r
// UTF-8対応\r
if(HostData->CurNameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))\r
{\r
- if((Sts = command(ContSock, Reply, CancelCheckWork, "OPTS UTF8 ON")) == 200)\r
- HostData->CurNameKanjiCode = KANJI_UTF8N;\r
+ // UTF-8を指定した場合も自動判別を行う\r
+// if((Sts = command(ContSock, Reply, CancelCheckWork, "OPTS UTF8 ON")) == 200)\r
+// HostData->CurNameKanjiCode = KANJI_UTF8N;\r
+ command(ContSock, Reply, CancelCheckWork, "OPTS UTF8 ON");\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
SOCKET ContSock;\r
ContSock = INVALID_SOCKET;\r
*CancelCheckWork = NO;\r
-// if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)\r
-// {\r
-// SetTaskMsg(MSGJPN317);\r
-// if((ContSock = DoConnectCrypt(CRYPT_SFTP, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
-// HostData->CryptMode = CRYPT_SFTP;\r
-// }\r
+ if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)\r
+ {\r
+ SetTaskMsg(MSGJPN317);\r
+ if((ContSock = DoConnectCrypt(CRYPT_SFTP, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security, CancelCheckWork)) != INVALID_SOCKET)\r
+ HostData->CryptMode = CRYPT_SFTP;\r
+ }\r
if(*CancelCheckWork == NO && ContSock == INVALID_SOCKET && HostData->UseFTPIS == YES)\r
{\r
SetTaskMsg(MSGJPN316);\r
if((Type == MD4) || (Type == MD5) || (Type == SHA1))\r
{\r
/* シーケンス番号を見つけるループ */\r
- DoPrintf("Analize OTP");\r
+ DoPrintf("Analyze OTP");\r
DoPrintf("%s", Pos);\r
Sts = FFFTP_FAIL;\r
while((Pos = GetNextField(Pos)) != NULL)\r
*----------------------------------------------------------------------------*/\r
\r
// IPv6対応\r
+typedef SOCKET (__cdecl* LPCONNECTSOCK)(char*, int, char*, int*);\r
+\r
+typedef struct\r
+{\r
+ HANDLE h;\r
+ DWORD ExitCode;\r
+ char *host;\r
+ int port;\r
+ char *PreMsg;\r
+ int CancelCheckWork;\r
+ LPCONNECTSOCK f;\r
+ SOCKET s;\r
+} CONNECTSOCKDATA;\r
+\r
+DWORD WINAPI connectsockThreadProc(LPVOID lpParameter)\r
+{\r
+ CONNECTSOCKDATA* pData;\r
+ pData = (CONNECTSOCKDATA*)lpParameter;\r
+ pData->s = pData->f(pData->host, pData->port, pData->PreMsg, &pData->CancelCheckWork);\r
+ return 0;\r
+}\r
+\r
+// IPv6対応\r
SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
{\r
SOCKET Result;\r
+ CONNECTSOCKDATA DataIPv4;\r
+ CONNECTSOCKDATA DataIPv6;\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
+// 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
+ DataIPv4.host = host;\r
+ DataIPv4.port = port;\r
+ DataIPv4.PreMsg = PreMsg;\r
+ DataIPv4.CancelCheckWork = *CancelCheckWork;\r
+ DataIPv4.f = connectsockIPv4;\r
+ DataIPv4.h = CreateThread(NULL, 0, connectsockThreadProc, &DataIPv4, 0, NULL);\r
+ DataIPv6.host = host;\r
+ DataIPv6.port = port;\r
+ DataIPv6.PreMsg = PreMsg;\r
+ DataIPv6.CancelCheckWork = *CancelCheckWork;\r
+ DataIPv6.f = connectsockIPv6;\r
+ DataIPv6.h = CreateThread(NULL, 0, connectsockThreadProc, &DataIPv6, 0, NULL);\r
+ while(1)\r
+ {\r
+ if(GetExitCodeThread(DataIPv4.h, &DataIPv4.ExitCode))\r
+ {\r
+ if(DataIPv4.ExitCode != STILL_ACTIVE)\r
+ {\r
+ if(DataIPv4.s != INVALID_SOCKET)\r
+ {\r
+ Result = DataIPv4.s;\r
+ CurHost.CurNetType = NTYPE_IPV4;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if(GetExitCodeThread(DataIPv6.h, &DataIPv6.ExitCode))\r
+ {\r
+ if(DataIPv6.ExitCode != STILL_ACTIVE)\r
+ {\r
+ if(DataIPv6.s != INVALID_SOCKET)\r
+ {\r
+ Result = DataIPv6.s;\r
+ CurHost.CurNetType = NTYPE_IPV6;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if(GetExitCodeThread(DataIPv4.h, &DataIPv4.ExitCode) && GetExitCodeThread(DataIPv6.h, &DataIPv6.ExitCode))\r
+ {\r
+ if(DataIPv4.ExitCode != STILL_ACTIVE && DataIPv6.ExitCode != STILL_ACTIVE)\r
+ {\r
+ if(DataIPv4.s == INVALID_SOCKET && DataIPv6.s == INVALID_SOCKET)\r
+ break;\r
+ }\r
+ }\r
+ DataIPv4.CancelCheckWork = *CancelCheckWork;\r
+ DataIPv6.CancelCheckWork = *CancelCheckWork;\r
+ BackgrndMessageProc();\r
+ Sleep(1);\r
+ }\r
+ while(1)\r
+ {\r
+ if(GetExitCodeThread(DataIPv4.h, &DataIPv4.ExitCode) && GetExitCodeThread(DataIPv6.h, &DataIPv6.ExitCode))\r
+ {\r
+ if(DataIPv4.ExitCode != STILL_ACTIVE && DataIPv6.ExitCode != STILL_ACTIVE)\r
+ {\r
+ CloseHandle(DataIPv4.h);\r
+ CloseHandle(DataIPv6.h);\r
+ break;\r
+ }\r
+ }\r
+ DataIPv4.CancelCheckWork = YES;\r
+ DataIPv6.CancelCheckWork = YES;\r
+ BackgrndMessageProc();\r
+ Sleep(1);\r
+ }\r
break;\r
case NTYPE_IPV4:\r
Result = connectsockIPv4(host, port, PreMsg, CancelCheckWork);\r
//SOCKET connectsock(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
SOCKET connectsockIPv4(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
{\r
+ // IPv6対応\r
+ struct sockaddr_in SocksSockAddr; /* SOCKSサーバのアドレス情報 */\r
+ struct sockaddr_in CurSockAddr; /* 接続先ホストのアドレス情報 */\r
struct sockaddr_in saSockAddr;\r
char HostEntry[MAXGETHOSTSTRUCT];\r
struct hostent *pHostEntry;\r
\r
UseIPadrs = YES;\r
strcpy(DomainName, host);\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
+ 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
{\r
// ホスト名が指定された\r
// ホスト名からアドレスを求める\r
if(((Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER)) &&\r
- (FwallResolv == YES))\r
+ (FwallResolve == YES))\r
{\r
// ホスト名解決はSOCKSサーバに任せる\r
pHostEntry = NULL;\r
else\r
{\r
// アドレスを取得\r
- SetTaskMsg(MSGJPN016, DomainName);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN016, DomainName);\r
+ SetTaskMsg(MSGJPN016, DomainName, MSGJPN333);\r
// IPv6対応\r
// pHostEntry = do_gethostbyname(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
pHostEntry = do_gethostbynameIPv4(host, HostEntry, MAXGETHOSTSTRUCT, CancelCheckWork);\r
\r
if(pHostEntry != NULL)\r
{\r
+ memcpy((char *)&CurSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\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
+ SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port), MSGJPN333);\r
}\r
else\r
{\r
UseIPadrs = NO;\r
// IPv6対応\r
// SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port));\r
- SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddrIPv4.sin_port));\r
+ SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin_port), MSGJPN333);\r
}\r
else\r
{\r
- SetTaskMsg(MSGJPN019, host);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN019, host);\r
+ SetTaskMsg(MSGJPN019, host, MSGJPN333);\r
return(INVALID_SOCKET);\r
}\r
}\r
else\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
+ SetTaskMsg(MSGJPN020, PreMsg, inet_ntoa(CurSockAddr.sin_addr), ntohs(CurSockAddr.sin_port), MSGJPN333);\r
\r
if((Fwall == FWALL_SOCKS4) || (Fwall == FWALL_SOCKS5_NOAUTH) || (Fwall == FWALL_SOCKS5_USER))\r
{\r
{\r
Socks4Cmd.Ver = SOCKS4_VER;\r
Socks4Cmd.Cmd = SOCKS4_CMD_CONNECT;\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
+ Socks4Cmd.Port = CurSockAddr.sin_port;\r
+ Socks4Cmd.AdrsInt = CurSockAddr.sin_addr.s_addr;\r
strcpy(Socks4Cmd.UserID, FwallUser);\r
Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
}\r
else\r
{\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
+ Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
}\r
\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
+ memset(&SocksSockAddr, 0, sizeof(SocksSockAddr));\r
+ if((SocksSockAddr.sin_addr.s_addr = inet_addr(FwallHost)) == INADDR_NONE)\r
{\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
+ memcpy((char *)&SocksSockAddr.sin_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
else\r
{\r
- SetTaskMsg(MSGJPN021, FwallHost);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN021, FwallHost);\r
+ SetTaskMsg(MSGJPN021, FwallHost, MSGJPN333);\r
return INVALID_SOCKET;\r
}\r
}\r
+ SocksSockAddr.sin_port = htons((u_short)FwallPort);\r
+ SocksSockAddr.sin_family = AF_INET;\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
+ SetTaskMsg(MSGJPN022, inet_ntoa(SocksSockAddr.sin_addr), ntohs(SocksSockAddr.sin_port), MSGJPN333);\r
// connectで接続する先はSOCKSサーバ\r
- // IPv6対応\r
-// memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
- memcpy(&saSockAddr, &SocksSockAddrIPv4, sizeof(SocksSockAddrIPv4));\r
+ memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
}\r
else\r
{\r
// connectで接続するのは接続先のホスト\r
- // IPv6対応\r
-// memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\r
- memcpy(&saSockAddr, &CurSockAddrIPv4, sizeof(CurSockAddrIPv4));\r
+ memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\r
}\r
\r
/////////////\r
\r
if((sSocket = do_socket(AF_INET, SOCK_STREAM, TCP_PORT)) != INVALID_SOCKET)\r
{\r
+ // ソケットにデータを付与\r
+ SetAsyncTableDataIPv4(sSocket, &CurSockAddr, &SocksSockAddr);\r
if(do_connect(sSocket, (struct sockaddr *)&saSockAddr, sizeof(saSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
{\r
if(Fwall == FWALL_SOCKS4)\r
(Socks4GetCmdReply(sSocket, &Socks4Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
(Socks4Reply.Result != SOCKS4_RES_OK))\r
{\r
- SetTaskMsg(MSGJPN023, Socks4Reply.Result);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN023, Socks4Reply.Result);\r
+ SetTaskMsg(MSGJPN023, Socks4Reply.Result, MSGJPN333);\r
DoClose(sSocket);\r
sSocket = INVALID_SOCKET;\r
}\r
(Socks5GetCmdReply(sSocket, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
(Socks5Reply.Result != SOCKS5_RES_OK))\r
{\r
- SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
+ SetTaskMsg(MSGJPN024, Socks5Reply.Result, MSGJPN333);\r
DoClose(sSocket);\r
sSocket = INVALID_SOCKET;\r
}\r
}\r
\r
if(sSocket != INVALID_SOCKET)\r
- SetTaskMsg(MSGJPN025);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN025);\r
+ SetTaskMsg(MSGJPN025, MSGJPN333);\r
}\r
else\r
{\r
//#pragma aaa\r
- SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/);\r
+ SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/, MSGJPN333);\r
DoClose(sSocket);\r
sSocket = INVALID_SOCKET;\r
}\r
}\r
else\r
- SetTaskMsg(MSGJPN027);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN027);\r
+ SetTaskMsg(MSGJPN027, MSGJPN333);\r
\r
return(sSocket);\r
}\r
\r
SOCKET connectsockIPv6(char *host, int port, char *PreMsg, int *CancelCheckWork)\r
{\r
+ struct sockaddr_in6 SocksSockAddr; /* SOCKSサーバのアドレス情報 */\r
+ struct sockaddr_in6 CurSockAddr; /* 接続先ホストのアドレス情報 */\r
struct sockaddr_in6 saSockAddr;\r
char HostEntry[MAXGETHOSTSTRUCT];\r
struct hostent *pHostEntry;\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
+ memset(&CurSockAddr, 0, sizeof(CurSockAddr));\r
+ CurSockAddr.sin6_port = htons((u_short)port);\r
+ CurSockAddr.sin6_family = AF_INET6;\r
+ CurSockAddr.sin6_addr = inet6_addr(host);\r
+ if(memcmp(&CurSockAddr.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
+ (FwallResolve == YES))\r
{\r
// ホスト名解決はSOCKSサーバに任せる\r
pHostEntry = NULL;\r
else\r
{\r
// アドレスを取得\r
- SetTaskMsg(MSGJPN016, DomainName);\r
+ SetTaskMsg(MSGJPN016, DomainName, MSGJPN334);\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
+ memcpy((char *)&CurSockAddr.sin6_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
+ SetTaskMsg(MSGJPN017, PreMsg, DomainName, inet6_ntoa(CurSockAddr.sin6_addr), ntohs(CurSockAddr.sin6_port), MSGJPN334);\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
+ SetTaskMsg(MSGJPN018, PreMsg, DomainName, ntohs(CurSockAddr.sin6_port), MSGJPN334);\r
}\r
else\r
{\r
- SetTaskMsg(MSGJPN019, host);\r
+ SetTaskMsg(MSGJPN019, host, MSGJPN334);\r
return(INVALID_SOCKET);\r
}\r
}\r
}\r
else\r
- SetTaskMsg(MSGJPN020, PreMsg, inet6_ntoa(CurSockAddrIPv6.sin6_addr), ntohs(CurSockAddrIPv6.sin6_port));\r
+ SetTaskMsg(MSGJPN020, PreMsg, inet6_ntoa(CurSockAddr.sin6_addr), ntohs(CurSockAddr.sin6_port), MSGJPN334);\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
+ Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_CONNECT, UseIPadrs, (char*)&CurSockAddr.sin6_addr, DomainName, CurSockAddr.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
+ memset(&SocksSockAddr, 0, sizeof(SocksSockAddr));\r
+ SocksSockAddr.sin6_addr = inet6_addr(FwallHost);\r
+ if(memcmp(&SocksSockAddr.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
+ memcpy((char *)&SocksSockAddr.sin6_addr, pHostEntry->h_addr, pHostEntry->h_length);\r
else\r
{\r
- SetTaskMsg(MSGJPN021, FwallHost);\r
+ SetTaskMsg(MSGJPN021, FwallHost, MSGJPN334);\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
+ SocksSockAddr.sin6_port = htons((u_short)FwallPort);\r
+ SocksSockAddr.sin6_family = AF_INET6;\r
+ SetTaskMsg(MSGJPN022, inet6_ntoa(SocksSockAddr.sin6_addr), ntohs(SocksSockAddr.sin6_port), MSGJPN334);\r
// connectで接続する先はSOCKSサーバ\r
- memcpy(&saSockAddr, &SocksSockAddrIPv6, sizeof(SocksSockAddrIPv6));\r
+ memcpy(&saSockAddr, &SocksSockAddr, sizeof(SocksSockAddr));\r
}\r
else\r
{\r
// connectで接続するのは接続先のホスト\r
- memcpy(&saSockAddr, &CurSockAddrIPv6, sizeof(CurSockAddrIPv6));\r
+ memcpy(&saSockAddr, &CurSockAddr, sizeof(CurSockAddr));\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
+ // ソケットにデータを付与\r
+ SetAsyncTableDataIPv6(sSocket, &CurSockAddr, &SocksSockAddr);\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
(Socks5GetCmdReply(sSocket, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
(Socks5Reply.Result != SOCKS5_RES_OK))\r
{\r
- SetTaskMsg(MSGJPN024, Socks5Reply.Result);\r
+ SetTaskMsg(MSGJPN024, Socks5Reply.Result, MSGJPN334);\r
DoClose(sSocket);\r
sSocket = INVALID_SOCKET;\r
}\r
}\r
\r
if(sSocket != INVALID_SOCKET)\r
- SetTaskMsg(MSGJPN025);\r
+ SetTaskMsg(MSGJPN025, MSGJPN334);\r
}\r
else\r
{\r
//#pragma aaa\r
- SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/);\r
+ SetTaskMsg(MSGJPN026/*"接続できません(2) %x", sSocket*/, MSGJPN334);\r
DoClose(sSocket);\r
sSocket = INVALID_SOCKET;\r
}\r
}\r
else\r
- SetTaskMsg(MSGJPN027);\r
+ SetTaskMsg(MSGJPN027, MSGJPN334);\r
\r
return(sSocket);\r
}\r
//SOCKET GetFTPListenSocket(SOCKET ctrl_skt, int *CancelCheckWork)\r
SOCKET GetFTPListenSocketIPv4(SOCKET ctrl_skt, int *CancelCheckWork)\r
{\r
+ // IPv6対応\r
+ struct sockaddr_in SocksSockAddr; /* SOCKSサーバのアドレス情報 */\r
+ struct sockaddr_in CurSockAddr; /* 接続先ホストのアドレス情報 */\r
SOCKET listen_skt;\r
int iLength;\r
char *a,*p;\r
int Len;\r
int Fwall;\r
\r
+ // UPnP対応\r
+ char Adrs[16];\r
+ int Port;\r
+\r
+ // ソケットにデータを付与\r
+ GetAsyncTableDataIPv4(ctrl_skt, &CurSockAddr, &SocksSockAddr);\r
+\r
Fwall = FWALL_NONE;\r
if(AskHostFireWall() == YES)\r
Fwall = FwallType;\r
{\r
/*===== SOCKS4を使う =====*/\r
DoPrintf("Use SOCKS4 BIND");\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
+ if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
{\r
Socks4Cmd.Ver = SOCKS4_VER;\r
Socks4Cmd.Cmd = SOCKS4_CMD_BIND;\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
+ Socks4Cmd.Port = CurSockAddr.sin_port;\r
+ Socks4Cmd.AdrsInt = CurSockAddr.sin_addr.s_addr;\r
strcpy(Socks4Cmd.UserID, FwallUser);\r
Len = offsetof(SOCKS4CMD, UserID) + strlen(FwallUser) + 1;\r
\r
(Socks4GetCmdReply(listen_skt, &Socks4Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
(Socks4Reply.Result != SOCKS4_RES_OK))\r
{\r
- SetTaskMsg(MSGJPN028, Socks4Reply.Result);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN028, Socks4Reply.Result);\r
+ SetTaskMsg(MSGJPN028, Socks4Reply.Result, MSGJPN333);\r
DoClose(listen_skt);\r
listen_skt = INVALID_SOCKET;\r
}\r
\r
if(Socks4Reply.AdrsInt == 0)\r
- // IPv6対応\r
-// Socks4Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
- Socks4Reply.AdrsInt = SocksSockAddrIPv4.sin_addr.s_addr;\r
+ Socks4Reply.AdrsInt = SocksSockAddr.sin_addr.s_addr;\r
\r
a = (char *)&Socks4Reply.AdrsInt;\r
p = (char *)&Socks4Reply.Port;\r
{\r
/*===== SOCKS5を使う =====*/\r
DoPrintf("Use SOCKS5 BIND");\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
+ if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
{\r
if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
{\r
return(listen_skt);\r
}\r
\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
+ Len = Socks5MakeCmdPacket(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, CurSockAddr.sin_addr.s_addr, DomainName, CurSockAddr.sin_port);\r
\r
Socks5Reply.Result = -1;\r
// 同時接続対応\r
(Socks5GetCmdReply(listen_skt, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
(Socks5Reply.Result != SOCKS5_RES_OK))\r
{\r
- SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
+ SetTaskMsg(MSGJPN029, Socks5Reply.Result, MSGJPN333);\r
DoClose(listen_skt);\r
listen_skt = INVALID_SOCKET;\r
}\r
\r
a = (char *)&saTmpAddr.sin_addr;\r
p = (char *)&saCtrlAddr.sin_port;\r
+ // UPnP対応\r
+ if(IsUPnPLoaded() == YES && UPnPEnabled == YES)\r
+ {\r
+ if(AddPortMapping(AddressToStringIPv4(Adrs, &saTmpAddr.sin_addr), ntohs(saCtrlAddr.sin_port)) == FFFTP_SUCCESS)\r
+ SetAsyncTableDataMapPort(listen_skt, ntohs(saCtrlAddr.sin_port));\r
+ }\r
}\r
else\r
{\r
}\r
\r
if(listen_skt == INVALID_SOCKET)\r
- SetTaskMsg(MSGJPN030);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN030);\r
+ SetTaskMsg(MSGJPN030, MSGJPN333);\r
}\r
}\r
else\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
- SetTaskMsg(MSGJPN031);\r
+ // IPv6対応\r
+// SetTaskMsg(MSGJPN031);\r
+ SetTaskMsg(MSGJPN031, MSGJPN333);\r
+ // UPnP対応\r
+ if(IsUPnPLoaded() == YES)\r
+ {\r
+ if(GetAsyncTableDataMapPort(listen_skt, &Port) == YES)\r
+ RemovePortMapping(Port);\r
+ }\r
do_closesocket(listen_skt);\r
listen_skt = INVALID_SOCKET;\r
}\r
\r
SOCKET GetFTPListenSocketIPv6(SOCKET ctrl_skt, int *CancelCheckWork)\r
{\r
+ struct sockaddr_in6 SocksSockAddr; /* SOCKSサーバのアドレス情報 */\r
+ struct sockaddr_in6 CurSockAddr; /* 接続先ホストのアドレス情報 */\r
SOCKET listen_skt;\r
int iLength;\r
char *a,*p;\r
int Fwall;\r
\r
char Adrs[40];\r
+ // UPnP対応\r
+ int Port;\r
+\r
+ // ソケットにデータを付与\r
+ GetAsyncTableDataIPv6(ctrl_skt, &CurSockAddr, &SocksSockAddr);\r
\r
Fwall = FWALL_NONE;\r
if(AskHostFireWall() == YES)\r
{\r
/*===== SOCKS5を使う =====*/\r
DoPrintf("Use SOCKS5 BIND");\r
- if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddrIPv6, sizeof(SocksSockAddrIPv6), CancelCheckWork) != SOCKET_ERROR)\r
+ if(do_connect(listen_skt, (struct sockaddr *)&SocksSockAddr, sizeof(SocksSockAddr), CancelCheckWork) != SOCKET_ERROR)\r
{\r
if(Socks5SelMethod(listen_skt, CancelCheckWork) == FFFTP_FAIL)\r
{\r
return(listen_skt);\r
}\r
\r
- Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, (char*)&CurSockAddrIPv6.sin6_addr, DomainName, CurSockAddrIPv6.sin6_port);\r
+ Len = Socks5MakeCmdPacketIPv6(&Socks5Cmd, SOCKS5_CMD_BIND, UseIPadrs, (char*)&CurSockAddr.sin6_addr, DomainName, CurSockAddr.sin6_port);\r
\r
Socks5Reply.Result = -1;\r
// 同時接続対応\r
(Socks5GetCmdReply(listen_skt, &Socks5Reply, CancelCheckWork) != FFFTP_SUCCESS) || \r
(Socks5Reply.Result != SOCKS5_RES_OK))\r
{\r
- SetTaskMsg(MSGJPN029, Socks5Reply.Result);\r
+ SetTaskMsg(MSGJPN029, Socks5Reply.Result, MSGJPN334);\r
DoClose(listen_skt);\r
listen_skt = INVALID_SOCKET;\r
}\r
\r
a = (char *)&saTmpAddr.sin6_addr;\r
p = (char *)&saCtrlAddr.sin6_port;\r
+ // UPnP対応\r
+ if(IsUPnPLoaded() == YES && UPnPEnabled == YES)\r
+ {\r
+ if(AddPortMapping(AddressToStringIPv6(Adrs, &saTmpAddr.sin6_addr), ntohs(saCtrlAddr.sin6_port)) == FFFTP_SUCCESS)\r
+ SetAsyncTableDataMapPort(listen_skt, ntohs(saCtrlAddr.sin6_port));\r
+ }\r
}\r
else\r
{\r
}\r
\r
if(listen_skt == INVALID_SOCKET)\r
- SetTaskMsg(MSGJPN030);\r
+ SetTaskMsg(MSGJPN030, MSGJPN334);\r
}\r
}\r
else\r
AddressToStringIPv6(Adrs, a),\r
(UC(p[0]) << 8) | UC(p[1])) / 100) != FTP_COMPLETE)\r
{\r
- SetTaskMsg(MSGJPN031);\r
+ SetTaskMsg(MSGJPN031, MSGJPN334);\r
+ // UPnP対応\r
+ if(IsUPnPLoaded() == YES)\r
+ {\r
+ if(GetAsyncTableDataMapPort(listen_skt, &Port) == YES)\r
+ RemovePortMapping(Port);\r
+ }\r
do_closesocket(listen_skt);\r
listen_skt = INVALID_SOCKET;\r
}\r
return(CurHost.TransferErrorNotify);\r
}\r
\r
+// セッションあたりの転送量制限対策\r
+int AskErrorReconnect(void)\r
+{\r
+ return(CurHost.TransferErrorReconnect);\r
+}\r
+\r