File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -1013,7 +1013,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
1013
1013
SetSocketNoDelay (hSocket);
1014
1014
1015
1015
// Don't accept connections from banned peers.
1016
- bool banned = m_banman->IsBanned (addr);
1016
+ bool banned = m_banman && m_banman ->IsBanned (addr);
1017
1017
if (!NetPermissions::HasFlag (permissionFlags, NetPermissionFlags::PF_NOBAN) && banned)
1018
1018
{
1019
1019
LogPrint (BCLog::NET, " connection from %s dropped (banned)\n " , addr.ToString ());
@@ -1022,7 +1022,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
1022
1022
}
1023
1023
1024
1024
// Only accept connections from discouraged peers if our inbound slots aren't (almost) full.
1025
- bool discouraged = m_banman->IsDiscouraged (addr);
1025
+ bool discouraged = m_banman && m_banman ->IsDiscouraged (addr);
1026
1026
if (!NetPermissions::HasFlag (permissionFlags, NetPermissionFlags::PF_NOBAN) && nInbound + 1 >= nMaxInbound && discouraged)
1027
1027
{
1028
1028
LogPrint (BCLog::NET, " connection from %s dropped (discouraged)\n " , addr.ToString ());
Original file line number Diff line number Diff line change @@ -447,6 +447,7 @@ class CConnman
447
447
std::atomic<int > nBestHeight;
448
448
CClientUIInterface* clientInterface;
449
449
NetEventsInterface* m_msgproc;
450
+ /* * Pointer to this node's banman. May be nullptr - check existence before dereferencing. */
450
451
BanMan* m_banman;
451
452
452
453
/* * SipHasher seeds for deterministic randomness */
Original file line number Diff line number Diff line change @@ -2491,8 +2491,10 @@ void ProcessMessage(
2491
2491
if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60 )
2492
2492
addr.nTime = nNow - 5 * 24 * 60 * 60 ;
2493
2493
pfrom.AddAddressKnown (addr);
2494
- if (banman->IsDiscouraged (addr)) continue ; // Do not process banned/discouraged addresses beyond remembering we received them
2495
- if (banman->IsBanned (addr)) continue ;
2494
+ if (banman && (banman->IsDiscouraged (addr) || banman->IsBanned (addr))) {
2495
+ // Do not process banned/discouraged addresses beyond remembering we received them
2496
+ continue ;
2497
+ }
2496
2498
bool fReachable = IsReachable (addr);
2497
2499
if (addr.nTime > nSince && !pfrom.fGetAddr && vAddr.size () <= 10 && addr.IsRoutable ())
2498
2500
{
@@ -3346,7 +3348,8 @@ void ProcessMessage(
3346
3348
std::vector<CAddress> vAddr = connman->GetAddresses ();
3347
3349
FastRandomContext insecure_rand;
3348
3350
for (const CAddress &addr : vAddr) {
3349
- if (!banman->IsDiscouraged (addr) && !banman->IsBanned (addr)) {
3351
+ bool banned_or_discouraged = banman && (banman->IsDiscouraged (addr) || banman->IsBanned (addr));
3352
+ if (!banned_or_discouraged) {
3350
3353
pfrom.PushAddress (addr, insecure_rand);
3351
3354
}
3352
3355
}
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ static const int DISCOURAGEMENT_THRESHOLD{100};
29
29
class PeerLogicValidation final : public CValidationInterface, public NetEventsInterface {
30
30
private:
31
31
CConnman* const connman;
32
+ /* * Pointer to this node's banman. May be nullptr - check existence before dereferencing. */
32
33
BanMan* const m_banman;
33
34
ChainstateManager& m_chainman;
34
35
CTxMemPool& m_mempool;
You can’t perform that action at this time.
0 commit comments