diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2016-04-12 20:41:39 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2016-04-20 13:08:19 -0400 |
commit | 367569926a9b15c05ba8d56c554880b8f5614f71 (patch) | |
tree | b4f20ad827bb2becb7df3fe0258c9f9b312c9a0e /src/netbase.cpp | |
parent | a98cd1fc86eac1e5e5a09830028233dbce1dae70 (diff) |
net: resolve outside of storage structures
Rather than allowing CNetAddr/CService/CSubNet to launch DNS queries, require
that addresses are already resolved.
This greatly simplifies async resolve logic, and makes it harder to
accidentally leak DNS queries.
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index 281c6bcb7f..1855d0a2e8 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -614,10 +614,12 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest proxyType nameProxy; GetNameProxy(nameProxy); - CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port); - if (addrResolved.IsValid()) { - addr = addrResolved; - return ConnectSocket(addr, hSocketRet, nTimeout); + CService addrResolved; + if (Lookup(strDest.c_str(), addrResolved, port, fNameLookup && !HaveNameProxy())) { + if (addrResolved.IsValid()) { + addr = addrResolved; + return ConnectSocket(addr, hSocketRet, nTimeout); + } } addr = CService("0.0.0.0:0"); |