svnno****@sourc*****
svnno****@sourc*****
2011年 2月 28日 (月) 16:22:11 JST
Revision: 4349 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4349 Author: doda Date: 2011-02-28 16:22:11 +0900 (Mon, 28 Feb 2011) Log Message: ----------- New Connection ダイアログでプロトコルを UNSPEC 以外にした場合は、プロキシへの接続は指定されたプロトコルのみを使うようにした。 Modified Paths: -------------- trunk/TTProxy/ProxyWSockHook.h -------------- next part -------------- Modified: trunk/TTProxy/ProxyWSockHook.h =================================================================== --- trunk/TTProxy/ProxyWSockHook.h 2011-02-28 05:18:57 UTC (rev 4348) +++ trunk/TTProxy/ProxyWSockHook.h 2011-02-28 07:22:11 UTC (rev 4349) @@ -49,6 +49,7 @@ private: struct DUMMYHOSTENT { struct hostent entry; + struct addrinfo *ai; struct addrinfo ainfo[2]; in_addr addr; struct in6_addr addr6; @@ -483,6 +484,9 @@ fillBuffer(buffer, bufferLength, "ssh"); } void fillBuffer(char* buffer, int bufferLength, const char *portname) { + fillBuffer(buffer, bufferLength, "ssh", AF_UNSPEC); + } + void fillBuffer(char* buffer, int bufferLength, const char *portname, int addr_family) { struct servent *sv; int portnum = 0; if (sv = getservbyname(portname, "tcp")) { @@ -521,7 +525,7 @@ dst->ainfo[0].ai_addrlen = sizeof(sockaddr_in6); dst->ainfo[0].ai_canonname = NULL; dst->ainfo[0].ai_addr = (struct sockaddr *)(&dst->saddr6); - dst->ainfo[0].ai_next = &dst->ainfo[1]; + dst->ainfo[0].ai_next = NULL; dst->ainfo[1].ai_flags = 0; dst->ainfo[1].ai_family = AF_INET; @@ -532,6 +536,20 @@ dst->ainfo[1].ai_addr = (struct sockaddr *)(&dst->saddr); dst->ainfo[1].ai_next = NULL; + switch (addr_family) { + case AF_INET: + dst->ai = &dst->ainfo[1]; + break; + case AF_INET6: + dst->ai = &dst->ainfo[0]; + break; + case AF_UNSPEC: + default: + dst->ainfo[0].ai_next = &dst->ainfo[1]; + dst->ai = &dst->ainfo[0]; + break; + } + strcpy_s(dst->hostname, bufferLength - sizeof (DUMMYHOSTENT), realhost); } }; @@ -2042,11 +2060,11 @@ HANDLE handle = connectioninfolist.getTask(info); int bufferLength = sizeof (DUMMYHOSTENT) + strlen(hostname) + 1; info->buffer = new char[bufferLength]; - info->fillBuffer(info->buffer, bufferLength, portname); + info->fillBuffer(info->buffer, bufferLength, portname, hints->ai_family); DUMMYHOSTENT* d = (DUMMYHOSTENT*)info->buffer; - *res = d->ainfo; + *res = d->ai; if (aicount < 256) { - ailist[aicount++] = d->ainfo; + ailist[aicount++] = d->ai; } ::PostMessage(window, message, (WPARAM) handle, MAKELPARAM(0, 0)); return handle;