ZaStoGram_desktop/Telegram/SourceFiles/mtproto/runtime/proxy_data.h
loop-uh 10f1f9823c Naive: тип прокси NaiveProxy и WSS на движке Chrome 158 (zsgnaive)
Новый модуль zsg_naive/ (загрузчик C API zsgnaive, сокет NaiveSocket на QTcpSocket),
тип ProxyData::Type::Naive (номер 5 в настройках, ссылки tg://naive, окно прокси),
WssSocket переведён с QSslSocket и своего разбора HTTP/кадров на zsg_ws:
TLS-рукопожатие, апгрейд и кадры делает библиотека, маршруты и здоровье остались.
Naive-запись не откатывается на прямой WSS и ходит к DC только по IPv4.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 06:59:57 -05:00

145 lines
3.3 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
*/
#pragma once
#include "base/bytes.h"
#include "base/basic_types.h"
#include <QtCore/QString>
#include <vector>
namespace MTP {
struct ProxyData {
enum class Settings {
System,
Enabled,
Disabled,
};
enum class Type {
None,
Socks5,
Http,
Mtproto,
Web,
// ZaStoGram: a NaiveProxy-compatible server (zsg_naive/). Appended at
// the end so the serialized numbering of the other types never moves.
Naive,
};
enum class Status {
Valid,
Unsupported,
IncorrectSecret,
Invalid,
};
Type type = Type::None;
QString host;
uint32 port = 0;
QString user, password;
QString originalHost;
std::vector<QString> resolvedIPs;
crl::time resolvedExpireAt = 0;
// A WEB proxy address is a hostname with an optional base path, like
// `proxy.example.com` or `proxy.example.com/my-super-app`, so that a
// production site can keep serving everything outside that prefix. The
// path lives in the otherwise unused `user` field: that keeps the
// serialized proxy format unchanged and makes a client without this
// feature reject the entry instead of silently using the host root.
[[nodiscard]] QString webAddress() const;
void setWebAddress(const QString &value);
[[nodiscard]] QString webBasePath() const;
[[nodiscard]] bool valid() const;
[[nodiscard]] Status status() const;
[[nodiscard]] bool supportsCalls() const;
[[nodiscard]] bool tryCustomResolve() const;
[[nodiscard]] bytes::vector secretFromMtprotoPassword() const;
[[nodiscard]] explicit operator bool() const;
[[nodiscard]] bool operator==(const ProxyData &other) const;
[[nodiscard]] bool operator!=(const ProxyData &other) const;
[[nodiscard]] static Status MtprotoPasswordStatus(
const QString &password);
};
enum class ProxyTlsProfile {
Auto,
Firefox,
AndroidChrome,
Yandex,
FirefoxAndroid,
AndroidOkHttp,
AutoRotate,
ChromeModern,
};
enum class ProxyClientHelloFragmentation {
Off,
Soft,
};
enum class ProxyConnectionPattern {
Off,
Soft,
Quiet,
Strict,
Browser,
};
enum class ProxyRecordSizing {
Off,
Conservative,
Varied,
};
enum class ProxyTiming {
Off,
Gentle,
Balanced,
};
enum class ProxyStartupCover {
Off,
Soft,
Strict,
};
enum class ProxyTransport {
Tcp,
Wss,
};
enum class ProxyStealthLevel {
CompatStrict,
CompatModern,
DpiAdaptiveHandshake,
DpiAdaptiveData,
Experimental,
};
struct ProxyStealthOptions {
ProxyStealthLevel level = ProxyStealthLevel::DpiAdaptiveData;
ProxyTlsProfile tlsProfile = ProxyTlsProfile::Auto;
ProxyClientHelloFragmentation clientHelloFragmentation
= ProxyClientHelloFragmentation::Off;
ProxyConnectionPattern connectionPattern = ProxyConnectionPattern::Browser;
ProxyRecordSizing recordSizing = ProxyRecordSizing::Off;
ProxyTiming timing = ProxyTiming::Off;
ProxyStartupCover startupCover = ProxyStartupCover::Off;
bool syntheticPsk = false;
ProxyTransport transport = ProxyTransport::Wss;
QString wssCustomHost;
int wssCustomPort = 443;
QString wssCustomPath;
QString wssCustomDomain;
friend bool operator==(
const ProxyStealthOptions &,
const ProxyStealthOptions &) = default;
};
} // namespace MTP