ZaStoGram_desktop/Telegram/SourceFiles/mtproto/proxy/socket_factory.cpp
loop-uh b357341160 Правки после слияния 7.4.7: NaiveSocket без флага файлов, очередь отложенных запросов, делегат сессии
- NaiveSocket по образцу TcpSocket 7.4.7 (без protocolForFiles и размеров буферов);
- failOverAuthImports чистит отложенные повторы через RequestRegistry::removeDelayed
  (очередь живёт в реестре форка);
- Session уведомляет о смене временного ключа через делегат, а не Instance.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 08:04:45 -05:00

85 lines
2.1 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "mtproto/proxy/socket_factory.h"
#include "mtproto/proxy/mtproxy/tls_socket.h"
#include "mtproto/proxy/wss/socket.h"
#include "mtproto/details/mtproto_web_proxy_socket.h"
#include "mtproto/transport/details/mtproto_tcp_socket.h"
#include "zsg_naive/zsg_naive_socket.h"
namespace MTP::details {
std::unique_ptr<AbstractSocket> CreateProxyAwareSocket(
not_null<RuntimeEnvironment*> runtime,
not_null<QThread*> thread,
const bytes::vector &secret,
const ProxyData &proxy,
bool protocolForFiles,
const ProxyStealthOptions &stealth,
int16 protocolDcId,
ProxyConnectionAttempt mtproxyAttempt,
MtProxyAttemptPlan mtproxyPlan,
crl::time mtproxyAttemptStartedAt,
bool wssFront) {
if (proxy.type == ProxyData::Type::Web) {
return std::make_unique<WebProxySocket>(
runtime,
thread,
proxy,
mtproxyAttempt.use);
}
if (proxy.type == ProxyData::Type::Naive) {
return std::make_unique<Zsg::Naive::NaiveSocket>(
runtime,
thread,
proxy);
}
const auto networkProxy = ToNetworkProxy(proxy);
if (stealth.transport == ProxyTransport::Wss) {
auto route = WssCustomRoute(stealth);
if (!route && wssFront) {
route = WssFrontRoute(protocolDcId);
}
if (!route) {
route = WssOfficialRoute(protocolDcId);
}
if (route && route->direct) {
return std::make_unique<WssDirectStepSocket>(
runtime,
thread,
networkProxy,
protocolForFiles,
std::move(*route));
} else if (route) {
return std::make_unique<WssSocket>(
runtime,
thread,
networkProxy,
protocolForFiles,
std::move(*route));
}
}
if (secret.size() >= 21 && secret[0] == bytes::type(0xEE)) {
return std::make_unique<TlsSocket>(
runtime,
thread,
secret,
proxy,
stealth,
mtproxyAttempt,
std::move(mtproxyPlan),
mtproxyAttemptStartedAt);
}
return std::make_unique<TcpSocket>(
runtime,
thread,
networkProxy);
}
} // namespace MTP::details