TlsInit: use server_time_difference
GitOrigin-RevId: 03d93412b660be3a968a4963fb28abafe068a58d
This commit is contained in:
parent
33e306f800
commit
e9a7dd637d
@ -346,7 +346,7 @@ class TlsObfusaction {
|
|||||||
|
|
||||||
void TlsInit::send_hello() {
|
void TlsInit::send_hello() {
|
||||||
auto hello =
|
auto hello =
|
||||||
TlsObfusaction::generate_header(username_, password_, static_cast<int32>(Clocks::system())); // TODO correct time
|
TlsObfusaction::generate_header(username_, password_, static_cast<int32>(Time::now() + server_time_difference_));
|
||||||
hello_rand_ = hello.substr(11, 32);
|
hello_rand_ = hello.substr(11, 32);
|
||||||
fd_.output_buffer().append(hello);
|
fd_.output_buffer().append(hello);
|
||||||
state_ = State::WaitHelloResponse;
|
state_ = State::WaitHelloResponse;
|
||||||
|
@ -20,9 +20,15 @@ class Grease {
|
|||||||
|
|
||||||
class TlsInit : public TransparentProxy {
|
class TlsInit : public TransparentProxy {
|
||||||
public:
|
public:
|
||||||
using TransparentProxy::TransparentProxy;
|
TlsInit(SocketFd socket_fd, IPAddress ip_address, string domain, string secret, unique_ptr<Callback> 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:
|
private:
|
||||||
|
double server_time_difference_{0};
|
||||||
enum class State {
|
enum class State {
|
||||||
SendHello,
|
SendHello,
|
||||||
WaitHelloResponse,
|
WaitHelloResponse,
|
||||||
|
@ -544,7 +544,7 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address
|
|||||||
children_[token] = {
|
children_[token] = {
|
||||||
false, create_actor<TlsInit>("PingTlsInit", std::move(socket_fd), extra.mtproto_ip, "www.google.com",
|
false, create_actor<TlsInit>("PingTlsInit", std::move(socket_fd), extra.mtproto_ip, "www.google.com",
|
||||||
hex_decode(proxy.proxy().secret().substr(2)).move_as_ok(), std::move(callback),
|
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 {
|
} else {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -1033,7 +1033,7 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
|||||||
children_[token] = {
|
children_[token] = {
|
||||||
true, create_actor<TlsInit>("TlsInit", std::move(socket_fd), extra.mtproto_ip, "www.google.com",
|
true, create_actor<TlsInit>("TlsInit", std::move(socket_fd), extra.mtproto_ip, "www.google.com",
|
||||||
hex_decode(proxy.proxy().secret().substr(2)).move_as_ok(), std::move(callback),
|
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 {
|
} else {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -955,7 +955,6 @@ void Session::connection_open_finish(ConnectionInfo *info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mtproto::TransportType transport_type = raw_connection->get_transport_type();
|
|
||||||
mtproto::SessionConnection::Mode mode;
|
mtproto::SessionConnection::Mode mode;
|
||||||
Slice mode_name;
|
Slice mode_name;
|
||||||
if (mode_ == Mode::Tcp) {
|
if (mode_ == Mode::Tcp) {
|
||||||
|
@ -620,7 +620,7 @@ TEST(Mtproto, TlsObfusaction) {
|
|||||||
ip_address.init_host_port(domain, 443).ensure();
|
ip_address.init_host_port(domain, 443).ensure();
|
||||||
SocketFd fd = SocketFd::open(ip_address).move_as_ok();
|
SocketFd fd = SocketFd::open(ip_address).move_as_ok();
|
||||||
create_actor<TlsInit>("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret", make_unique<Callback>(),
|
create_actor<TlsInit>("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret", make_unique<Callback>(),
|
||||||
ActorShared<>())
|
ActorShared<>(), Clocks::system() - Time::now())
|
||||||
.release();
|
.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user