Fix incorrect sending of DC id when connecting to MTProxy

This commit is contained in:
Dmitry D. Chernov 2019-02-12 21:17:08 +10:00
parent 4899788d92
commit d25442345e
2 changed files with 3 additions and 3 deletions

View File

@ -36,5 +36,4 @@ class ConnectionTcpMTProxy(ConnectionTcpObfuscated):
def _compose_tail(self, data):
dc_id_bytes = self._dc_id.to_bytes(2, "little", signed=True)
tail_bytes = super()._compose_tail(data)
return tail_bytes[:4] + dc_id_bytes + tail_bytes[6:]
return super()._compose_tail(data[:60] + dc_id_bytes + data[62:])

View File

@ -38,7 +38,6 @@ class ConnectionTcpObfuscated(ConnectionTcpAbridged):
break
random = bytearray(random)
random[56] = random[57] = random[58] = random[59] = 0xef
random_reversed = random[55:7:-1] # Reversed (8, len=48)
# Encryption has "continuous buffer" enabled
@ -50,7 +49,9 @@ class ConnectionTcpObfuscated(ConnectionTcpAbridged):
self._aes_encrypt = AESModeCTR(encrypt_key, encrypt_iv)
self._aes_decrypt = AESModeCTR(decrypt_key, decrypt_iv)
random[56:60] = b'\xef\xef\xef\xef'
random[56:64] = self._compose_tail(bytes(random))
self._writer.write(random)
await self._writer.drain()