td icon indicating copy to clipboard operation
td copied to clipboard

feat(server): support tdesktop

Open ernado opened this issue 1 year ago • 2 comments

Meta-issue for tdesktop support on server and protocol.

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

cc: @tdakkota

ernado avatar Jul 28 '22 09:07 ernado

Screenshot from 2022-07-28 13-09-56

ernado avatar Jul 28 '22 10:07 ernado

[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)

ernado avatar Jul 28 '22 10:07 ernado

Thank you for help guys!

ernado avatar Aug 14 '22 13:08 ernado