CatapultServer  v0.5.0.1 (Elephant)
catapult::net Namespace Reference

Namespaces

 detail
 

Classes

class  AsyncTcpServer
 An async TCP server. More...
 
struct  AsyncTcpServerSettings
 Settings used to configure AsyncTcpServer behavior. More...
 
class  BriefServerRequestor
 
class  ChainedSocketReader
 
struct  ClientChallengeResponse
 Packet representing a challenge response from a server to a client. More...
 
class  ClientConnector
 Accepts connections that are initiated by external nodes to this (local) node. More...
 
class  ConnectionContainer
 Manages a collection of connections. More...
 
struct  ConnectionSettings
 Settings used to configure connections. More...
 
class  PacketIoPicker
 An interface for picking packet io pairs. More...
 
class  PacketIoPickerContainer
 A collection of packet io pickers. More...
 
class  PacketReaders
 Manages a collection of connections that receive data from external nodes. More...
 
class  PacketWriters
 Manages a collection of connections that send data to external nodes. More...
 
struct  PeerConnectResult
 Peer connection result. More...
 
struct  ServerChallengeRequest
 Packet representing a challenge request from a server to a client. More...
 
struct  ServerChallengeResponse
 Packet representing a challenge response and new challenge request from a client to a server. More...
 
class  ServerConnector
 Establishes connections with external nodes that this (local) node initiates. More...
 
struct  VerifiedPeerInfo
 Information about the verified node. More...
 

Typedefs

using AcceptHandler = consumer< const ionet::AcceptedPacketSocketInfo & >
 
using ConfigureSocketHandler = consumer< ionet::socket & >
 
using Challenge = std::array< uint8_t, 64 >
 Challenge data. More...
 
using VerifyCallback = consumer< VerifyResult, const VerifiedPeerInfo & >
 Callback that is called with the result of a verify operation and verified peer information on success. More...
 

Enumerations

enum  NodeRequestResult { NodeRequestResult::NODE_REQUEST_RESULT_LIST }
 Enumeration of possible results of a ping operation. More...
 
enum  PeerConnectCode { PeerConnectCode::PEER_CONNECT_CODE_LIST }
 Enumeration of possible peer connection codes. More...
 
enum  VerifyResult { VerifyResult::VERIFY_RESULT_LIST }
 Enumeration of verification results. More...
 

Functions

std::shared_ptr< AsyncTcpServerCreateAsyncTcpServer (const std::shared_ptr< thread::IoThreadPool > &pPool, const boost::asio::ip::tcp::endpoint &endpoint, const AsyncTcpServerSettings &settings)
 
template<typename TRequestor , typename TResult = std::pair<NodeRequestResult, typename TRequestor::ResponseType>>
thread::future< TResult > BeginRequestFuture (TRequestor &requestor, const ionet::Node &node)
 Initiates a request for data from node using requestor and returns a future. More...
 
std::shared_ptr< ChainedSocketReaderCreateChainedSocketReader (const std::shared_ptr< ionet::PacketSocket > &pPacketSocket, const ionet::ServerPacketHandlers &serverHandlers, const ionet::ReaderIdentity &identity)
 
std::shared_ptr< ChainedSocketReaderCreateChainedSocketReader (const std::shared_ptr< ionet::PacketSocket > &pPacketSocket, const ionet::ServerPacketHandlers &serverHandlers, const ionet::ReaderIdentity &identity, const ChainedSocketReader::CompletionHandler &completionHandler)
 
std::shared_ptr< ServerChallengeRequestGenerateServerChallengeRequest ()
 Generates a random server challenge request that is sent to a client. More...
 
std::shared_ptr< ServerChallengeResponseGenerateServerChallengeResponse (const ServerChallengeRequest &request, const crypto::KeyPair &keyPair, ionet::ConnectionSecurityMode securityMode)
 
bool VerifyServerChallengeResponse (const ServerChallengeResponse &response, const Challenge &challenge)
 Verifies a client's response to challenge. More...
 
std::shared_ptr< ClientChallengeResponseGenerateClientChallengeResponse (const ServerChallengeResponse &request, const crypto::KeyPair &keyPair)
 Generates a server response to a client challenge (request) using the server key pair (keyPair). More...
 
bool VerifyClientChallengeResponse (const ClientChallengeResponse &response, const Key &serverPublicKey, const Challenge &challenge)
 
std::shared_ptr< ClientConnectorCreateClientConnector (const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const ConnectionSettings &settings)
 Creates a client connector for a server with a key pair of keyPair using pPool and configured with settings. More...
 
std::ostream & operator<< (std::ostream &out, NodeRequestResult value)
 Insertion operator for outputting value to out. More...
 
std::vector< ionet::NodePacketIoPairPickMultiple (PacketIoPicker &picker, size_t numRequested, const utils::TimeSpan &ioDuration)
 
std::shared_ptr< PacketReadersCreatePacketReaders (const std::shared_ptr< thread::IoThreadPool > &pPool, const ionet::ServerPacketHandlers &handlers, const crypto::KeyPair &keyPair, const ConnectionSettings &settings, uint32_t maxConnectionsPerIdentity)
 
std::shared_ptr< PacketWritersCreatePacketWriters (const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const ConnectionSettings &settings)
 
std::ostream & operator<< (std::ostream &out, PeerConnectCode value)
 Insertion operator for outputting value to out. More...
 
std::shared_ptr< ServerConnectorCreateServerConnector (const std::shared_ptr< thread::IoThreadPool > &pPool, const crypto::KeyPair &keyPair, const ConnectionSettings &settings)
 Creates a server connector for a server with a key pair of keyPair using pPool and configured with settings. More...
 
void VerifyClient (const std::shared_ptr< ionet::PacketIo > &pClientIo, const crypto::KeyPair &keyPair, ionet::ConnectionSecurityMode allowedSecurityModes, const VerifyCallback &callback)
 
void VerifyServer (const std::shared_ptr< ionet::PacketIo > &pServerIo, const VerifiedPeerInfo &serverPeerInfo, const crypto::KeyPair &keyPair, const VerifyCallback &callback)
 
std::ostream & operator<< (std::ostream &out, VerifyResult value)
 Insertion operator for outputting value to out. More...
 

Typedef Documentation

◆ AcceptHandler

◆ Challenge

using catapult::net::Challenge = typedef std::array<uint8_t, 64>

Challenge data.

◆ ConfigureSocketHandler

◆ VerifyCallback

Callback that is called with the result of a verify operation and verified peer information on success.

Enumeration Type Documentation

◆ NodeRequestResult

Enumeration of possible results of a ping operation.

Enumerator
NODE_REQUEST_RESULT_LIST 

◆ PeerConnectCode

Enumeration of possible peer connection codes.

Enumerator
PEER_CONNECT_CODE_LIST 

◆ VerifyResult

Enumeration of verification results.

Enumerator
VERIFY_RESULT_LIST 

Function Documentation

◆ BeginRequestFuture()

template<typename TRequestor , typename TResult = std::pair<NodeRequestResult, typename TRequestor::ResponseType>>
thread::future<TResult> catapult::net::BeginRequestFuture ( TRequestor &  requestor,
const ionet::Node node 
)

Initiates a request for data from node using requestor and returns a future.

◆ CreateAsyncTcpServer()

std::shared_ptr< AsyncTcpServer > catapult::net::CreateAsyncTcpServer ( const std::shared_ptr< thread::IoThreadPool > &  pPool,
const boost::asio::ip::tcp::endpoint &  endpoint,
const AsyncTcpServerSettings settings 
)

Creates an async tcp server listening on endpoint with the specified settings using the specified thread pool (pPool).

Here is the caller graph for this function:

◆ CreateChainedSocketReader() [1/2]

std::shared_ptr< ChainedSocketReader > catapult::net::CreateChainedSocketReader ( const std::shared_ptr< ionet::PacketSocket > &  pPacketSocket,
const ionet::ServerPacketHandlers serverHandlers,
const ionet::ReaderIdentity identity 
)

Creates a chained socket reader around pPacketSocket and serverHandlers with a default completion handler given an identity.

◆ CreateChainedSocketReader() [2/2]

std::shared_ptr< ChainedSocketReader > catapult::net::CreateChainedSocketReader ( const std::shared_ptr< ionet::PacketSocket > &  pPacketSocket,
const ionet::ServerPacketHandlers serverHandlers,
const ionet::ReaderIdentity identity,
const ChainedSocketReader::CompletionHandler completionHandler 
)

Creates a chained socket reader around pPacketSocket and serverHandlers with a custom completion handler (completionHandler) given an identity.

◆ CreateClientConnector()

std::shared_ptr< ClientConnector > catapult::net::CreateClientConnector ( const std::shared_ptr< thread::IoThreadPool > &  pPool,
const crypto::KeyPair keyPair,
const ConnectionSettings settings 
)

Creates a client connector for a server with a key pair of keyPair using pPool and configured with settings.

◆ CreatePacketReaders()

std::shared_ptr< PacketReaders > catapult::net::CreatePacketReaders ( const std::shared_ptr< thread::IoThreadPool > &  pPool,
const ionet::ServerPacketHandlers handlers,
const crypto::KeyPair keyPair,
const ConnectionSettings settings,
uint32_t  maxConnectionsPerIdentity 
)

Creates a packet readers container for a server with a key pair of keyPair using pPool and handlers, configured with settings and allowing maxConnectionsPerIdentity.

◆ CreatePacketWriters()

std::shared_ptr< PacketWriters > catapult::net::CreatePacketWriters ( const std::shared_ptr< thread::IoThreadPool > &  pPool,
const crypto::KeyPair keyPair,
const ConnectionSettings settings 
)

Creates a packet writers container for a server with a key pair of keyPair using pPool and configured with settings.

◆ CreateServerConnector()

std::shared_ptr< ServerConnector > catapult::net::CreateServerConnector ( const std::shared_ptr< thread::IoThreadPool > &  pPool,
const crypto::KeyPair keyPair,
const ConnectionSettings settings 
)

Creates a server connector for a server with a key pair of keyPair using pPool and configured with settings.

Here is the caller graph for this function:

◆ GenerateClientChallengeResponse()

std::shared_ptr< ClientChallengeResponse > catapult::net::GenerateClientChallengeResponse ( const ServerChallengeResponse request,
const crypto::KeyPair keyPair 
)

Generates a server response to a client challenge (request) using the server key pair (keyPair).

◆ GenerateServerChallengeRequest()

std::shared_ptr< ServerChallengeRequest > catapult::net::GenerateServerChallengeRequest ( )

Generates a random server challenge request that is sent to a client.

◆ GenerateServerChallengeResponse()

std::shared_ptr< ServerChallengeResponse > catapult::net::GenerateServerChallengeResponse ( const ServerChallengeRequest request,
const crypto::KeyPair keyPair,
ionet::ConnectionSecurityMode  securityMode 
)

Generates a client response to a server challenge (request) using the client key pair (keyPair) and requests the specified security mode (securityMode).

Here is the call graph for this function:

◆ operator<<() [1/3]

std::ostream& catapult::net::operator<< ( std::ostream &  out,
NodeRequestResult  value 
)

Insertion operator for outputting value to out.

◆ operator<<() [2/3]

std::ostream& catapult::net::operator<< ( std::ostream &  out,
PeerConnectCode  value 
)

Insertion operator for outputting value to out.

◆ operator<<() [3/3]

std::ostream& catapult::net::operator<< ( std::ostream &  out,
VerifyResult  value 
)

Insertion operator for outputting value to out.

◆ PickMultiple()

std::vector< ionet::NodePacketIoPair > catapult::net::PickMultiple ( PacketIoPicker picker,
size_t  numRequested,
const utils::TimeSpan ioDuration 
)

Retrieves io interfaces to at most numRequested connections from picker. After ioDuration elapses, the connections will timeout.

Here is the call graph for this function:

◆ VerifyClient()

void catapult::net::VerifyClient ( const std::shared_ptr< ionet::PacketIo > &  pClientIo,
const crypto::KeyPair keyPair,
ionet::ConnectionSecurityMode  allowedSecurityModes,
const VerifyCallback callback 
)

Attempts to verify a client (pClientIo) and calls callback on completion. Only security modes set in allowedSecurityModes are allowed. keyPair is used for responses from the server.

◆ VerifyClientChallengeResponse()

bool catapult::net::VerifyClientChallengeResponse ( const ClientChallengeResponse response,
const Key serverPublicKey,
const Challenge challenge 
)

Verifies a server's response to challenge assuming the server has a public key of serverPublicKey.

◆ VerifyServer()

void catapult::net::VerifyServer ( const std::shared_ptr< ionet::PacketIo > &  pServerIo,
const VerifiedPeerInfo serverPeerInfo,
const crypto::KeyPair keyPair,
const VerifyCallback callback 
)

Attempts to verify a server (pServerIo) using serverPeerInfo and calls callback on completion. keyPair is used for responses from the client.

◆ VerifyServerChallengeResponse()

bool catapult::net::VerifyServerChallengeResponse ( const ServerChallengeResponse response,
const Challenge challenge 
)

Verifies a client's response to challenge.