Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | if (sock != INVALID_SOCKET) { | ||||
} else { | } else { | ||||
LogPrint(BCLog::NET, "Warning: getsockname failed\n"); | LogPrint(BCLog::NET, "Warning: getsockname failed\n"); | ||||
} | } | ||||
} | } | ||||
return addr_bind; | return addr_bind; | ||||
} | } | ||||
CNode *CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, | CNode *CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, | ||||
bool fCountFailure) { | bool fCountFailure, bool manual_connection) { | ||||
if (pszDest == nullptr) { | if (pszDest == nullptr) { | ||||
if (IsLocal(addrConnect)) { | if (IsLocal(addrConnect)) { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
// Look for an existing connection | // Look for an existing connection | ||||
CNode *pnode = FindNode(static_cast<CService>(addrConnect)); | CNode *pnode = FindNode(static_cast<CService>(addrConnect)); | ||||
if (pnode) { | if (pnode) { | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (addrConnect.IsValid()) { | ||||
proxy, addrConnect.ToStringIP(), addrConnect.GetPort(), hSocket, | proxy, addrConnect.ToStringIP(), addrConnect.GetPort(), hSocket, | ||||
nConnectTimeout, &proxyConnectionFailed); | nConnectTimeout, &proxyConnectionFailed); | ||||
} else { | } else { | ||||
// no proxy needed (none set for target network) | // no proxy needed (none set for target network) | ||||
hSocket = CreateSocket(addrConnect); | hSocket = CreateSocket(addrConnect); | ||||
if (hSocket == INVALID_SOCKET) { | if (hSocket == INVALID_SOCKET) { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
connected = | connected = ConnectSocketDirectly( | ||||
ConnectSocketDirectly(addrConnect, hSocket, nConnectTimeout); | addrConnect, hSocket, nConnectTimeout, manual_connection); | ||||
} | } | ||||
if (!proxyConnectionFailed) { | if (!proxyConnectionFailed) { | ||||
// If a connection to the node was attempted, and failure (if any) | // If a connection to the node was attempted, and failure (if any) | ||||
// is not caused by a problem connecting to the proxy, mark this as | // is not caused by a problem connecting to the proxy, mark this as | ||||
// an attempt. | // an attempt. | ||||
addrman.Attempt(addrConnect, fCountFailure); | addrman.Attempt(addrConnect, fCountFailure); | ||||
} | } | ||||
} else if (pszDest && GetNameProxy(proxy)) { | } else if (pszDest && GetNameProxy(proxy)) { | ||||
▲ Show 20 Lines • Show All 1,669 Lines • ▼ Show 20 Lines | if (!pszDest) { | ||||
FindNode(static_cast<CNetAddr>(addrConnect)) || | FindNode(static_cast<CNetAddr>(addrConnect)) || | ||||
IsBanned(addrConnect) || FindNode(addrConnect.ToStringIPPort())) { | IsBanned(addrConnect) || FindNode(addrConnect.ToStringIPPort())) { | ||||
return; | return; | ||||
} | } | ||||
} else if (FindNode(std::string(pszDest))) { | } else if (FindNode(std::string(pszDest))) { | ||||
return; | return; | ||||
} | } | ||||
CNode *pnode = ConnectNode(addrConnect, pszDest, fCountFailure); | CNode *pnode = | ||||
ConnectNode(addrConnect, pszDest, fCountFailure, manual_connection); | |||||
if (!pnode) { | if (!pnode) { | ||||
return; | return; | ||||
} | } | ||||
if (grantOutbound) { | if (grantOutbound) { | ||||
grantOutbound->MoveTo(pnode->grantOutbound); | grantOutbound->MoveTo(pnode->grantOutbound); | ||||
} | } | ||||
if (fOneShot) { | if (fOneShot) { | ||||
▲ Show 20 Lines • Show All 973 Lines • Show Last 20 Lines |