From 225134d485ec3795e839ea9bbafdae214771f340 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Thu, 17 Oct 2024 19:18:14 +0200 Subject: Moved files to correct folders and changed example slightly --- modules/io-tls/c++/tls.hpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 modules/io-tls/c++/tls.hpp (limited to 'modules/io-tls/c++/tls.hpp') diff --git a/modules/io-tls/c++/tls.hpp b/modules/io-tls/c++/tls.hpp new file mode 100644 index 0000000..c5c3da1 --- /dev/null +++ b/modules/io-tls/c++/tls.hpp @@ -0,0 +1,77 @@ +#pragma once + +#include +#include + +#include +#include + +namespace saw { +namespace net { +template +struct Tls {}; +} + +class tls; + +/** +* tls context class. +* Provides tls network class which ensures the usage of tls encrypted connections +*/ +class tls { +private: + class impl; + own impl_; +public: + tls(); + ~tls(); + + struct version { + struct tls_1_0{}; + struct tls_1_1{}; + struct tls_1_2{}; + }; + + struct options { + public: + version version; + }; + + impl &get_impl(); +private: + options options_; +}; + +template +class network> { +public: + virtual ~network() = default; + + /** + * Resolve the provided string and uint16 to the preferred storage method + */ + virtual conveyor>>> + resolve_address(const std::string &addr, uint16_t port_hint = 0) = 0; + + /** + * Parse the provided string and uint16 to the preferred storage method + * Since no dns request is made here, no async conveyors have to be used. + */ + virtual error_or>>> + parse_address(const std::string &addr, uint16_t port_hint = 0) = 0; + + /** + * Set up a listener on this address + */ + virtual error_or>> listen(network_address &bind_addr) = 0; + + /** + * Connect to a remote address + */ + virtual conveyor>> connect(network_address &address) = 0; +}; + +template +error_or>>> setup_tls_network(network &network); + +} // namespace saw -- cgit v1.2.3