diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2011-05-14 09:48:42 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2011-05-14 09:48:42 -0700 |
commit | f53faffb91b7361634941774f5c395145ffcd944 (patch) | |
tree | 712ff71c73af830d246346388661f0a110149fea /src | |
parent | efe06e1efde6daf1ce1338ed39bd4b50acd29312 (diff) | |
parent | 545a679aed48ba4ad951056a6fad157b9f3729df (diff) |
Merge pull request #223 from sipa/dnslookup
bugfix in dnslookup code: didn't compile in mingw
Diffstat (limited to 'src')
-rw-r--r-- | src/net.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index b7cf973d41..018afc47c7 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -130,6 +130,8 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet) bool Lookup(const char *pszName, vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup, int portDefault, bool fAllowPort) { vaddr.clear(); + if (pszName[0] == 0) + return false; int port = portDefault; char psz[256]; char *pszHost = psz; @@ -155,11 +157,11 @@ bool Lookup(const char *pszName, vector<CAddress>& vaddr, int nServices, int nMa } } - struct in_addr addrIP; - if (inet_aton(pszHost, &addrIP)) + unsigned int addrIP = inet_addr(pszHost); + if (addrIP != INADDR_NONE) { // valid IP address passed - vaddr.push_back(CAddress(addrIP.s_addr, port, nServices)); + vaddr.push_back(CAddress(addrIP, port, nServices)); return true; } @@ -1524,7 +1526,7 @@ void StartNode(void* parg) if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) { vector<CAddress> vaddr; - if (NameLookup(pszHostName, vaddr, nLocalServices)) + if (Lookup(pszHostName, vaddr, nLocalServices, -1, true)) foreach (const CAddress &addr, vaddr) if (addr.GetByte(3) != 127) { |