mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 04:52:36 +02:00
net: Move NetPermissionFlags::Implicit
verification to AddWhitelistPermissionFlags
This commit is contained in:
parent
2863d7dddb
commit
9133fd69a5
24
src/net.cpp
24
src/net.cpp
@ -558,9 +558,18 @@ void CNode::CloseSocketDisconnect()
|
|||||||
m_i2p_sam_session.reset();
|
m_i2p_sam_session.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnman::AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNetAddr &addr) const {
|
void CConnman::AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNetAddr &addr, const std::vector<NetWhitelistPermissions>& ranges) const {
|
||||||
for (const auto& subnet : vWhitelistedRange) {
|
for (const auto& subnet : ranges) {
|
||||||
if (subnet.m_subnet.Match(addr)) NetPermissions::AddFlag(flags, subnet.m_flags);
|
if (subnet.m_subnet.Match(addr)) {
|
||||||
|
NetPermissions::AddFlag(flags, subnet.m_flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Implicit)) {
|
||||||
|
NetPermissions::ClearFlag(flags, NetPermissionFlags::Implicit);
|
||||||
|
if (whitelist_forcerelay) NetPermissions::AddFlag(flags, NetPermissionFlags::ForceRelay);
|
||||||
|
if (whitelist_relay) NetPermissions::AddFlag(flags, NetPermissionFlags::Relay);
|
||||||
|
NetPermissions::AddFlag(flags, NetPermissionFlags::Mempool);
|
||||||
|
NetPermissions::AddFlag(flags, NetPermissionFlags::NoBan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1726,14 +1735,7 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
|
|||||||
{
|
{
|
||||||
int nInbound = 0;
|
int nInbound = 0;
|
||||||
|
|
||||||
AddWhitelistPermissionFlags(permission_flags, addr);
|
AddWhitelistPermissionFlags(permission_flags, addr, vWhitelistedRange);
|
||||||
if (NetPermissions::HasFlag(permission_flags, NetPermissionFlags::Implicit)) {
|
|
||||||
NetPermissions::ClearFlag(permission_flags, NetPermissionFlags::Implicit);
|
|
||||||
if (gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) NetPermissions::AddFlag(permission_flags, NetPermissionFlags::ForceRelay);
|
|
||||||
if (gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)) NetPermissions::AddFlag(permission_flags, NetPermissionFlags::Relay);
|
|
||||||
NetPermissions::AddFlag(permission_flags, NetPermissionFlags::Mempool);
|
|
||||||
NetPermissions::AddFlag(permission_flags, NetPermissionFlags::NoBan);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(m_nodes_mutex);
|
LOCK(m_nodes_mutex);
|
||||||
|
@ -53,11 +53,6 @@ class CNode;
|
|||||||
class CScheduler;
|
class CScheduler;
|
||||||
struct bilingual_str;
|
struct bilingual_str;
|
||||||
|
|
||||||
/** Default for -whitelistrelay. */
|
|
||||||
static const bool DEFAULT_WHITELISTRELAY = true;
|
|
||||||
/** Default for -whitelistforcerelay. */
|
|
||||||
static const bool DEFAULT_WHITELISTFORCERELAY = false;
|
|
||||||
|
|
||||||
/** Time after which to disconnect, after waiting for a ping response (or inactivity). */
|
/** Time after which to disconnect, after waiting for a ping response (or inactivity). */
|
||||||
static constexpr std::chrono::minutes TIMEOUT_INTERVAL{20};
|
static constexpr std::chrono::minutes TIMEOUT_INTERVAL{20};
|
||||||
/** Run the feeler connection loop once every 2 minutes. **/
|
/** Run the feeler connection loop once every 2 minutes. **/
|
||||||
@ -1343,7 +1338,7 @@ private:
|
|||||||
|
|
||||||
bool AttemptToEvictConnection();
|
bool AttemptToEvictConnection();
|
||||||
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
|
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure, ConnectionType conn_type, bool use_v2transport) EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
|
||||||
void AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNetAddr &addr) const;
|
void AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNetAddr &addr, const std::vector<NetWhitelistPermissions>& ranges) const;
|
||||||
|
|
||||||
void DeleteNode(CNode* pnode);
|
void DeleteNode(CNode* pnode);
|
||||||
|
|
||||||
|
@ -15,6 +15,11 @@ struct bilingual_str;
|
|||||||
|
|
||||||
extern const std::vector<std::string> NET_PERMISSIONS_DOC;
|
extern const std::vector<std::string> NET_PERMISSIONS_DOC;
|
||||||
|
|
||||||
|
/** Default for -whitelistrelay. */
|
||||||
|
constexpr bool DEFAULT_WHITELISTRELAY = true;
|
||||||
|
/** Default for -whitelistforcerelay. */
|
||||||
|
constexpr bool DEFAULT_WHITELISTFORCERELAY = false;
|
||||||
|
|
||||||
enum class NetPermissionFlags : uint32_t {
|
enum class NetPermissionFlags : uint32_t {
|
||||||
None = 0,
|
None = 0,
|
||||||
// Can query bloomfilter even if -peerbloomfilters is false
|
// Can query bloomfilter even if -peerbloomfilters is false
|
||||||
|
Loading…
Reference in New Issue
Block a user