Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <net_permissions.h>6#include <netbase.h>7#include <test/fuzz/FuzzedDataProvider.h>8#include <test/fuzz/fuzz.h>9#include <test/fuzz/util.h>10#include <test/fuzz/util/net.h>11#include <util/translation.h>13#include <cassert>14#include <cstdint>15#include <string>16#include <vector>18FUZZ_TARGET(net_permissions)19{20FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());21const std::string s = fuzzed_data_provider.ConsumeRandomLengthString(1000);22const NetPermissionFlags net_permission_flags = ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS);24NetWhitebindPermissions net_whitebind_permissions;25bilingual_str error_net_whitebind_permissions;26if (NetWhitebindPermissions::TryParse(s, net_whitebind_permissions, error_net_whitebind_permissions)) {27(void)NetPermissions::ToStrings(net_whitebind_permissions.m_flags);28(void)NetPermissions::AddFlag(net_whitebind_permissions.m_flags, net_permission_flags);29assert(NetPermissions::HasFlag(net_whitebind_permissions.m_flags, net_permission_flags));30(void)NetPermissions::ClearFlag(net_whitebind_permissions.m_flags, NetPermissionFlags::Implicit);31(void)NetPermissions::ToStrings(net_whitebind_permissions.m_flags);32}34NetWhitelistPermissions net_whitelist_permissions;35ConnectionDirection connection_direction;36bilingual_str error_net_whitelist_permissions;37if (NetWhitelistPermissions::TryParse(s, net_whitelist_permissions, connection_direction, error_net_whitelist_permissions)) {38(void)NetPermissions::ToStrings(net_whitelist_permissions.m_flags);39(void)NetPermissions::AddFlag(net_whitelist_permissions.m_flags, net_permission_flags);40assert(NetPermissions::HasFlag(net_whitelist_permissions.m_flags, net_permission_flags));41(void)NetPermissions::ClearFlag(net_whitelist_permissions.m_flags, NetPermissionFlags::Implicit);42(void)NetPermissions::ToStrings(net_whitelist_permissions.m_flags);43}44}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.