12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- /*
- * TLS client implementation using GnuTLS
- * Dependencies: bzbnet, GnuTLS
- */
- #include "socket.h"
- namespace bzbnet {
- constexpr unsigned int DEFAULT_TLS_PACKETSIZE = 512;
- /*
- * Initializes te GnuTLS library and credentials structure.
- * TLSClient calls this function automatically.
- */
- void initialize_tls();
- /*
- * Destroys the GnuTLS library and credentials structure.
- */
- void destroy_tls();
- class TLSClient {
- private:
- TCPSocket socket;
- void* session_ptr;
- public:
- TLSClient();
-
- ~TLSClient();
-
- void connect(std::string hostname, std::string service = "443");
- std::vector<char> recv(unsigned int packetsize = DEFAULT_TLS_PACKETSIZE);
- void send(std::string data);
- void send(std::vector<char> data);
- void close();
- bool is_open();
- int get_raw_fd();
- };
- }
|