td
td copied to clipboard
feat(server): support tdesktop
Meta-issue for tdesktop support on server and protocol.
- tdesktop fork patched for localhost and test private key
- teled, server based on tgtest
int TcpConnection::Protocol::Version0::readPacketLength(
bytes::const_span bytes) const {
if (bytes.empty()) {
return kUnknownSize;
}
const auto first = static_cast<char>(bytes[0]);
if (first == 0x7F) {
if (bytes.size() < 4) {
return kUnknownSize;
}
const auto ints = static_cast<uint32>(bytes[1])
| (static_cast<uint32>(bytes[2]) << 8)
| (static_cast<uint32>(bytes[3]) << 16);
return (ints >= 0x7F) ? (int(ints << 2) + 4) : kInvalidSize;
} else if (first > 0 && first < 0x7F) {
const auto ints = uint32(first);
return int(ints << 2) + 1;
}
return kInvalidSize;
}
This looks like abridged, but it is currently not working:
-
read: read: read abridged: read payload: unexpected EOF
when no header - Invalid header with header
Other implementations
- teamgram-server
- marmota, teamgram protocol implementation
cc: @tdakkota
[13:12:33.034 02-0002899] Connection 740(dc:1,) Info: Sending 88 len request. (connection_abstract.cpp : 25)
[13:12:33.035 02-0002900] Connection 737(dc:1,127.0.0.1:9443) Info: Sending fake req_pq. (connection_abstract.cpp : 25)
[13:12:33.035 02-0002901] Connection 737(dc:1,127.0.0.1:9443) Info: TCP Info: write packet 77 bytes. (connection_abstract.cpp : 25)
Thank you for help guys!