7d06e0b4c09d0faed2673cf18b51a77201a91222 PF_NOBAN
is a multi-flag, so this will return false for both the “noban” and the “download” statuses. If you want it to be false only for noban, use HasFlag()
0 if (!NetPermissions::HasFlag(whitebind.m_flags, NetPermissionFlags::PF_NOBAN)) {
(and if you want it to be false for both “noban” and “download” the following would be more explicit and simplify the change in #21506)
0 if (!NetPermissions::HasFlag(whitebind.m_flags, NetPermissionFlags::PF_NOBAN) &&
1 !NetPermissions::HasFlag(whitebind.m_flags, NetPermissionFlags::PF_DOWNLOAD)) {
To illustrate, these tests pass if added to netbase_tests.cpp
in the “netpermissions_test”:
0 // "noban" implies "download"
1 BOOST_CHECK(NetWhitebindPermissions::TryParse("noban@1.2.3.4:32", whitebindPermissions, error));
2 BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_NOBAN);
3 BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_NOBAN));
4 BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_DOWNLOAD));
5 BOOST_CHECK(whitebindPermissions.m_flags & PF_NOBAN);
6 BOOST_CHECK(whitebindPermissions.m_flags & PF_DOWNLOAD);
7
8 // "download" excludes (does not imply) "noban"
9 BOOST_CHECK(NetWhitebindPermissions::TryParse("download@1.2.3.4:32", whitebindPermissions, error));
10 BOOST_CHECK_EQUAL(whitebindPermissions.m_flags, PF_DOWNLOAD);
11 BOOST_CHECK(whitebindPermissions.m_flags != PF_NOBAN);
12 BOOST_CHECK(!NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_NOBAN));
13 BOOST_CHECK(NetPermissions::HasFlag(whitebindPermissions.m_flags, PF_DOWNLOAD));
14 BOOST_CHECK(whitebindPermissions.m_flags & PF_NOBAN);
15 BOOST_CHECK(whitebindPermissions.m_flags & PF_DOWNLOAD);