From 025c0614156b3740512c84daa075bf78c0e8b505 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 27 Jun 2014 21:11:56 -0300 Subject: [PATCH] dhtput should have a higher cost, as it lacks active limit check. --- src/dhtproxy.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dhtproxy.cpp b/src/dhtproxy.cpp index 358b401a..2baf84f0 100644 --- a/src/dhtproxy.cpp +++ b/src/dhtproxy.cpp @@ -178,17 +178,17 @@ namespace DhtProxy } } - bool checkForAbuse(CNode* pfrom) + bool checkForAbuse(CNode* pfrom, int cost) { LOCK(cs_dhtProxy); // logic inspired/copied from dht_tracker.cpp:incoming_packet ptime now = time_now(); PeerBanStats *match = &m_peerBanStats[pfrom->addr]; - match->count++; + match->count+=cost; if( match->count >= 500 ) { if (now < match->limit) { - if( match->count == 500 ) { + if( match->count == 500 ) { // cost may break this 'if' but then we just dont log. dbgprintf("DhtProxy::checkForAbuse: %s misbehaving, too much requests.\n", pfrom->addr.ToString().c_str()); } @@ -212,7 +212,7 @@ namespace DhtProxy // we are using proxy ourselves, we can't be proxy to anyone else pfrom->PushMessage("nodhtproxy"); return true; - } else if( !req.stopReq && checkForAbuse(pfrom) ) { + } else if( !req.stopReq && checkForAbuse(pfrom, 1) ) { return false; } else { std::string username(req.vchUsername.data(), req.vchUsername.size()); @@ -296,7 +296,7 @@ namespace DhtProxy // we are using proxy ourselves, we can't be proxy to anyone else pfrom->PushMessage("nodhtproxy"); return true; - } else if( checkForAbuse(pfrom) ) { + } else if( checkForAbuse(pfrom, 10) ) { return false; } else { std::string username(req.vchUsername.data(), req.vchUsername.size());