mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#20881: net permission flags in net processing
This commit is contained in:
parent
0644b9b6db
commit
31b7169b3c
@ -984,7 +984,7 @@ public:
|
|||||||
std::unique_ptr<TransportDeserializer> m_deserializer;
|
std::unique_ptr<TransportDeserializer> m_deserializer;
|
||||||
std::unique_ptr<TransportSerializer> m_serializer;
|
std::unique_ptr<TransportSerializer> m_serializer;
|
||||||
|
|
||||||
// socket
|
NetPermissionFlags m_permissionFlags{ PF_NONE };
|
||||||
std::atomic<ServiceFlags> nServices{NODE_NONE};
|
std::atomic<ServiceFlags> nServices{NODE_NONE};
|
||||||
SOCKET hSocket GUARDED_BY(cs_hSocket);
|
SOCKET hSocket GUARDED_BY(cs_hSocket);
|
||||||
size_t nSendSize{0}; // total size of all vSendMsg entries
|
size_t nSendSize{0}; // total size of all vSendMsg entries
|
||||||
@ -1198,7 +1198,6 @@ private:
|
|||||||
const ServiceFlags nLocalServices;
|
const ServiceFlags nLocalServices;
|
||||||
|
|
||||||
int nSendVersion {0};
|
int nSendVersion {0};
|
||||||
NetPermissionFlags m_permissionFlags{ PF_NONE };
|
|
||||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||||
|
|
||||||
mutable RecursiveMutex cs_addrName;
|
mutable RecursiveMutex cs_addrName;
|
||||||
|
@ -67,9 +67,8 @@ void fuzz_target(const std::vector<uint8_t>& buffer, const std::string& LIMIT_TO
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CNode& p2p_node = *ConsumeNodeAsUniquePtr(fuzzed_data_provider).release();
|
CNode& p2p_node = *ConsumeNodeAsUniquePtr(fuzzed_data_provider).release();
|
||||||
|
FillNode(fuzzed_data_provider, p2p_node);
|
||||||
p2p_node.fSuccessfullyConnected = true;
|
p2p_node.fSuccessfullyConnected = true;
|
||||||
p2p_node.nVersion = PROTOCOL_VERSION;
|
|
||||||
p2p_node.SetSendVersion(PROTOCOL_VERSION);
|
|
||||||
connman.AddTestNode(p2p_node);
|
connman.AddTestNode(p2p_node);
|
||||||
g_setup->m_node.peerman->InitializeNode(&p2p_node);
|
g_setup->m_node.peerman->InitializeNode(&p2p_node);
|
||||||
|
|
||||||
|
@ -45,10 +45,9 @@ FUZZ_TARGET_INIT(process_messages, initialize_process_messages)
|
|||||||
peers.push_back(ConsumeNodeAsUniquePtr(fuzzed_data_provider, i).release());
|
peers.push_back(ConsumeNodeAsUniquePtr(fuzzed_data_provider, i).release());
|
||||||
CNode& p2p_node = *peers.back();
|
CNode& p2p_node = *peers.back();
|
||||||
|
|
||||||
|
FillNode(fuzzed_data_provider, p2p_node);
|
||||||
p2p_node.fSuccessfullyConnected = true;
|
p2p_node.fSuccessfullyConnected = true;
|
||||||
p2p_node.fPauseSend = false;
|
p2p_node.fPauseSend = false;
|
||||||
p2p_node.nVersion = PROTOCOL_VERSION;
|
|
||||||
p2p_node.SetSendVersion(PROTOCOL_VERSION);
|
|
||||||
g_setup->m_node.peerman->InitializeNode(&p2p_node);
|
g_setup->m_node.peerman->InitializeNode(&p2p_node);
|
||||||
|
|
||||||
connman.AddTestNode(p2p_node);
|
connman.AddTestNode(p2p_node);
|
||||||
|
@ -318,6 +318,23 @@ auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<N
|
|||||||
}
|
}
|
||||||
inline std::unique_ptr<CNode> ConsumeNodeAsUniquePtr(FuzzedDataProvider& fdp, const std::optional<NodeId>& node_id_in = nullopt) { return ConsumeNode<true>(fdp, node_id_in); }
|
inline std::unique_ptr<CNode> ConsumeNodeAsUniquePtr(FuzzedDataProvider& fdp, const std::optional<NodeId>& node_id_in = nullopt) { return ConsumeNode<true>(fdp, node_id_in); }
|
||||||
|
|
||||||
|
inline void FillNode(FuzzedDataProvider& fuzzed_data_provider, CNode& node, const std::optional<int32_t>& version_in = std::nullopt) noexcept
|
||||||
|
{
|
||||||
|
const ServiceFlags remote_services = ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS);
|
||||||
|
const NetPermissionFlags permission_flags = ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS);
|
||||||
|
const int32_t version = version_in.value_or(fuzzed_data_provider.ConsumeIntegral<int32_t>());
|
||||||
|
const bool filter_txs = fuzzed_data_provider.ConsumeBool();
|
||||||
|
|
||||||
|
node.nServices = remote_services;
|
||||||
|
node.m_permissionFlags = permission_flags;
|
||||||
|
node.nVersion = version;
|
||||||
|
node.SetSendVersion(version);
|
||||||
|
if (node.m_tx_relay != nullptr) {
|
||||||
|
LOCK(node.m_tx_relay->cs_filter);
|
||||||
|
node.m_tx_relay->fRelayTxes = filter_txs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void InitializeFuzzingContext(const std::string& chain_name = CBaseChainParams::REGTEST)
|
inline void InitializeFuzzingContext(const std::string& chain_name = CBaseChainParams::REGTEST)
|
||||||
{
|
{
|
||||||
static const BasicTestingSetup basic_testing_setup{chain_name, {"-nodebuglogfile"}};
|
static const BasicTestingSetup basic_testing_setup{chain_name, {"-nodebuglogfile"}};
|
||||||
|
Loading…
Reference in New Issue
Block a user