SSLStream (WIP)
This commit is contained in:
44
source/mijin/net/ssl.hpp
Normal file
44
source/mijin/net/ssl.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(MIJIN_NET_SSL_HPP_INCLUDED)
|
||||
#define MIJIN_NET_SSL_HPP_INCLUDED 1
|
||||
|
||||
#if !MIJIN_ENABLE_OPENSSL
|
||||
#error "SSL support not enabled. Set MIJIN_ENABLE_OPENSSL to True in your environment settings."
|
||||
#endif // !MIJIN_ENABLE_OPENSSL
|
||||
|
||||
#include <memory>
|
||||
#include "../io/stream.hpp"
|
||||
|
||||
namespace mijin
|
||||
{
|
||||
class SSLStream : public Stream
|
||||
{
|
||||
private:
|
||||
Stream* base_ = nullptr;
|
||||
void* ssl_ = nullptr;
|
||||
void* bioA_ = nullptr;
|
||||
void* bioB_ = nullptr;
|
||||
public:
|
||||
StreamError open(Stream& base, const std::string& hostname) noexcept;
|
||||
void close() noexcept;
|
||||
|
||||
StreamError readRaw(std::span<std::uint8_t> buffer, const ReadOptions& options, std::size_t* outBytesRead) override;
|
||||
StreamError writeRaw(std::span<const std::uint8_t> buffer) override;
|
||||
std::size_t tell() override;
|
||||
StreamError seek(std::intptr_t pos, SeekMode seekMode) override;
|
||||
void flush() override;
|
||||
bool isAtEnd() override;
|
||||
StreamFeatures getFeatures() override;
|
||||
private:
|
||||
StreamError bioToBase() noexcept;
|
||||
StreamError baseToBio() noexcept;
|
||||
// mijin::Task<StreamError> c_readRaw(std::span<std::uint8_t> buffer, const ReadOptions& options = {}, std::size_t* outBytesRead = nullptr) override;
|
||||
// mijin::Task<StreamError> c_writeRaw(std::span<const std::uint8_t> buffer) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !defined(MIJIN_NET_SSL_HPP_INCLUDED)
|
||||
|
||||
Reference in New Issue
Block a user