X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fnetbase.cpp;h=54aa933a5426876f6efaa4374c7f64487359393c;hb=882164196e5b1971313493f95a6d027f05e2ec92;hp=34d58f90a366c0de22f623b1824a12617f809753;hpb=b24e6e4d1b917210b9e22711fb2535f53e949547;p=novacoin.git diff --git a/src/netbase.cpp b/src/netbase.cpp index 34d58f9..54aa933 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -25,7 +25,9 @@ static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0 bool static LookupIntern(const char *pszName, std::vector& vIP, int nMaxSolutions, bool fAllowLookup) { vIP.clear(); - struct addrinfo aiHint = {}; + struct addrinfo aiHint; + memset(&aiHint, 0, sizeof(struct addrinfo)); + aiHint.ai_socktype = SOCK_STREAM; aiHint.ai_protocol = IPPROTO_TCP; #ifdef WIN32 @@ -625,11 +627,12 @@ CService::CService(const char *pszIpPort, bool fAllowLookup) *this = ip; } -CService::CService(const char *pszIp, int portIn, bool fAllowLookup) +CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup) { - std::vector ip; - if (LookupHost(pszIp, ip, 1, fAllowLookup)) - *this = CService(ip[0], portIn); + Init(); + CService ip; + if (Lookup(pszIpPort, ip, portDefault, fAllowLookup)) + *this = ip; } CService::CService(const std::string &strIpPort, bool fAllowLookup) @@ -640,11 +643,12 @@ CService::CService(const std::string &strIpPort, bool fAllowLookup) *this = ip; } -CService::CService(const std::string &strIp, int portIn, bool fAllowLookup) +CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup) { - std::vector ip; - if (LookupHost(strIp.c_str(), ip, 1, fAllowLookup)) - *this = CService(ip[0], portIn); + Init(); + CService ip; + if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup)) + *this = ip; } unsigned short CService::GetPort() const