2019-06-26 16:13:07 +02:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2019-06-26 16:13:07 +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
|
2019-06-26 22:27:37 +02:00
|
|
|
|
2019-06-26 16:13:07 +02:00
|
|
|
#include "td/net/TransparentProxy.h"
|
|
|
|
|
2019-07-23 00:50:12 +02:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/port/IPAddress.h"
|
|
|
|
#include "td/utils/port/SocketFd.h"
|
2019-07-01 15:18:28 +02:00
|
|
|
#include "td/utils/Slice.h"
|
2019-06-26 22:27:37 +02:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
2019-06-26 16:13:07 +02:00
|
|
|
namespace td {
|
2019-07-09 05:56:06 +02:00
|
|
|
namespace mtproto {
|
2019-06-26 22:27:37 +02:00
|
|
|
|
2019-06-26 16:13:07 +02:00
|
|
|
class Grease {
|
|
|
|
public:
|
|
|
|
static void init(MutableSlice res);
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class TlsInit final : public TransparentProxy {
|
2019-06-26 16:13:07 +02:00
|
|
|
public:
|
2019-07-22 04:04:18 +02:00
|
|
|
TlsInit(SocketFd socket_fd, string domain, string secret, unique_ptr<Callback> callback, ActorShared<> parent,
|
|
|
|
double server_time_difference)
|
|
|
|
: TransparentProxy(std::move(socket_fd), IPAddress(), std::move(domain), std::move(secret), std::move(callback),
|
|
|
|
std::move(parent))
|
2019-07-04 15:14:11 +02:00
|
|
|
, server_time_difference_(server_time_difference) {
|
|
|
|
}
|
2019-06-26 16:13:07 +02:00
|
|
|
|
|
|
|
private:
|
2019-07-04 15:14:11 +02:00
|
|
|
double server_time_difference_{0};
|
2019-06-26 16:13:07 +02:00
|
|
|
enum class State {
|
|
|
|
SendHello,
|
|
|
|
WaitHelloResponse,
|
|
|
|
} state_ = State::SendHello;
|
2019-07-02 17:14:13 +02:00
|
|
|
std::string hello_rand_;
|
2019-06-26 16:13:07 +02:00
|
|
|
|
|
|
|
void send_hello();
|
|
|
|
Status wait_hello_response();
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
Status loop_impl() final;
|
2019-06-26 16:13:07 +02:00
|
|
|
};
|
2019-06-26 22:27:37 +02:00
|
|
|
|
2019-07-09 05:56:06 +02:00
|
|
|
} // namespace mtproto
|
2019-06-26 16:13:07 +02:00
|
|
|
} // namespace td
|