ZaStoGram_desktop/Telegram/SourceFiles/mtproto/runtime/proxy_data.h
loop-uh 5bce8c10e5 Merge upstream dev through a1ea1ddd8c (7.2.9)
Keeps the ZaStoGram MTProto layout and its unaligned-access fixes, the
Forgejo update checker and the rich-page layout contract; takes the
upstream IV editor edge restore, horizontal overflow width, round video
seek, tlottie renderer and the lib_ui text shaper.
2026-09-23 16:21:17 +03:00

143 lines
3.2 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,
};
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 bool ValidMtprotoPassword(const QString &password);
[[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