net: Log to net debug in MaybeDiscourageAndDisconnect except for noban and manual peers #20845
pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2101-netLogDisconnect changing 1 files +2 −1-
MarcoFalke commented at 2:43 pm on January 4, 2021: memberThe goal is to avoid local peers (e.g. untrusted peers on the local network or inbound onion peers via a local onion proxy) filling the debug log (and thus the disk).
-
MarcoFalke force-pushed on Jan 4, 2021
-
in src/net_processing.cpp:3789 in fae5c7c92b outdated
3785@@ -3786,7 +3786,7 @@ bool PeerManager::MaybeDiscourageAndDisconnect(CNode& pnode) 3786 if (pnode.addr.IsLocal()) { 3787 // We disconnect local peers for bad behavior but don't discourage (since that would discourage 3788 // all peers on the same local address) 3789- LogPrintf("Warning: disconnecting but not discouraging local peer %d!\n", peer_id); 3790+ LogPrint(BCLog::NET, "Warning: disconnecting but not discouraging local peer %d!\n", peer_id);
vasild commented at 3:38 pm on January 4, 2021:We can use
pnode.ConnectedThroughNetwork() == NET_ONION
to check for an onion peer.Actually, if the tor daemon is running on another machine or running on the same machine but bitcoind<->tord communication is happening via some of the external (real) addresses, then incoming tor connections will not have
pnode.addr
equal to127.0.0.1
and thuspnode.addr.IsLocal()
will befalse
.
MarcoFalke commented at 3:48 pm on January 4, 2021:thus pnode.addr.IsLocal() will be false.
That seems like something that can be improved unrelated to a logging-only change?
We can use pnode.ConnectedThroughNetwork() == NET_ONION to check for an onion peer.
Onion peers are just an example of peers that may use the local proxy. I haven’t tested, but it should be possible to use a proxy for ipv4 and ipv6 as well.
vasild commented at 8:57 am on January 5, 2021:That seems like something that can be improved unrelated to a logging-only change?
Yes.
Onion peers are just an example of peers that may use the local proxy.
You mean incoming peers to use a local proxy? I guess that would be possible, though maybe unusual.
MarcoFalke commented at 12:49 pm on February 16, 2021:Added a check forpnode.m_inbound_onion
for local onion proxies. I’ll leave non-local onion proxies for a follow-up.MarcoFalke added the label P2P on Jan 4, 2021MarcoFalke added the label Utils/log/libs on Jan 4, 2021practicalswift commented at 5:36 pm on January 9, 2021: contributorACK fae5c7c92b012bb3ce6fe6d1edee4a2448fdf646vasild approvedvasild commented at 10:26 am on January 15, 2021: memberACK fae5c7c92b012bb3ce6fe6d1edee4a2448fdf646
As a further improvement maybe the following would make sense:
Achieve two things:
- Recognize incoming onion peers even if the tor proxy is not running on
127.0.0.1
- Distinguish onion from normal local peers in the logging, if the tor proxy is running on
127.0.0.1
0diff --git i/src/net_processing.cpp w/src/net_processing.cpp 1index 413e3c034..ecd615995 100644 2--- i/src/net_processing.cpp 3+++ w/src/net_processing.cpp 4@@ -3780,16 +3780,20 @@ bool PeerManager::MaybeDiscourageAndDisconnect(CNode& pnode) 5 if (pnode.IsManualConn()) { 6 // We never disconnect or discourage manual peers for bad behavior 7 LogPrintf("Warning: not punishing manually connected peer %d!\n", peer_id); 8 return false; 9 } 10 11- if (pnode.addr.IsLocal()) { 12- // We disconnect local peers for bad behavior but don't discourage (since that would discourage 13- // all peers on the same local address) 14- LogPrint(BCLog::NET, "Warning: disconnecting but not discouraging local peer %d!\n", peer_id); 15+ if (pnode.addr.IsLocal() || pnode.IsInboundOnion()) { 16+ // We disconnect local or onion peers for bad behavior but don't discourage 17+ // (since that would discourage all peers on the same address) 18+ if (pnode.IsInboundOnion()) { 19+ LogPrint(BCLog::NET, "Warning: disconnecting but not discouraging onion peer %d!\n", peer_id); 20+ } else { 21+ LogPrintf("Warning: disconnecting but not discouraging local peer %d!\n", peer_id); 22+ } 23 pnode.fDisconnect = true; 24 return true; 25 } 26 27 // Normal case: Disconnect the peer and discourage all nodes sharing the address 28 LogPrint(BCLog::NET, "Disconnecting and discouraging peer %d!\n", peer_id);
practicalswift commented at 10:35 am on January 15, 2021: contributorluke-jr referenced this in commit d4430a7d56 on Jan 28, 2021DrahtBot commented at 2:53 pm on February 12, 2021: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
No conflicts as of last run.
MarcoFalke renamed this:
net: Log to net debug in MaybeDiscourageAndDisconnect except for noban and manual peers
net: Avoid discouraging the onion proxy when one inbound onion misbehaves
on Feb 15, 2021MarcoFalke removed the label Utils/log/libs on Feb 15, 2021MarcoFalke renamed this:
net: Avoid discouraging the onion proxy when one inbound onion misbehaves
net: Log to net debug in MaybeDiscourageAndDisconnect except for noban and manual peers
on Feb 15, 2021MarcoFalke added the label Utils/log/libs on Feb 15, 2021DrahtBot added the label Needs rebase on Feb 16, 2021net: Log to net debug in MaybeDiscourageAndDisconnect except for noban and manual peers fa55159b9eMarcoFalke force-pushed on Feb 16, 2021MarcoFalke commented at 12:52 pm on February 16, 2021: memberRebased and added a check for pnode.m_inbound_onion for local onion proxies. I’ll leave non-local onion proxies for a follow-up.DrahtBot removed the label Needs rebase on Feb 16, 2021vasild approvedvasild commented at 5:03 pm on February 16, 2021: memberACK fa55159b9ede4a915f8ef9e5b90e3e99eadedf91practicalswift commented at 7:18 pm on February 16, 2021: contributorACK fa55159b9ede4a915f8ef9e5b90e3e99eadedf91
Nice to see
fa
comeback afterffff
detour.MarcoFalke merged this on Feb 22, 2021MarcoFalke closed this on Feb 22, 2021
MarcoFalke deleted the branch on Feb 22, 2021sidhujag referenced this in commit fda8589af5 on Feb 22, 2021luke-jr referenced this in commit c9ddaec2db on Jun 27, 2021DrahtBot locked this on Aug 16, 2022
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 21:12 UTC
More mirrored repositories can be found on mirror.b10c.me