CatapultServer  v0.5.0.1 (Elephant)
ServerConnector.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ConnectionSettings.h"
23 #include "PeerConnectCode.h"
24 #include "catapult/functions.h"
25 #include <memory>
26 
27 namespace catapult {
28  namespace crypto { class KeyPair; }
29  namespace ionet {
30  class Node;
31  class PacketSocket;
32  }
33  namespace thread { class IoThreadPool; }
34 }
35 
36 namespace catapult { namespace net {
37 
40  public:
43 
44  public:
45  virtual ~ServerConnector() = default;
46 
47  public:
49  virtual size_t numActiveConnections() const = 0;
50 
51  public:
53  virtual void connect(const ionet::Node& node, const ConnectCallback& callback) = 0;
54 
56  virtual void shutdown() = 0;
57  };
58 
60  std::shared_ptr<ServerConnector> CreateServerConnector(
61  const std::shared_ptr<thread::IoThreadPool>& pPool,
62  const crypto::KeyPair& keyPair,
63  const ConnectionSettings& settings);
64 }}
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
catapult::ionet::Connect
action Connect(boost::asio::io_context &ioContext, const PacketSocketOptions &options, const NodeEndpoint &endpoint, const ConnectCallback &callback)
Definition: PacketSocket.cpp:525
catapult::ionet::ConnectCallback
consumer< ConnectResult, const std::shared_ptr< PacketSocket > & > ConnectCallback
Callback for a connected socket.
Definition: PacketSocket.h:125
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::net::ConnectionSettings
Settings used to configure connections.
Definition: ConnectionSettings.h:31
catapult::ionet::Secure
std::shared_ptr< PacketSocket > Secure(const std::shared_ptr< PacketSocket > &pSocket, ConnectionSecurityMode securityMode, const crypto::KeyPair &sourceKeyPair, const Key &remoteKey, utils::FileSize maxPacketDataSize)
Definition: SecurePacketSocketDecorator.cpp:85
colorPrint.warning
def warning(*args)
Definition: colorPrint.py:10
m_settings
ConnectionSettings m_settings
Definition: ServerConnector.cpp:114
catapult::net::ServerConnector::ConnectCallback
consumer< PeerConnectCode, const std::shared_ptr< ionet::PacketSocket > & > ConnectCallback
A callback that is passed the connect result and the connected socket on success.
Definition: ServerConnector.h:42
catapult::net::VerifyServer
void VerifyServer(const std::shared_ptr< ionet::PacketIo > &pServerIo, const VerifiedPeerInfo &serverPeerInfo, const crypto::KeyPair &keyPair, const VerifyCallback &callback)
Definition: VerifyPeer.cpp:201
catapult::net::CreateServerConnector
std::shared_ptr< ServerConnector > 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 se...
Definition: ServerConnector.cpp:119
m_pPool
std::shared_ptr< thread::IoThreadPool > m_pPool
Definition: ServerConnector.cpp:112
catapult::net::ServerConnector::shutdown
virtual void shutdown()=0
Shuts down all connections.
VerifyPeer.h
functions.h
PeerConnectCode.h
KeyPair.h
catapult::net::ServerConnector::~ServerConnector
virtual ~ServerConnector()=default
PacketSocket.h
catapult::thread::MakeTimedCallback
auto MakeTimedCallback(boost::asio::io_context &ioContext, TCallback callback, TCallbackArgs &&... timeoutArgs)
Definition: TimedCallback.h:170
catapult::crypto::KeyPair
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
catapult::net::ServerConnector::numActiveConnections
virtual size_t numActiveConnections() const =0
Gets the number of active connections.
Node.h
IoThreadPool.h
ConnectionSettings.h
forwardsValidation.info
def info(*args)
Definition: forwardsValidation.py:12
catapult::ionet::socket
boost::asio::ip::tcp::socket socket
Definition: IoTypes.h:30
m_keyPair
const crypto::KeyPair & m_keyPair
Definition: ServerConnector.cpp:113
ServerConnector.h
pSocket
SocketPointer pSocket
Definition: PacketWriters.cpp:46
Node
ionet::Node Node
Definition: PacketWriters.cpp:45
catapult
Definition: AddressExtractionExtension.cpp:28
Logging.h
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82
catapult::consumer
std::function< void(TArgs...)> consumer
A consumer function.
Definition: functions.h:35
catapult::net::ServerConnector::connect
virtual void connect(const ionet::Node &node, const ConnectCallback &callback)=0
Attempts to connect to node and calls callback on completion.
catapult::Key
utils::ByteArray< Key_Size, Key_tag > Key
Definition: src/catapult/types.h:41
WeakContainer.h
catapult::net::ServerConnector
Establishes connections with external nodes that this (local) node initiates.
Definition: ServerConnector.h:39
SecurePacketSocketDecorator.h
TimedCallback.h
m_sockets
utils::WeakContainer< ionet::PacketSocket > m_sockets
Definition: ServerConnector.cpp:115