aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/net.cpp b/src/net.cpp
index a66875a894..2773b63f7c 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -12,7 +12,7 @@
#include "addrman.h"
#include "chainparams.h"
#include "clientversion.h"
-#include "core/transaction.h"
+#include "primitives/transaction.h"
#include "ui_interface.h"
#ifdef WIN32
@@ -399,7 +399,9 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
// Connect
SOCKET hSocket;
- if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, Params().GetDefaultPort()) : ConnectSocket(addrConnect, hSocket))
+ bool proxyConnectionFailed = false;
+ if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, Params().GetDefaultPort(), nConnectTimeout, &proxyConnectionFailed) :
+ ConnectSocket(addrConnect, hSocket, nConnectTimeout, &proxyConnectionFailed))
{
addrman.Attempt(addrConnect);
@@ -415,6 +417,10 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
pnode->nTimeConnected = GetTime();
return pnode;
+ } else if (!proxyConnectionFailed) {
+ // If connecting to the node failed, and failure is not caused by a problem connecting to
+ // the proxy, mark this as an attempt.
+ addrman.Attempt(addrConnect);
}
return NULL;
@@ -439,7 +445,6 @@ void CNode::PushVersion()
{
int nBestHeight = g_signals.GetHeight().get_value_or(0);
- /// when NTP implemented, change to just nTime = GetAdjustedTime()
int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime());
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
CAddress addrMe = GetLocalAddress(&addr);
@@ -595,7 +600,7 @@ int CNetMessage::readHeader(const char *pch, unsigned int nBytes)
try {
hdrbuf >> hdr;
}
- catch (const std::exception &) {
+ catch (const std::exception&) {
return -1;
}
@@ -1062,7 +1067,7 @@ void ThreadMapPort()
MilliSleep(20*60*1000); // Refresh every 20 minutes
}
}
- catch (boost::thread_interrupted)
+ catch (const boost::thread_interrupted&)
{
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
LogPrintf("UPNP_DeletePortMapping() returned : %d\n", r);
@@ -1559,7 +1564,7 @@ void static Discover(boost::thread_group& threadGroup)
#ifdef WIN32
// Get local host IP
- char pszHostName[1000] = "";
+ char pszHostName[256] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
{
vector<CNetAddr> vaddr;
@@ -1567,7 +1572,8 @@ void static Discover(boost::thread_group& threadGroup)
{
BOOST_FOREACH (const CNetAddr &addr, vaddr)
{
- AddLocal(addr, LOCAL_IF);
+ if (AddLocal(addr, LOCAL_IF))
+ LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString());
}
}
}
@@ -1587,20 +1593,19 @@ void static Discover(boost::thread_group& threadGroup)
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
CNetAddr addr(s4->sin_addr);
if (AddLocal(addr, LOCAL_IF))
- LogPrintf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString());
+ LogPrintf("%s: IPv4 %s: %s\n", __func__, ifa->ifa_name, addr.ToString());
}
else if (ifa->ifa_addr->sa_family == AF_INET6)
{
struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
CNetAddr addr(s6->sin6_addr);
if (AddLocal(addr, LOCAL_IF))
- LogPrintf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString());
+ LogPrintf("%s: IPv6 %s: %s\n", __func__, ifa->ifa_name, addr.ToString());
}
}
freeifaddrs(myaddrs);
}
#endif
-
}
void StartNode(boost::thread_group& threadGroup)
@@ -1848,7 +1853,7 @@ bool CAddrDB::Write(const CAddrMan& addr)
try {
fileout << ssPeers;
}
- catch (std::exception &e) {
+ catch (const std::exception& e) {
return error("%s : Serialize or I/O error - %s", __func__, e.what());
}
FileCommit(fileout.Get());
@@ -1884,7 +1889,7 @@ bool CAddrDB::Read(CAddrMan& addr)
filein.read((char *)&vchData[0], dataSize);
filein >> hashIn;
}
- catch (std::exception &e) {
+ catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
filein.fclose();
@@ -1908,7 +1913,7 @@ bool CAddrDB::Read(CAddrMan& addr)
// de-serialize address data into one CAddrMan object
ssPeers >> addr;
}
- catch (std::exception &e) {
+ catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}