diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2016-05-31 13:51:11 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2016-07-31 13:24:07 -0400 |
commit | f96c7c4d91f3c09d26658bc9c15aa561689fa2d4 (patch) | |
tree | 4fc6bff63eff752e4791ae3fb64de77b427afeee /src/net.cpp | |
parent | 31d6b1d5f0414d8b356d8cb9c99961d8a04d6c0a (diff) |
net: Split resolving out of CService
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp index 8725346fe8..e44bdafc79 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -175,7 +175,7 @@ static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn // one by discovery. CAddress GetLocalAddress(const CNetAddr *paddrPeer) { - CAddress ret(CService("0.0.0.0",GetListenPort()), NODE_NONE); + CAddress ret(CService(CNetAddr(),GetListenPort()), NODE_NONE); CService addr; if (GetLocal(addr, paddrPeer)) { @@ -494,7 +494,7 @@ void CNode::PushVersion() int nBestHeight = GetNodeSignals().GetHeight().get_value_or(0); int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime()); - CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0", 0), addr.nServices)); + CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService(), addr.nServices)); CAddress addrMe = GetLocalAddress(&addr); GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); if (fLogIPs) @@ -1727,7 +1727,8 @@ std::vector<AddedNodeInfo> GetAddedNodeInfo() } BOOST_FOREACH(const std::string& strAddNode, lAddresses) { - CService service(strAddNode, Params().GetDefaultPort()); + CService service; + LookupNumeric(strAddNode.c_str(), service, Params().GetDefaultPort()); if (service.IsValid()) { // strAddNode is an IP:port auto it = mapConnected.find(service); @@ -1765,7 +1766,8 @@ void ThreadOpenAddedConnections() CSemaphoreGrant grant(*semOutbound); // If strAddedNode is an IP/port, decode it immediately, so // OpenNetworkConnection can detect existing connections to that IP/port. - CService service(info.strAddedNode, Params().GetDefaultPort()); + CService service; + LookupNumeric(info.strAddedNode.c_str(), service, Params().GetDefaultPort()); OpenNetworkConnection(CAddress(service, NODE_NONE), false, &grant, info.strAddedNode.c_str(), false); MilliSleep(500); } @@ -2063,8 +2065,11 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) semOutbound = new CSemaphore(nMaxOutbound); } - if (pnodeLocalHost == NULL) - pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); + if (pnodeLocalHost == NULL) { + CNetAddr local; + LookupHost("127.0.0.1", local, false); + pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService(local, 0), nLocalServices)); + } Discover(threadGroup); |