ZaStoGram/TMessagesProj/jni/tgnet/transport/TransportSocket.h
loop-uh 19781730f6
Some checks failed
ZaStoGram source guards / guards (push) Failing after 25s
Build three ZaStoGram APKs / build (arm64-v8a, ZaStoGram-standalone-arm64-v8a, Arm64, arm64) (push) Failing after 2m13s
Build three ZaStoGram APKs / build (armeabi-v7a, ZaStoGram-standalone-armeabi-v7a, Armv7, armv7) (push) Failing after 2m15s
Build three ZaStoGram APKs / build (x86, ZaStoGram-standalone-x86, X86, x86) (push) Failing after 2m15s
Качать через туннель мелкими частями и слать видео без пережатия
Релеи медиа DC1/DC5 на мобильной сети закрыты, а туннель Cloudflare
замерзает на каждом TCP-соединении после ~16 КБ. Через туннель файлы
теперь качаются частями по 8 КБ по одному запросу, а соединение
туннеля заменяется новым после ~6 КБ, так что каждый ответ проходит:
аватарки и смайлики с DC1/DC5 грузятся, пусть и медленнее.

Новая настройка «Видео без пережатия» (ZaSto Приватность): видео до
выбранного размера уходит оригиналом, как с компьютера, без долгого
перекодирования 4K в 720p; видео с правками пережимается всегда.
2026-09-24 21:36:58 +03:00

60 lines
2.1 KiB
C++

/*
* This is the source code of tgnet library v. 1.1
* It is licensed under GNU GPL v. 2 or later.
*/
#ifndef TGNET_TRANSPORT_SOCKET_H
#define TGNET_TRANSPORT_SOCKET_H
#include <stdint.h>
#include <sys/socket.h>
#include <string>
#include <vector>
namespace tgnet {
namespace transport {
enum class HandshakePhase : uint8_t {
None,
TcpConnected,
TlsReady,
WebSocketReady,
FirstDataReceived,
};
// Transport boundary used by the connection layer. Implementations own their
// native descriptor and expose a byte stream; MTProto does not know how that
// stream is carried on the wire.
class Socket {
public:
virtual ~Socket() = default;
virtual bool open(const struct sockaddr *address, socklen_t addressLength, std::string *diagnostic) = 0;
virtual int fd() const = 0;
virtual bool onEvent(uint32_t events, std::vector<std::vector<uint8_t>> &payloads, std::string *diagnostic) = 0;
virtual bool write(const uint8_t *data, uint32_t size, std::string *diagnostic) = 0;
virtual size_t queuedOutputBytes() const = 0;
virtual bool isReady() const = 0;
virtual bool wantsWrite() const = 0;
virtual bool canWriteApplicationData() const = 0;
virtual bool isClosed() const = 0;
virtual HandshakePhase handshakePhase() const = 0;
virtual const char *transportName() const = 0;
virtual void timedOut() = 0;
// The handshake completed, application data was sent, and no reply came
// back within the shared watchdog timeout. Transports use this to penalize
// routes that look healthy but silently swallow traffic.
virtual void noteAppDataTimeout() {}
// One-line account of this socket's life for the disconnect log line
// (route, bytes each way, handshake and first-data times). Taking it
// tells the transport not to log the same summary again on close.
virtual std::string takeSessionSummary() { return std::string(); }
// Application bytes received since open; the WSS tunnel rotates on it.
virtual uint64_t receivedBytes() const { return 0; }
virtual void close() = 0;
};
} // namespace transport
} // namespace tgnet
#endif