2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#ifndef NET_CONFIG_CONFIGTLSCLIENT_H
43#define NET_CONFIG_CONFIGTLSCLIENT_H
45#include "net/config/ConfigTls.h"
53#ifndef DOXYGEN_SHOULD_SKIP_THIS
72 std::string
getSni()
const;
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) override
~SimpleSocketProtocolFactory() override
void onDisconnected() override
~SimpleSocketProtocol() override
web::http::client::ResponseParser * responseParser
SimpleSocketProtocol(core::socket::stream::SocketConnection *socketConnection)
bool onSignal(int signum) override
void onConnected() override
void onReadError(int errnum) override
void onWriteError(int errnum) override
std::size_t onReceivedFromPeer() override
static void atNextTick(const std::function< void(void)> &callBack)
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
void timeoutEvent() final
ConnectEventReceiver(const std::string &name, const utils::Timeval &timeout)
void signalEvent(int signum) override
virtual void connectTimeout()
virtual void connectEvent()=0
void dispatchEvent() final
Config & getConfig() const
State & operator&=(int state)
static constexpr int DISABLED
bool operator==(const int &state) const
State operator&(int state)
static constexpr int ERROR
static constexpr int FATAL
static constexpr int NO_RETRY
SocketClient(const std::string &name, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, Args &&... args)
const SocketClient & connect(const SocketAddress &remoteAddress, const SocketAddress &localAddress, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
SocketClient(const std::shared_ptr< Config > &config, const std::shared_ptr< SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect)
std::function< void(SocketConnection *)> & getOnDisconnect() const
SocketClient(const std::string &name, Args &&... args)
SocketContextFactoryT SocketContextFactory
std::function< void(const std::shared_ptr< AutoConnectControl > &)> & getOnAutoConnectControl()
const SocketClient & setOnInitState(const std::function< void(core::eventreceiver::ConnectEventReceiver *)> &onInitState, bool initialize=false) const
const SocketClient & connect(const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
typename SocketConnector::SocketAddress SocketAddress
const SocketClient & setOnConnect(const std::function< void(SocketConnection *)> &onConnect, bool initialize=false) const
std::function< void(SocketConnection *)> & getOnConnected() const
const SocketClient & realConnect(const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, unsigned int tries, double retryTimeoutScale) const
typename SocketConnector::SocketConnection SocketConnection
std::shared_ptr< SocketContextFactory > getSocketContextFactory() const
SocketClient(const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, Args &&... args)
typename SocketConnector::Config Config
SocketConnectorT SocketConnector
const SocketClient & setOnDisconnect(const std::function< void(SocketConnection *)> &onDisconnect, bool initialize=false) const
const SocketClient & setOnAutoConnectControl(const std::function< void(const std::shared_ptr< AutoConnectControl > &)> &onAutoConnectControl, bool initialize=false) const
core::socket::Socket< typename SocketConnector::Config > Super
std::function< void(core::eventreceiver::ConnectEventReceiver *)> & getOnInitState() const
SocketClient(const std::shared_ptr< Config > &config, const std::shared_ptr< Context > &sharedContext)
std::function< void(SocketConnection *)> & getOnConnect()
const SocketClient & connect(const SocketAddress &remoteAddress, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
SocketClient(Args &&... args)
std::shared_ptr< Context > sharedContext
const SocketClient & setOnConnected(const std::function< void(SocketConnection *)> &onConnected, bool initialize=false) const
const SocketAddress & getRemoteAddress() const final
const SocketAddress & getLocalAddress() const final
void sendToPeer(const std::string &data)
SocketConnector(const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, const std::function< void(core::eventreceiver::ConnectEventReceiver *)> &onInitState, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, const std::shared_ptr< Config > &config)
typename PhysicalClientSocket::SocketAddress SocketAddress
SocketAddress remoteAddress
virtual void useNextSocketAddress()=0
void connectTimeout() final
SocketConnector(const SocketConnector &socketConnector)
std::function< void(const SocketAddress &, core::socket::State)> onStatus
SocketConnectionT< PhysicalClientSocket, Config > SocketConnection
std::function< void(SocketConnection *)> onConnected
PhysicalClientSocket physicalClientSocket
std::shared_ptr< Config > config
std::function< void(SocketConnection *)> onDisconnect
PhysicalSocketClientT PhysicalClientSocket
std::function< void(core::eventreceiver::ConnectEventReceiver *)> onInitState
std::function< void(SocketConnection *)> onConnect
void unobservedEvent() final
void connectEvent() final
~SocketConnector() override
SocketContext(core::socket::stream::SocketConnection *socketConnection)
void onReadError(int errnum) override
void onWriteError(int errnum) override
typename Super::SocketAddress SocketAddress
SocketConnector(const std::shared_ptr< core::socket::stream::SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, const std::function< void(core::eventreceiver::ConnectEventReceiver *)> &onInitState, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, const std::shared_ptr< Config > &config)
typename Super::Config Config
core::socket::stream::SocketConnector< PhysicalClientSocketT, ConfigT, core::socket::stream::legacy::SocketConnection > Super
SocketConnector(const SocketConnector &socketConnector)
void useNextSocketAddress() override
typename Super::SocketConnection SocketConnection
utils::Timeval sslShutdownTimeout
SocketConnection(PhysicalSocket &&physicalSocket, const std::function< void(SocketConnection *)> &onDisconnect, const std::shared_ptr< Config > &config)
typename Super::SocketReader SocketReader
SSL * startSSL(int fd, SSL_CTX *ctx)
core::socket::stream:: SocketConnectionT< PhysicalSocketT, core::socket::stream::tls::SocketReader, core::socket::stream::tls::SocketWriter, ConfigT > Super
typename Super::SocketAddress SocketAddress
void doWriteShutdown(const std::function< void()> &onShutdown) final
utils::Timeval sslInitTimeout
void onReadShutdown() final
PhysicalSocketT PhysicalSocket
bool doSSLHandshake(const std::function< void()> &onSuccess, const std::function< void()> &onTimeout, const std::function< void(int)> &onStatus) final
typename Super::SocketWriter SocketWriter
core::socket::stream::SocketConnector< PhysicalSocketClientT, ConfigT, core::socket::stream::tls::SocketConnection > Super
typename Super::SocketAddress SocketAddress
void useNextSocketAddress() override
SocketConnector(const SocketConnector &socketConnector)
typename Super::SocketConnection SocketConnection
SocketConnector(const std::shared_ptr< core::socket::stream::SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, const std::function< void(core::eventreceiver::ConnectEventReceiver *)> &onInitState, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, const std::shared_ptr< Config > &config)
typename Super::Config Config
virtual void onReadShutdown()=0
virtual bool doSSLHandshake(const std::function< void()> &onSuccess, const std::function< void()> &onTimeout, const std::function< void(int)> &onStatus)=0
ssize_t read(char *chunk, std::size_t chunkLen) override
core::socket::stream::SocketReader Super
core::socket::stream::SocketWriter Super
virtual bool doSSLHandshake(const std::function< void()> &onSuccess, const std::function< void()> &onTimeout, const std::function< void(int)> &onStatus)=0
ssize_t write(const char *chunk, std::size_t chunkLen) override
const std::string & getInstanceName() const
~ConfigPhysicalSocketClient() override
CLI::Option * reconnectTimeOpt
ConfigPhysicalSocketClient(ConfigInstance *instance)
CLI::Option * connectTimeoutOpt
ConfigPhysicalSocket Super
CLI::Option * reconnectOpt
ConfigPhysicalSocketClient & setReconnectTime(double time)
bool getReconnect() const
ConfigPhysicalSocketClient & setReconnect(bool reconnect=true)
double getReconnectTime() const
utils::Timeval getConnectTimeout() const
ConfigPhysicalSocketClient & setConnectTimeout(const utils::Timeval &connectTimeout)
~ConfigTlsClient() override
ConfigTlsClient & setSni(const std::string &sni)
std::string getSni() const
ConfigTlsClient(ConfigInstance *instance)
ConfigAddressLocalT< net::config::ConfigAddressLocal > Local
ConfigAddressRemoteT< net::config::ConfigAddressRemote > Remote
ConfigSocketClient(net::config::ConfigInstance *instance)
net::config::ConfigPhysicalSocketClient Socket
net::config::ConfigConnection Connection
ConfigSocketClient(const std::string &name)
net::config::ConfigInstance Instance
net::config::ConfigLegacy Legacy
net::config::ConfigInstance Instance
ConfigSocketClient(const std::string &name)
net::config::ConfigTlsClient Tls
~ConfigSocketClient() override
SocketAddress(const std::string &ipOrHostname, uint16_t port)
std::string getCanonName() const
std::string toString(bool expanded=true) const override
void init(const Hints &hints={.aiFlags=0,.aiSockType=0,.aiProtocol=0})
PhysicalSocketClient(PhysicalSocketClient &&) noexcept=default
net::in::phy::stream::PhysicalSocket< net::phy::stream::PhysicalSocketClient > Super
~PhysicalSocketClient() override
const Super & connect(const std::string &ipOrHostname, uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
core::socket::stream:: SocketClient< SocketConnectorT< net::in::phy::stream::PhysicalSocketClient, ConfigSocketClientT >, SocketContextFactoryT, Args... > Super
const Super & connect(const std::string &ipOrHostname, uint16_t port, const std::string &bindHost, uint16_t bindPort, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const Super & connect(const std::string &ipOrHostname, uint16_t port, const std::string &bindHost, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const Super & connect(const std::string &ipOrHostname, uint16_t port, uint16_t bindPort, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
bool getDisableNagleAlgorithm() const
CLI::Option * disableNagleAlgorithmOpt
ConfigSocketClient & setDisableNagleAlgorithm(bool disableNagleAlgorithm=true)
ConfigSocketClient(net::config::ConfigInstance *instance)
~ConfigSocketClient() override
~ConfigSocketClient() override
ConfigSocketClient(const std::string &name)
~ConfigSocketClient() override
ConfigSocketClient(const std::string &name)
int connect(SocketAddress &remoteAddress)
net::phy::stream::PhysicalSocket< SocketAddressT > Super
static bool connectInProgress(int cErrno)
SocketAddressT SocketAddress
static double getInRange(double ll, double ul)
ResponseParser(core::socket::stream::SocketContext *socketContext, const std::function< void()> &onResponseStart, const std::function< void(Response &)> &onResponseParsed, const std::function< void(int, const std::string &)> &onResponseParseError)
int main(int argc, char *argv[])
static web::http::client::ResponseParser * getResponseParser(core::socket::stream::SocketContext *socketContext)
SocketClient Client(const std::string &instanceName, Args &&... socketContextFactoryArgs)
SocketClient Client(const std::string &instanceName, const std::function< void(typename SocketClient::Config &)> &configurator, Args &&... socketContextFactoryArgs)
net::in::stream::legacy::SocketClient< apps::http::SimpleSocketProtocolFactory > SocketClient
SocketClient::SocketAddress SocketAddress
SocketClient::SocketConnection SocketConnection
SocketClient getLegacyClient()
SocketClient< SocketContextFactory, SocketContextFactoryArgs... > Client(const std::string &instanceName, SocketContextFactoryArgs &&... socketContextFactoryArgs)
net::in::stream::SocketClient< core::socket::stream::legacy::SocketConnector, net::in::stream::legacy::config::ConfigSocketClient, SocketContextFactoryT, Args... > SocketClient
SocketClient< SocketContextFactory, SocketContextFactoryArgs... > Client(const std::string &instanceName, const std::function< void(net::in::stream::legacy::config::ConfigSocketClient &)> &configurator, SocketContextFactoryArgs &&... socketContextFactoryArgs)
net::in::stream::SocketClient< core::socket::stream::tls::SocketConnector, net::in::stream::tls::config::ConfigSocketClient, SocketContextFactoryT, Args... > SocketClient
SocketClient< SocketContextFactory, SocketContextFactoryArgs... > Client(const std::string &instanceName, const std::function< void(net::in::stream::tls::config::ConfigSocketClient &)> &configurator, SocketContextFactoryArgs &&... socketContextFactoryArgs)
SocketClient< SocketContextFactory, SocketContextFactoryArgs... > Client(const std::string &instanceName, SocketContextFactoryArgs &&... socketContextFactoryArgs)
net::in::stream::tls::SocketClient< apps::http::SimpleSocketProtocolFactory > SocketClient
SocketClient::SocketConnection SocketConnection
SocketClient::SocketAddress SocketAddress
std::function< void(SocketConnection *)> onConnect
std::shared_ptr< SocketContextFactory > socketContextFactory
std::function< void(const std::shared_ptr< AutoConnectControl > &)> onAutoConnectControl
std::function< void(core::eventreceiver::ConnectEventReceiver *)> onInitState
std::shared_ptr< AutoConnectControl > autoConnectControl
std::function< void(SocketConnection *)> onConnected
std::function< void(SocketConnection *)> onDisconnect
Context(const std::shared_ptr< SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect)