mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
p2p, bugfix: use NetPermissions::HasFlag() in CConnman::Bind()
PF_NOBAN is a multi-flag that includes PF_DOWNLOAD, so the conditional in CConnman::Bind() using a bitwise AND will return the same result for both the "noban" status and the "download" status. Example: `PF_DOWNLOAD` is `0b1000000` `PF_NOBAN` is `0b1010000` This makes a check like `flags & PF_NOBAN` return `true` even if `flags` is equal to `PF_DOWNLOAD`. If `-whitebind=download@1.1.1.1:8765` is specified, then `1.1.1.1:8765` should be added to the list of local addresses. We only want to avoid adding to local addresses (that are advertised) a whitebind that has a `noban@` flag. As a result of a mis-check in `CConnman::Bind()` we would not have added `1.1.1.1:8765` to the local addresses in the example above. Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
parent
f0fa32450e
commit
dde69f20a0
1 changed files with 3 additions and 2 deletions
|
@ -2408,8 +2408,9 @@ NodeId CConnman::GetNewNodeId()
|
|||
|
||||
|
||||
bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags permissions) {
|
||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
|
||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr)) {
|
||||
return false;
|
||||
}
|
||||
bilingual_str strError;
|
||||
if (!BindListenPort(addr, strError, permissions)) {
|
||||
if ((flags & BF_REPORT_ERROR) && clientInterface) {
|
||||
|
@ -2418,7 +2419,7 @@ bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags
|
|||
return false;
|
||||
}
|
||||
|
||||
if (addr.IsRoutable() && fDiscover && !(flags & BF_DONT_ADVERTISE) && !(permissions & PF_NOBAN)) {
|
||||
if (addr.IsRoutable() && fDiscover && !(flags & BF_DONT_ADVERTISE) && !NetPermissions::HasFlag(permissions, NetPermissionFlags::PF_NOBAN)) {
|
||||
AddLocal(addr, LOCAL_BIND);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue