2018-08-15 14:41:42 +02:00
|
|
|
//
|
2020-01-01 02:23:48 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
2018-08-15 14:41:42 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2018-08-15 22:05:06 +02:00
|
|
|
#include "td/utils/ByteFlow.h"
|
2018-08-15 14:41:42 +02:00
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
class SslStreamImpl;
|
2019-07-22 06:01:51 +02:00
|
|
|
} // namespace detail
|
2018-08-15 14:41:42 +02:00
|
|
|
|
|
|
|
class SslStream {
|
|
|
|
public:
|
|
|
|
SslStream();
|
|
|
|
SslStream(SslStream &&);
|
|
|
|
SslStream &operator=(SslStream &&);
|
|
|
|
~SslStream();
|
|
|
|
|
|
|
|
enum class VerifyPeer { On, Off };
|
|
|
|
|
2020-09-14 02:58:57 +02:00
|
|
|
static Result<SslStream> create(CSlice host, CSlice cert_file = CSlice(), VerifyPeer verify_peer = VerifyPeer::On,
|
|
|
|
bool check_ip_address_as_host = false);
|
2018-08-15 14:41:42 +02:00
|
|
|
|
|
|
|
ByteFlowInterface &read_byte_flow();
|
|
|
|
ByteFlowInterface &write_byte_flow();
|
|
|
|
|
|
|
|
size_t flow_read(MutableSlice slice);
|
|
|
|
size_t flow_write(Slice slice);
|
|
|
|
|
|
|
|
explicit operator bool() const {
|
2018-10-15 10:23:51 +02:00
|
|
|
return static_cast<bool>(impl_);
|
2018-08-15 14:41:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-09-27 03:19:03 +02:00
|
|
|
unique_ptr<detail::SslStreamImpl> impl_;
|
2018-08-15 14:41:42 +02:00
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
explicit SslStream(unique_ptr<detail::SslStreamImpl> impl);
|
2018-08-15 14:41:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|