Skip to content

Commit

Permalink
Added very light (+1) banscore for clients repeatedly spamming getblo…
Browse files Browse the repository at this point in the history
…ck each time

Also put a +50 banscore for clients which triggers a flood response
  • Loading branch information
root committed Oct 11, 2014
1 parent afd8ef7 commit 0119fd0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ src/slimcoin
src/slimcoind
src/test_slimcoin
src/build.h
src/obj/*
src/obj_test
.*.swp
*.*~*
*~
Expand Down
14 changes: 14 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3422,6 +3422,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
Checkpoints::checkpointMessage.RelayTo(pfrom);
}

if (pfrom->nStartingHeight == 15164) {
pfrom->fDisconnect = true;
printf("Obsolete client stuck at block 15164, disconnecting.");
return false;
}

pfrom->fSuccessfullyConnected = true;

printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
Expand Down Expand Up @@ -3644,6 +3650,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
pindex = pindex->pnext;
int nLimit = 500 + locator.GetDistanceBack();
printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);


if(pindex)
if (pindex->nHeight < 60000) {
pfrom->Misbehaving(1);
printf(" likely old client, incrementing misbehaviour count.");
}

for(; pindex; pindex = pindex->pnext)
{
if(pindex->GetBlockHash() == hashStop)
Expand Down
9 changes: 7 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string.h>
#endif

#undef USE_UPNP
#ifdef USE_UPNP
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
Expand Down Expand Up @@ -720,8 +721,10 @@ void ThreadSocketHandler2(void* parg)
unsigned int nPos = vRecv.size();

if(nPos > ReceiveBufferSize()) {
if(!pnode->fDisconnect)
if(!pnode->fDisconnect) {
printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size());
pnode->Misbehaving(50);
}
pnode->CloseSocketDisconnect();
}
else {
Expand Down Expand Up @@ -786,8 +789,10 @@ void ThreadSocketHandler2(void* parg)
}
}
if(vSend.size() > SendBufferSize()) {
if(!pnode->fDisconnect)
if(!pnode->fDisconnect) {
printf("socket send flood control disconnect (%d bytes)\n", vSend.size());
pnode->Misbehaving(100);
}
pnode->CloseSocketDisconnect();
}
}
Expand Down

0 comments on commit 0119fd0

Please sign in to comment.