diff --git a/td/mtproto/TlsInit.cpp b/td/mtproto/TlsInit.cpp index 6958d0e4c..033bf6843 100644 --- a/td/mtproto/TlsInit.cpp +++ b/td/mtproto/TlsInit.cpp @@ -346,7 +346,7 @@ class TlsObfusaction { void TlsInit::send_hello() { auto hello = - TlsObfusaction::generate_header(username_, password_, static_cast(Clocks::system())); // TODO correct time + TlsObfusaction::generate_header(username_, password_, static_cast(Time::now() + server_time_difference_)); hello_rand_ = hello.substr(11, 32); fd_.output_buffer().append(hello); state_ = State::WaitHelloResponse; diff --git a/td/mtproto/TlsInit.h b/td/mtproto/TlsInit.h index ab6a862b2..92d075482 100644 --- a/td/mtproto/TlsInit.h +++ b/td/mtproto/TlsInit.h @@ -20,9 +20,15 @@ class Grease { class TlsInit : public TransparentProxy { public: - using TransparentProxy::TransparentProxy; + TlsInit(SocketFd socket_fd, IPAddress ip_address, string domain, string secret, unique_ptr callback, + ActorShared<> parent, double server_time_difference) + : TransparentProxy(std::move(socket_fd), std::move(ip_address), std::move(domain), std::move(secret), + std::move(callback), std::move(parent)) + , server_time_difference_(server_time_difference) { + } private: + double server_time_difference_{0}; enum class State { SendHello, WaitHelloResponse, diff --git a/td/telegram/net/ConnectionCreator.cpp b/td/telegram/net/ConnectionCreator.cpp index 356f3a42a..82579dbc1 100644 --- a/td/telegram/net/ConnectionCreator.cpp +++ b/td/telegram/net/ConnectionCreator.cpp @@ -544,7 +544,7 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address children_[token] = { false, create_actor("PingTlsInit", std::move(socket_fd), extra.mtproto_ip, "www.google.com", hex_decode(proxy.proxy().secret().substr(2)).move_as_ok(), std::move(callback), - create_reference(token))}; + create_reference(token), G()->get_server_time_difference())}; } else { UNREACHABLE(); } @@ -1033,7 +1033,7 @@ void ConnectionCreator::client_loop(ClientInfo &client) { children_[token] = { true, create_actor("TlsInit", std::move(socket_fd), extra.mtproto_ip, "www.google.com", hex_decode(proxy.proxy().secret().substr(2)).move_as_ok(), std::move(callback), - create_reference(token))}; + create_reference(token), G()->get_server_time_difference())}; } else { UNREACHABLE(); } diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index afb146d37..d7e0cca7e 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -955,7 +955,6 @@ void Session::connection_open_finish(ConnectionInfo *info, } } - // mtproto::TransportType transport_type = raw_connection->get_transport_type(); mtproto::SessionConnection::Mode mode; Slice mode_name; if (mode_ == Mode::Tcp) { diff --git a/test/mtproto.cpp b/test/mtproto.cpp index 568fbe36e..05f3d89cb 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -620,7 +620,7 @@ TEST(Mtproto, TlsObfusaction) { ip_address.init_host_port(domain, 443).ensure(); SocketFd fd = SocketFd::open(ip_address).move_as_ok(); create_actor("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret", make_unique(), - ActorShared<>()) + ActorShared<>(), Clocks::system() - Time::now()) .release(); }