summaryrefslogtreecommitdiff
path: root/modules/io-tls/c++/tls.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/io-tls/c++/tls.hpp')
-rw-r--r--modules/io-tls/c++/tls.hpp77
1 files changed, 77 insertions, 0 deletions
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 <forstio/common.hpp>
+#include <forstio/io/io.hpp>
+
+#include <optional>
+#include <variant>
+
+namespace saw {
+namespace net {
+template<typename T = net::Os>
+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> 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<typename T>
+class network<net::Tls<T>> {
+public:
+ virtual ~network() = default;
+
+ /**
+ * Resolve the provided string and uint16 to the preferred storage method
+ */
+ virtual conveyor<own<network_address<net::Tls<T>>>>
+ 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<own<network_address<net::Tls<T>>>>
+ parse_address(const std::string &addr, uint16_t port_hint = 0) = 0;
+
+ /**
+ * Set up a listener on this address
+ */
+ virtual error_or<own<server<T>>> listen(network_address<T> &bind_addr) = 0;
+
+ /**
+ * Connect to a remote address
+ */
+ virtual conveyor<own<io_stream<T>>> connect(network_address<T> &address) = 0;
+};
+
+template<typename T = net::Os>
+error_or<own<network<net::Tls<T>>>> setup_tls_network(network<T> &network);
+
+} // namespace saw