ConnectionCreator: use tls init
GitOrigin-RevId: f58530975f30e5341e250478c3f83cabf8947b71
This commit is contained in:
parent
795bf65f8d
commit
9289b61b92
@ -15,7 +15,7 @@ namespace mtproto {
|
||||
unique_ptr<IStreamTransport> create_transport(TransportType type) {
|
||||
switch (type.type) {
|
||||
case TransportType::ObfuscatedTcp:
|
||||
return td::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret), type.emulate_tls);
|
||||
return td::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret));
|
||||
case TransportType::Tcp:
|
||||
return td::make_unique<tcp::OldTransport>();
|
||||
case TransportType::Http:
|
||||
|
@ -123,8 +123,9 @@ class OldTransport : public IStreamTransport {
|
||||
|
||||
class ObfuscatedTransport : public IStreamTransport {
|
||||
public:
|
||||
ObfuscatedTransport(int16 dc_id, std::string secret, bool emulate_tls)
|
||||
: dc_id_(dc_id), secret_(std::move(secret)), emulate_tls_(emulate_tls), impl_(secret_.size() >= 17) {
|
||||
ObfuscatedTransport(int16 dc_id, std::string secret)
|
||||
: dc_id_(dc_id), secret_(std::move(secret)), impl_(secret_.size() >= 17) {
|
||||
emulate_tls_ = secret.size() >= 17 && secret[0] == '\0xee';
|
||||
}
|
||||
|
||||
Result<size_t> read_next(BufferSlice *message, uint32 *quick_ack) override TD_WARN_UNUSED_RESULT;
|
||||
|
@ -15,11 +15,13 @@ struct TransportType {
|
||||
enum Type { Tcp, ObfuscatedTcp, Http } type = Tcp;
|
||||
int16 dc_id{0};
|
||||
string secret;
|
||||
bool emulate_tls{false};
|
||||
|
||||
TransportType() = default;
|
||||
TransportType(Type type, int16 dc_id, string secret, bool emulate_tls = false)
|
||||
: type(type), dc_id(dc_id), secret(std::move(secret)), emulate_tls(emulate_tls) {
|
||||
TransportType(Type type, int16 dc_id, string secret) : type(type), dc_id(dc_id), secret(std::move(secret)) {
|
||||
}
|
||||
|
||||
bool emulate_tls() const {
|
||||
return secret.size() >= 17 && secret[0] == '\0xee';
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "td/mtproto/Ping.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
#include "td/mtproto/TlsInit.h"
|
||||
|
||||
#include "td/net/GetHostByNameActor.h"
|
||||
#include "td/net/HttpProxy.h"
|
||||
@ -961,6 +962,8 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
||||
client.checking_connections++;
|
||||
}
|
||||
|
||||
bool emulate_tls = extra.transport_type.emulate_tls();
|
||||
|
||||
auto promise = PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this), check_mode, transport_type = extra.transport_type, hash = client.hash,
|
||||
debug_str = extra.debug_str,
|
||||
@ -973,7 +976,7 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
||||
td::make_unique<detail::StatsCallback>(client.is_media ? media_net_stats_callback_ : common_net_stats_callback_,
|
||||
actor_id(this), client.hash, extra.stat);
|
||||
|
||||
if (proxy.use_socks5_proxy() || proxy.use_http_tcp_proxy()) {
|
||||
if (proxy.use_socks5_proxy() || proxy.use_http_tcp_proxy() || emulate_tls) {
|
||||
VLOG(connections) << "In client_loop: create new transparent proxy connection " << extra.debug_str;
|
||||
class Callback : public TransparentProxy::Callback {
|
||||
public:
|
||||
@ -1013,10 +1016,14 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
||||
children_[token] = {
|
||||
true, create_actor<Socks5>("Socks5", std::move(socket_fd), extra.mtproto_ip, proxy.proxy().user().str(),
|
||||
proxy.proxy().password().str(), std::move(callback), create_reference(token))};
|
||||
} else {
|
||||
} else if (proxy.use_http_tcp_proxy()) {
|
||||
children_[token] = {true, create_actor<HttpProxy>("HttpProxy", std::move(socket_fd), extra.mtproto_ip,
|
||||
proxy.proxy().user().str(), proxy.proxy().password().str(),
|
||||
std::move(callback), create_reference(token))};
|
||||
} else {
|
||||
children_[token] = {true, create_actor<TlsInit>("HttpProxy", std::move(socket_fd), extra.mtproto_ip,
|
||||
"www.google.com" /*todo use domain*/, "", std::move(callback),
|
||||
create_reference(token))};
|
||||
}
|
||||
} else {
|
||||
VLOG(connections) << "In client_loop: create new direct connection " << extra.debug_str;
|
||||
|
Loading…
Reference in New Issue
Block a user