ZaStoGram/TMessagesProj/jni/mtproxy/MtProxyServerFlightParser.h
loop-uh 3f8f8f27e7 Extract mtproxy module with unified retry authority
Move MTProxy policy engine from tgnet/ to self-contained jni/mtproxy/ module. Consolidate reconnect hold computation into single MtProxyRetryAuthority owner (was split across Connection, ConnectionSocket, endpoint policy, and probe coordinator, causing hold misalignment bugs). Add MtProxyTerminalDiagnostic module with host tests for pre-I/O verdict preservation (fixes 02.07/30.06 clobber livelocks). Auto-generate phase classification (isPreIoTerminalVerdict, needsReconnectBackoff, isObservationFacadePhase, isLocalSchedulerTimeout) from single Python contract into both C++ and Java to eliminate parallel maintenance. Pass native hold (coordinator terminal hold + endpoint cooldown) via JNI to Java so reconnect timer and health store use THE clock, not re-derived ones. Optimize log flushing: batch debug lines, flush errors immediately. Add module boundary guard, host build system (MSVC), and unit tests for retry logic and terminal diagnostic derivation.
2026-07-02 18:25:13 +03:00

37 lines
1.2 KiB
C++

#ifndef MTPROXYSERVERFLIGHTPARSER_H
#define MTPROXYSERVERFLIGHTPARSER_H
#include "MtProxyPhaseContract.h"
#include <cstddef>
#include <cstdint>
#include <string>
static constexpr size_t MT_PROXY_SERVER_FLIGHT_MAX_BYTES = 64 * 1024;
struct MtProxyServerFlightRecordInfo {
int32_t recordType = -1;
int32_t tlsMajor = -1;
int32_t tlsMinor = -1;
int32_t recordLength = -1;
int32_t alertLevel = -1;
int32_t alertDescription = -1;
};
struct MtProxyServerFlightParseResult {
bool waitMore = false;
bool matched = false;
bool invalid = false;
size_t matchedBytes = 0;
size_t appFlightBytes = 0;
size_t candidateBytes = 0;
const char *reason = MtProxyPhase::ServerHelloHmacMismatch;
};
const char *mtProxyServerHelloParserName(int32_t parserMode);
MtProxyServerFlightRecordInfo mtProxyServerFlightReadRecordInfo(const uint8_t *data, size_t size);
bool mtProxyServerFlightLooksLikeTlsAlert(const uint8_t *data, size_t size);
bool mtProxyServerFlightHandshakeRecordNeedsMoreBytes(const uint8_t *data, size_t size);
MtProxyServerFlightParseResult mtProxyParseServerHelloFlight(const std::string &secret, const uint8_t *clientRandom, const uint8_t *data, size_t size, int32_t parserMode);
#endif