13#include <shared_mutex>
24#include <boost/asio.hpp>
25#include <boost/asio/ip/tcp.hpp>
26#include <boost/asio/steady_timer.hpp>
29namespace ba = boost::asio;
104using CapDesc = std::pair<std::string, unsigned>;
182 std::string
enode()
const;
206 explicit operator bool()
const {
return static_cast<bool>(
id); }
236inline boost::log::formatting_ostream&
operator<<(boost::log::formatting_ostream&
_strm,
251#if !defined(BOOST_ASIO_HAS_STD_HASH)
254struct hash<bi::address> {
256 if (_a.is_v4())
return std::hash<unsigned long>()(_a.to_v4().to_ulong());
258 auto const& range = _a.to_v6().to_bytes();
259 return boost::hash_range(range.begin(), range.end());
261 if (_a.is_unspecified())
262 return static_cast<size_t>(0x3487194039229152ull);
264 return std::hash<std::string>()(_a.to_string());
Class for writing to an RLP bytestream.
Definition RLP.h:484
std::atomic< PeerType > peerType
Definition Common.h:217
std::atomic< uint16_t > external_udp_port
Definition Common.h:218
Node(Public _publicKey, NodeIPEndpoint const &_ip, PeerType _peerType=PeerType::Optional)
Definition Common.h:197
NodeID const id
Definition Common.h:209
std::shared_mutex endpoint_mu_
Definition Common.h:213
NodeID const & address() const
Definition Common.h:201
void set_endpoint(NodeIPEndpoint endpoint)
Definition Common.cpp:158
NodeIPEndpoint endpoint_
Definition Common.h:212
NodeIPEndpoint get_endpoint() const
Definition Common.cpp:153
IPv4,UDP/TCP endpoints.
Definition Common.h:128
void setUdpPort(uint16_t _udp)
Definition Common.h:156
void interpretRLP(RLP const &_r)
Definition Common.cpp:137
uint16_t tcpPort() const
Definition Common.h:158
void streamRLP(RLPStream &_s, RLPAppend _append=StreamList) const
Definition Common.cpp:126
void setAddress(bi::address _addr)
Definition Common.h:152
bool operator!=(NodeIPEndpoint const &_cmp) const
Definition Common.h:145
uint16_t m_udpPort
Definition Common.h:164
uint16_t udpPort() const
Definition Common.h:154
NodeIPEndpoint(RLP const &_r)
Definition Common.h:135
bi::address m_address
Definition Common.h:163
void setTcpPort(uint16_t _tcp)
Definition Common.h:160
RLPAppend
Definition Common.h:130
@ StreamList
Definition Common.h:130
@ StreamInline
Definition Common.h:130
bi::address address() const
Definition Common.h:150
NodeIPEndpoint(bi::address _addr, uint16_t _udp, uint16_t _tcp)
Definition Common.h:133
bool operator==(NodeIPEndpoint const &_cmp) const
Definition Common.h:142
uint16_t m_tcpPort
Definition Common.h:165
std::vector< CapDesc > CapDescs
Definition Common.h:105
std::string clientVersion
Definition Common.h:114
HandshakeFailureReason
Definition Common.h:93
std::set< CapDesc > caps
Definition Common.h:118
std::string host
Definition Common.h:115
NodeID id
Definition Common.h:113
std::pair< std::string, unsigned > CapDesc
Definition Common.h:104
std::chrono::steady_clock::duration lastPing
Definition Common.h:117
std::vector< PeerSessionInfo > PeerSessionInfos
Definition Common.h:121
ostream & operator<<(ostream &_out, NodeIPEndpoint const &_ep)
Definition Common.cpp:205
bool isLocalHostAddress(bi::address const &_addressToCheck)
Definition Common.cpp:77
const Node UnspecifiedNode
Definition Common.cpp:17
bool isPublicAddress(string const &_addressToCheck)
Definition Common.cpp:34
constexpr unsigned c_protocolVersion
Peer network protocol version.
Definition Common.h:40
string reasonOf(DisconnectReason _r)
Definition Common.cpp:93
char const * p2pPacketTypeToString(P2pPacketType _packetType)
Definition Common.cpp:19
bool isPrivateAddress(bi::address const &_addressToCheck)
Definition Common.cpp:52
unsigned short port
Definition Common.h:116
bool isAllowedEndpoint(bool _allowLocalDiscovery, NodeIPEndpoint const &_endpointToCheck)
Definition Common.cpp:46
DisconnectReason
Definition Common.h:73
@ NoDisconnect
Definition Common.h:87
@ UserReason
Definition Common.h:86
@ LocalIdentity
Definition Common.h:84
@ DisconnectRequested
Definition Common.h:74
@ DuplicatePeer
Definition Common.h:79
@ PingTimeout
Definition Common.h:85
@ IncompatibleProtocol
Definition Common.h:80
@ UnexpectedIdentity
Definition Common.h:83
@ ClientQuit
Definition Common.h:82
@ TCPError
Definition Common.h:75
@ TooManyPeers
Definition Common.h:78
@ NullIdentity
Definition Common.h:81
@ UselessPeer
Definition Common.h:77
@ BadProtocol
Definition Common.h:76
P2pPacketType
Definition Common.h:69
@ UserPacket
Definition Common.h:69
@ PongPacket
Definition Common.h:69
@ PingPacket
Definition Common.h:69
@ DisconnectPacket
Definition Common.h:69
@ HelloPacket
Definition Common.h:69
bool isAllowedAddress(bool _allowLocalDiscovery, bi::address const &_addressToCheck)
Definition Common.cpp:42
PeerType
Definition Common.h:123
const NodeIPEndpoint UnspecifiedNodeIPEndpoint
Definition Common.cpp:16
void assertThrowAux(bool _condition, ::std::string const &_errorDescription, unsigned _line, char const *_file, char const *_function)
Definition Assertions.h:53
FixedHash< 64 > h512
Definition FixedHash.h:452
std::hash for asio::adress
Definition FixedHash.h:483
Base class for all exceptions.
Definition Exceptions.h:21
The ECDHE agreement failed during RLPx handshake.
Definition Common.h:67
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not t...
Definition Host.h:69
bool isValid() const
Definition Common.cpp:203
NodeID id() const
Definition Common.h:178
NodeIPEndpoint nodeIPEndpoint() const
Definition Common.cpp:185
NodeID m_id
Definition Common.h:190
uint16_t m_tcpPort
Definition Common.h:188
NodeSpec(std::string const &_user)
std::string enode() const
Definition Common.cpp:189
NodeSpec()
Definition Common.h:169
NodeSpec(std::string const &_addr, uint16_t _port, int _udpPort=-1)
Definition Common.h:175
std::string m_address
Definition Common.h:187
uint16_t m_udpPort
Definition Common.h:189
The Session class.
Definition Session.h:33
size_t operator()(bi::address const &_a) const
Definition Common.h:255