Show when node is misbehaving, not just at the point that it gets banned.

This commit is contained in:
R E Broadley 2012-05-17 22:05:36 +01:00
parent e75acc006e
commit 90c838da9f

View File

@ -586,7 +586,7 @@ bool CNode::Misbehaving(int howmuch)
{ {
if (addr.IsLocal()) if (addr.IsLocal())
{ {
printf("Warning: local node %s misbehaving\n", addrName.c_str()); printf("Warning: local node %s misbehaving (delta: %d)\n", addrName.c_str(), howmuch);
return false; return false;
} }
@ -594,15 +594,16 @@ bool CNode::Misbehaving(int howmuch)
if (nMisbehavior >= GetArg("-banscore", 100)) if (nMisbehavior >= GetArg("-banscore", 100))
{ {
int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
{ {
LOCK(cs_setBanned); LOCK(cs_setBanned);
if (setBanned[addr] < banTime) if (setBanned[addr] < banTime)
setBanned[addr] = banTime; setBanned[addr] = banTime;
} }
CloseSocketDisconnect(); CloseSocketDisconnect();
printf("Disconnected %s for misbehavior (score=%d)\n", addrName.c_str(), nMisbehavior);
return true; return true;
} } else
printf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
return false; return false;
} }