diff options
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index 08d133740a..360ecdd959 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -9,12 +9,16 @@ #include "hash.h" #ifndef WIN32 -#include <sys/fcntl.h> +#include <fcntl.h> #endif #include <boost/algorithm/string/case_conv.hpp> // for to_lower() #include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith() +#if !defined(HAVE_MSG_NOSIGNAL) +#define MSG_NOSIGNAL 0 +#endif + using namespace std; // Settings @@ -165,7 +169,7 @@ bool LookupNumeric(const char *pszName, CService& addr, int portDefault) bool static Socks4(const CService &addrDest, SOCKET& hSocket) { - printf("SOCKS4 connecting %s\n", addrDest.ToString().c_str()); + LogPrintf("SOCKS4 connecting %s\n", addrDest.ToString().c_str()); if (!addrDest.IsIPv4()) { closesocket(hSocket); @@ -200,16 +204,16 @@ bool static Socks4(const CService &addrDest, SOCKET& hSocket) { closesocket(hSocket); if (pchRet[1] != 0x5b) - printf("ERROR: Proxy returned error %d\n", pchRet[1]); + LogPrintf("ERROR: Proxy returned error %d\n", pchRet[1]); return false; } - printf("SOCKS4 connected %s\n", addrDest.ToString().c_str()); + LogPrintf("SOCKS4 connected %s\n", addrDest.ToString().c_str()); return true; } bool static Socks5(string strDest, int port, SOCKET& hSocket) { - printf("SOCKS5 connecting %s\n", strDest.c_str()); + LogPrintf("SOCKS5 connecting %s\n", strDest.c_str()); if (strDest.size() > 255) { closesocket(hSocket); @@ -305,7 +309,7 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket) closesocket(hSocket); return error("Error reading from proxy"); } - printf("SOCKS5 connected %s\n", strDest.c_str()); + LogPrintf("SOCKS5 connected %s\n", strDest.c_str()); return true; } @@ -320,7 +324,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe #endif socklen_t len = sizeof(sockaddr); if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { - printf("Cannot connect to %s: unsupported network\n", addrConnect.ToString().c_str()); + LogPrintf("Cannot connect to %s: unsupported network\n", addrConnect.ToString().c_str()); return false; } @@ -359,13 +363,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); if (nRet == 0) { - printf("connection timeout\n"); + LogPrint("net", "connection timeout\n"); closesocket(hSocket); return false; } if (nRet == SOCKET_ERROR) { - printf("select() for connection failed: %i\n",WSAGetLastError()); + LogPrintf("select() for connection failed: %i\n",WSAGetLastError()); closesocket(hSocket); return false; } @@ -376,13 +380,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) #endif { - printf("getsockopt() for connection failed: %i\n",WSAGetLastError()); + LogPrintf("getsockopt() for connection failed: %i\n",WSAGetLastError()); closesocket(hSocket); return false; } if (nRet != 0) { - printf("connect() failed after select(): %s\n",strerror(nRet)); + LogPrintf("connect() failed after select(): %s\n",strerror(nRet)); closesocket(hSocket); return false; } @@ -393,7 +397,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe else #endif { - printf("connect() failed: %i\n",WSAGetLastError()); + LogPrintf("connect() failed: %i\n",WSAGetLastError()); closesocket(hSocket); return false; } @@ -860,7 +864,7 @@ std::vector<unsigned char> CNetAddr::GetGroup() const nBits = 4; } // for he.net, use /36 groups - else if (GetByte(15) == 0x20 && GetByte(14) == 0x11 && GetByte(13) == 0x04 && GetByte(12) == 0x70) + else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70) nBits = 36; // for the rest of the IPv6 network, use /32 groups else @@ -889,7 +893,7 @@ uint64 CNetAddr::GetHash() const void CNetAddr::print() const { - printf("CNetAddr(%s)\n", ToString().c_str()); + LogPrintf("CNetAddr(%s)\n", ToString().c_str()); } // private extensions to enum Network, only returned by GetExtNetwork, @@ -1130,7 +1134,7 @@ std::string CService::ToString() const void CService::print() const { - printf("CService(%s)\n", ToString().c_str()); + LogPrintf("CService(%s)\n", ToString().c_str()); } void CService::SetPort(unsigned short portIn) |