SNode.C
Loading...
Searching...
No Matches
TlsLegacySocketContext.h
Go to the documentation of this file.
1/*
2 * SNode.C - A Slim Toolkit for Network Communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025, 2026
5 */
6
7#ifndef APPS_TLSLEGACY_TLSLEGACYSOCKETCONTEXT_H
8#define APPS_TLSLEGACY_TLSLEGACYSOCKETCONTEXT_H
9
10#include "core/socket/stream/SocketContext.h"
11#include "core/socket/stream/SocketContextFactory.h"
12#include "core/timer/Timer.h"
13
14namespace core::socket::stream {
15 class SocketConnection;
16}
17
18#include <cstddef>
19#include <string>
20
21namespace apps::tlslegacy {
22
23 class TlsLegacySocketContext : public core::socket::stream::SocketContext {
24 public:
25 enum class Role { SERVER, CLIENT };
26
27 explicit TlsLegacySocketContext(core::socket::stream::SocketConnection* socketConnection, Role role);
28
29 private:
30 void onConnected() override;
31 void onDisconnected() override;
32 bool onSignal(int signum) override;
33 std::size_t onReceivedFromPeer() override;
34
35 void onClientLine(const std::string& line);
36 void onServerLine(const std::string& line);
37 void startLegacyRetryTimer(const std::string& payload);
38
40 std::string inboundBuffer;
41
42 bool tlsReplySeen = false;
43 bool legacyReplySeen = false;
44 bool legacyPayloadSeen = false;
45
47 };
48
50 private:
51 core::socket::stream::SocketContext* create(core::socket::stream::SocketConnection* socketConnection) override;
52 };
53
55 private:
56 core::socket::stream::SocketContext* create(core::socket::stream::SocketConnection* socketConnection) override;
57 };
58
59} // namespace apps::tlslegacy
60
61#endif
#define LOG(level)
Definition Logger.h:148
#define VLOG(level)
Definition Logger.h:164
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) override
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) override
void startLegacyRetryTimer(const std::string &payload)
TlsLegacySocketContext(core::socket::stream::SocketConnection *socketConnection, Role role)
static void init(int argc, char *argv[])
Definition SNodeC.cpp:54
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
Definition SNodeC.cpp:60
Config * getConfig() const
Definition Socket.hpp:65
bool operator==(const int &state) const
Definition State.cpp:74
static constexpr int ERROR
Definition State.h:57
std::string what() const
Definition State.cpp:114
static constexpr int OK
Definition State.h:55
const SocketClient & connect(const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
LogMessage(Level level, int verboseLevel=-1, bool withErrno=false)
Definition Logger.cpp:280
const std::string & getInstanceName() const
ConfigTls * setNoCloseNotifyIsEOF(bool noCloseNotifyIsEOF=true)
ConfigTls * setCertKey(const std::string &certKey)
Definition ConfigTls.cpp:63
ConfigTls * setCaCert(const std::string &caCert)
Definition ConfigTls.cpp:83
ConfigTls * setCert(const std::string &cert)
Definition ConfigTls.cpp:53
ConfigTls * setCaCertAcceptUnknown(bool set=true)
ConfigTls * setCertKeyPassword(const std::string &certKeyPassword)
Definition ConfigTls.cpp:73
std::string toString(bool expanded=true) const override
int main(int argc, char *argv[])
Definition Timer.h:59
net::in::stream::SocketClient< core::socket::stream::tls::SocketConnector, net::in::stream::tls::config::ConfigSocketClient, SocketContextFactoryT, Args... > SocketClient