mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Respect logips
config option in few more log outputs (#3078)
* Introduce CNode::GetLogString() and use it where appropriate * All other cases * fix typo * drop useless argument
This commit is contained in:
parent
d26b6a84cc
commit
ac0270871c
@ -248,7 +248,9 @@ void CAddrMan::Good_(const CService& addr, int64_t nTime)
|
||||
if (nUBucket == -1)
|
||||
return;
|
||||
|
||||
LogPrint(BCLog::ADDRMAN, "Moving %s to tried\n", addr.ToString());
|
||||
if (fLogIPs) {
|
||||
LogPrint(BCLog::ADDRMAN, "Moving %s to tried\n", addr.ToString());
|
||||
}
|
||||
|
||||
// move nId to the tried tables
|
||||
MakeTried(info, nId);
|
||||
|
@ -121,7 +121,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
} else {
|
||||
SyncSingleObjVotes(pfrom, nProp, filter, connman);
|
||||
}
|
||||
LogPrint(BCLog::GOBJECT, "MNGOVERNANCESYNC -- syncing governance objects to our peer at %s\n", pfrom->addr.ToString());
|
||||
LogPrint(BCLog::GOBJECT, "MNGOVERNANCESYNC -- syncing governance objects to our peer %s\n", pfrom->GetLogString());
|
||||
}
|
||||
|
||||
// A NEW GOVERNANCE OBJECT HAS ARRIVED
|
||||
@ -320,7 +320,7 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
|
||||
}
|
||||
}
|
||||
|
||||
LogPrintf("CGovernanceManager::AddGovernanceObject -- %s new, received from %s\n", strHash, pfrom ? pfrom->GetAddrName() : "nullptr");
|
||||
LogPrintf("CGovernanceManager::AddGovernanceObject -- %s new, received from peer %s\n", strHash, pfrom ? pfrom->GetLogString() : "nullptr");
|
||||
govobj.Relay(connman);
|
||||
|
||||
// Update the rate buffer
|
||||
|
@ -39,7 +39,11 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
|
||||
}
|
||||
if (fFound) return; // do NOT disconnect mixing masternodes
|
||||
#endif // ENABLE_WALLET
|
||||
LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->GetId(), pnode->addr.ToString());
|
||||
if (fLogIPs) {
|
||||
LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->GetId(), pnode->addr.ToString());
|
||||
} else {
|
||||
LogPrintf("Closing Masternode connection: peer=%d\n", pnode->GetId());
|
||||
}
|
||||
pnode->fDisconnect = true;
|
||||
}
|
||||
});
|
||||
|
48
src/net.cpp
48
src/net.cpp
@ -392,9 +392,14 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||
}
|
||||
|
||||
/// debug print
|
||||
LogPrint(BCLog::NET, "trying connection %s lastseen=%.1fhrs\n",
|
||||
pszDest ? pszDest : addrConnect.ToString(),
|
||||
pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);
|
||||
if (fLogIPs) {
|
||||
LogPrint(BCLog::NET, "trying connection %s lastseen=%.1fhrs\n",
|
||||
pszDest ? pszDest : addrConnect.ToString(),
|
||||
pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "trying connection lastseen=%.1fhrs\n",
|
||||
pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);
|
||||
}
|
||||
|
||||
// Connect
|
||||
SOCKET hSocket;
|
||||
@ -655,6 +660,11 @@ void CNode::SetAddrLocal(const CService& addrLocalIn) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string CNode::GetLogString() const
|
||||
{
|
||||
return fLogIPs ? addr.ToString() : strprintf("%d", id);
|
||||
}
|
||||
|
||||
#undef X
|
||||
#define X(name) stats.name = name
|
||||
void CNode::copyStats(CNodeStats &stats)
|
||||
@ -1131,15 +1141,22 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strDropped;
|
||||
if (fLogIPs) {
|
||||
strDropped = strprintf("connection from %s dropped", addr.ToString());
|
||||
} else {
|
||||
strDropped = "connection dropped";
|
||||
}
|
||||
|
||||
if (!fNetworkActive) {
|
||||
LogPrintf("connection from %s dropped: not accepting new connections\n", addr.ToString());
|
||||
LogPrintf("%s: not accepting new connections\n", strDropped);
|
||||
CloseSocket(hSocket);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsSelectableSocket(hSocket))
|
||||
{
|
||||
LogPrintf("connection from %s dropped: non-selectable socket\n", addr.ToString());
|
||||
LogPrintf("%s: non-selectable socket\n", strDropped);
|
||||
CloseSocket(hSocket);
|
||||
return;
|
||||
}
|
||||
@ -1150,7 +1167,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
|
||||
if (IsBanned(addr) && !whitelisted)
|
||||
{
|
||||
LogPrintf("connection from %s dropped (banned)\n", addr.ToString());
|
||||
LogPrintf("%s (banned)\n", strDropped);
|
||||
CloseSocket(hSocket);
|
||||
return;
|
||||
}
|
||||
@ -1187,7 +1204,11 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
pnode->fWhitelisted = whitelisted;
|
||||
GetNodeSignals().InitializeNode(pnode, *this);
|
||||
|
||||
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString());
|
||||
if (fLogIPs) {
|
||||
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString());
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "connection accepted\n");
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
@ -1211,8 +1232,13 @@ void CConnman::ThreadSocketHandler()
|
||||
{
|
||||
if (pnode->fDisconnect)
|
||||
{
|
||||
LogPrintf("ThreadSocketHandler -- removing node: peer=%d addr=%s nRefCount=%d fInbound=%d fMasternode=%d\n",
|
||||
if (fLogIPs) {
|
||||
LogPrintf("ThreadSocketHandler -- removing node: peer=%d addr=%s nRefCount=%d fInbound=%d fMasternode=%d\n",
|
||||
pnode->GetId(), pnode->addr.ToString(), pnode->GetRefCount(), pnode->fInbound, pnode->fMasternode);
|
||||
} else {
|
||||
LogPrintf("ThreadSocketHandler -- removing node: peer=%d nRefCount=%d fInbound=%d fMasternode=%d\n",
|
||||
pnode->GetId(), pnode->GetRefCount(), pnode->fInbound, pnode->fMasternode);
|
||||
}
|
||||
|
||||
// remove from vNodes
|
||||
vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());
|
||||
@ -1957,7 +1983,11 @@ void CConnman::ThreadOpenConnections()
|
||||
int randsleep = GetRandInt(FEELER_SLEEP_WINDOW * 1000);
|
||||
if (!interruptNet.sleep_for(std::chrono::milliseconds(randsleep)))
|
||||
return;
|
||||
LogPrint(BCLog::NET, "Making feeler connection to %s\n", addrConnect.ToString());
|
||||
if (fLogIPs) {
|
||||
LogPrint(BCLog::NET, "Making feeler connection to %s\n", addrConnect.ToString());
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Making feeler connection\n");
|
||||
}
|
||||
}
|
||||
|
||||
OpenNetworkConnection(addrConnect, (int)setConnected.size() >= std::min(nMaxConnections - 1, 2), &grant, nullptr, false, fFeeler);
|
||||
|
@ -1020,6 +1020,8 @@ public:
|
||||
std::string GetAddrName() const;
|
||||
//! Sets the addrName only if it was not previously set
|
||||
void MaybeSetAddrName(const std::string& addrNameIn);
|
||||
|
||||
std::string GetLogString() const;
|
||||
};
|
||||
|
||||
class CExplicitNetCleanup
|
||||
|
@ -2987,13 +2987,13 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman& connman)
|
||||
if (state.fShouldBan) {
|
||||
state.fShouldBan = false;
|
||||
if (pnode->fWhitelisted)
|
||||
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->addr.ToString());
|
||||
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->GetLogString());
|
||||
else if (pnode->fAddnode)
|
||||
LogPrintf("Warning: not punishing addnoded peer %s!\n", pnode->addr.ToString());
|
||||
LogPrintf("Warning: not punishing addnoded peer %s!\n", pnode->GetLogString());
|
||||
else {
|
||||
pnode->fDisconnect = true;
|
||||
if (pnode->addr.IsLocal())
|
||||
LogPrintf("Warning: not banning local peer %s!\n", pnode->addr.ToString());
|
||||
LogPrintf("Warning: not banning local peer %s!\n", pnode->GetLogString());
|
||||
else
|
||||
{
|
||||
connman.Ban(pnode->addr, BanReasonNodeMisbehaving);
|
||||
|
@ -72,7 +72,11 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
|
||||
|
||||
int64_t nLastDsq = mmetaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
||||
if (nLastDsq != 0 && nLastDsq + mnList.GetValidMNsCount() / 5 > mmetaman.GetDsqCount()) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSACCEPT -- last dsq too recent, must wait: addr=%s\n", pfrom->addr.ToString());
|
||||
if (fLogIPs) {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSACCEPT -- last dsq too recent, must wait: peer=%d, addr=%s\n", pfrom->GetId(), pfrom->addr.ToString());
|
||||
} else {
|
||||
LogPrint(BCLog::PRIVATESEND, "DSACCEPT -- last dsq too recent, must wait: peer=%d\n", pfrom->GetId());
|
||||
}
|
||||
PushStatus(pfrom, STATUS_REJECTED, ERR_RECENT, connman);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user