Browse Source

links

pull/1/head
Pieter Wuille 13 years ago
parent
commit
adc55f0b36
  1. 37
      netbase.cpp
  2. 2
      protocol.cpp

37
netbase.cpp

@ -183,11 +183,7 @@ 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)
addrProxy.GetSockAddr(&sockaddr);
else
GetSockAddr(&sockaddr); GetSockAddr(&sockaddr);
#ifdef WIN32 #ifdef WIN32
@ -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;
} }

2
protocol.cpp

@ -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…
Cancel
Save