Bitcoin ABC  0.24.7
P2P Digital Currency
net_permissions.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2018 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_NET_PERMISSIONS_H
6 #define BITCOIN_NET_PERMISSIONS_H
7 
8 #include <netaddress.h>
9 
10 #include <string>
11 #include <vector>
12 
13 struct bilingual_str;
14 
15 extern const std::vector<std::string> NET_PERMISSIONS_DOC;
16 
18  PF_NONE = 0,
19  // Can query bloomfilter even if -peerbloomfilters is false
20  PF_BLOOMFILTER = (1U << 1),
21  // Relay and accept transactions from this peer, even if -blocksonly is true
22  // This peer is also not subject to limits on how many transaction INVs are
23  // tracked
24  PF_RELAY = (1U << 3),
25  // Always relay transactions from this peer, even if already in mempool
26  // Keep parameter interaction: forcerelay implies relay
27  PF_FORCERELAY = (1U << 2) | PF_RELAY,
28  // Allow getheaders during IBD and block-download after maxuploadtarget
29  // limit
30  PF_DOWNLOAD = (1U << 6),
31  // Can't be banned/disconnected/discouraged for misbehavior
32  PF_NOBAN = (1U << 4) | PF_DOWNLOAD,
33  // Can query the mempool
34  PF_MEMPOOL = (1U << 5),
35  // Can request addrs without hitting a privacy-preserving cache
36  PF_ADDR = (1U << 7),
37  // Bypass the limit on how many proof INVs are tracked from this peer as
38  // well as the delay penalty when reaching the the in-flight requests limit
40 
41  // True if the user did not specifically set fine grained permissions
42  PF_ISIMPLICIT = (1U << 31),
45 };
46 
48 public:
50  static std::vector<std::string> ToStrings(NetPermissionFlags flags);
51  static inline bool HasFlag(const NetPermissionFlags &flags,
53  return (flags & f) == f;
54  }
55  static inline void AddFlag(NetPermissionFlags &flags,
57  flags = static_cast<NetPermissionFlags>(flags | f);
58  }
59  static inline void ClearFlag(NetPermissionFlags &flags,
61  flags = static_cast<NetPermissionFlags>(flags & ~f);
62  }
63 };
64 
66 public:
67  static bool TryParse(const std::string str, NetWhitebindPermissions &output,
70 };
71 
73 public:
74  static bool TryParse(const std::string str, NetWhitelistPermissions &output,
77 };
78 
79 #endif // BITCOIN_NET_PERMISSIONS_H
CService
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:514
PF_DOWNLOAD
@ PF_DOWNLOAD
Definition: net_permissions.h:30
NetPermissions::ToStrings
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
Definition: net_permissions.cpp:97
PF_FORCERELAY
@ PF_FORCERELAY
Definition: net_permissions.h:27
flags
int flags
Definition: bitcoin-tx.cpp:532
PF_ALL
@ PF_ALL
Definition: net_permissions.h:43
PF_NONE
@ PF_NONE
Definition: net_permissions.h:18
bilingual_str
Bilingual messages:
Definition: translation.h:17
PF_RELAY
@ PF_RELAY
Definition: net_permissions.h:24
PF_BYPASS_PROOF_REQUEST_LIMITS
@ PF_BYPASS_PROOF_REQUEST_LIMITS
Definition: net_permissions.h:39
NetPermissions::ClearFlag
static void ClearFlag(NetPermissionFlags &flags, NetPermissionFlags f)
Definition: net_permissions.h:59
NetWhitelistPermissions::m_subnet
CSubNet m_subnet
Definition: net_permissions.h:76
NET_PERMISSIONS_DOC
const std::vector< std::string > NET_PERMISSIONS_DOC
Definition: net_permissions.cpp:12
NetPermissions::HasFlag
static bool HasFlag(const NetPermissionFlags &flags, NetPermissionFlags f)
Definition: net_permissions.h:51
NetWhitelistPermissions
Definition: net_permissions.h:72
netaddress.h
NetPermissionFlags
NetPermissionFlags
Definition: net_permissions.h:17
NetWhitebindPermissions::m_service
CService m_service
Definition: net_permissions.h:69
NetWhitebindPermissions::TryParse
static bool TryParse(const std::string str, NetWhitebindPermissions &output, bilingual_str &error)
Definition: net_permissions.cpp:126
CSubNet
Definition: netaddress.h:465
PF_BLOOMFILTER
@ PF_BLOOMFILTER
Definition: net_permissions.h:20
NetPermissions::AddFlag
static void AddFlag(NetPermissionFlags &flags, NetPermissionFlags f)
Definition: net_permissions.h:55
NetPermissions::m_flags
NetPermissionFlags m_flags
Definition: net_permissions.h:49
PF_MEMPOOL
@ PF_MEMPOOL
Definition: net_permissions.h:34
NetPermissions
Definition: net_permissions.h:47
PF_ADDR
@ PF_ADDR
Definition: net_permissions.h:36
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
PF_NOBAN
@ PF_NOBAN
Definition: net_permissions.h:32
PF_ISIMPLICIT
@ PF_ISIMPLICIT
Definition: net_permissions.h:42
NetWhitebindPermissions
Definition: net_permissions.h:65
NetWhitelistPermissions::TryParse
static bool TryParse(const std::string str, NetWhitelistPermissions &output, bilingual_str &error)
Definition: net_permissions.cpp:153