diff options
Diffstat (limited to 'forstio/io-tls/tls.h')
-rw-r--r-- | forstio/io-tls/tls.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/forstio/io-tls/tls.h b/forstio/io-tls/tls.h new file mode 100644 index 0000000..8a31c1d --- /dev/null +++ b/forstio/io-tls/tls.h @@ -0,0 +1,70 @@ +#pragma once + +#include <forstio/core/common.h> +#include <forstio/io/io.h> + +#include <optional> +#include <variant> + +namespace saw { +class Tls; + +class TlsServer final : public server { +private: + own<server> internal; + +public: + TlsServer(own<server> srv); + + conveyor<own<io_stream>> accept() override; +}; + +class TlsNetwork final : public network { +private: + Tls& tls; + network &internal; +public: + TlsNetwork(Tls& tls_, network &network_); + + conveyor<own<network_address>> resolve_address(const std::string &addr, uint16_t port = 0) override; + + own<server> listen(network_address& address) override; + + conveyor<own<io_stream>> connect(network_address& address) override; + + own<class datagram> datagram(network_address& address) override; +}; + +/** +* Tls context class. +* Provides tls network class which ensures the usage of tls encrypted connections +*/ +class Tls { +private: + class Impl; + own<Impl> impl; +public: + Tls(); + ~Tls(); + + struct Version { + struct Tls_1_0{}; + struct Tls_1_1{}; + struct Tls_1_2{}; + }; + + struct Options { + public: + Version version; + }; + + network& tlsNetwork(); + + Impl &getImpl(); +private: + Options options; +}; + +std::optional<own<TlsNetwork>> setupTlsNetwork(network &network); + +} // namespace saw |