Skip to content

Commit 1a5a4e6

Browse files
committed
Randomize name lookup result in ConnectSocketByName
1 parent f9f5cfc commit 1a5a4e6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/netbase.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,10 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
621621
proxyType nameProxy;
622622
GetNameProxy(nameProxy);
623623

624-
CService addrResolved;
625-
if (Lookup(strDest.c_str(), addrResolved, port, fNameLookup && !HaveNameProxy())) {
626-
if (addrResolved.IsValid()) {
627-
addr = addrResolved;
624+
std::vector<CService> addrResolved;
625+
if (Lookup(strDest.c_str(), addrResolved, port, fNameLookup && !HaveNameProxy(), 256)) {
626+
if (addrResolved.size() > 0) {
627+
addr = addrResolved[GetRand(addrResolved.size())];
628628
return ConnectSocket(addr, hSocketRet, nTimeout);
629629
}
630630
}

0 commit comments

Comments
 (0)