links
This commit is contained in:
parent
8e95f6442a
commit
adc55f0b36
2 changed files with 3 additions and 38 deletions
39
netbase.cpp
39
netbase.cpp
|
@ -183,12 +183,8 @@ bool CIPPort::ConnectSocket(SOCKET& hSocketRet, int nTimeout) const
|
||||||
setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));
|
setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool fProxy = (fUseProxy && IsRoutable());
|
|
||||||
struct sockaddr_in sockaddr;
|
struct sockaddr_in sockaddr;
|
||||||
if (fProxy)
|
GetSockAddr(&sockaddr);
|
||||||
addrProxy.GetSockAddr(&sockaddr);
|
|
||||||
else
|
|
||||||
GetSockAddr(&sockaddr);
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
u_long fNonblock = 1;
|
u_long fNonblock = 1;
|
||||||
|
@ -273,39 +269,6 @@ bool CIPPort::ConnectSocket(SOCKET& hSocketRet, int nTimeout) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fProxy)
|
|
||||||
{
|
|
||||||
printf("proxy connecting %s\n", ToString().c_str());
|
|
||||||
char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
GetSockAddr(&addr);
|
|
||||||
memcpy(pszSocks4IP + 2, &addr.sin_port, 2);
|
|
||||||
memcpy(pszSocks4IP + 4, &addr.sin_addr, 4);
|
|
||||||
char* pszSocks4 = pszSocks4IP;
|
|
||||||
int nSize = sizeof(pszSocks4IP);
|
|
||||||
|
|
||||||
int ret = send(hSocket, pszSocks4, nSize, MSG_NOSIGNAL);
|
|
||||||
if (ret != nSize)
|
|
||||||
{
|
|
||||||
closesocket(hSocket);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char pchRet[8];
|
|
||||||
if (recv(hSocket, pchRet, 8, 0) != 8)
|
|
||||||
{
|
|
||||||
closesocket(hSocket);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (pchRet[1] != 0x5a)
|
|
||||||
{
|
|
||||||
closesocket(hSocket);
|
|
||||||
if (pchRet[1] != 0x5b)
|
|
||||||
printf("ERROR: Proxy returned error %d\n", pchRet[1]);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
printf("proxy connected %s\n", ToString().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
hSocketRet = hSocket;
|
hSocketRet = hSocket;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ static const char* ppszTypeName[] =
|
||||||
"block",
|
"block",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };
|
||||||
|
|
||||||
CMessageHeader::CMessageHeader()
|
CMessageHeader::CMessageHeader()
|
||||||
{
|
{
|
||||||
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
|
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
|
||||||
|
|
Loading…
Reference in a new issue