fix issue with MTProxy and media dc_id

This commit is contained in:
Wizou 2022-06-19 18:08:19 +02:00
parent b1c8d225f2
commit f620514759
2 changed files with 4 additions and 2 deletions

View file

@ -355,7 +355,7 @@ namespace WTelegram
internal IObject ReadFrame(byte[] data, int dataLen)
{
if (dataLen == 4 && data[3] == 0xFF)
if (dataLen < 8 && data[3] == 0xFF)
{
int error_code = -BinaryPrimitives.ReadInt32LittleEndian(data);
throw new RpcException(error_code, TransportError(error_code));
@ -448,6 +448,7 @@ namespace WTelegram
{
404 => "Auth key not found",
429 => "Transport flood",
444 => "Invalid DC",
_ => Enum.GetName(typeof(HttpStatusCode), error_code) ?? "Transport error"
};
}
@ -708,7 +709,7 @@ namespace WTelegram
if (MTProxyUrl != null)
{
#if OBFUSCATION
if (!IsMainDC) dcId = -dcId;
if (_dcSession.DataCenter?.flags.HasFlag(DcOption.Flags.media_only) == true) dcId = -dcId;
var parms = HttpUtility.ParseQueryString(MTProxyUrl[MTProxyUrl.IndexOf('?')..]);
var server = parms["server"];
int port = int.Parse(parms["port"]);

View file

@ -56,6 +56,7 @@ namespace WTelegram
new_nonce = new Int256(RNG),
dc = session.DataCenter?.id ?? 0
};
if (session.DataCenter?.flags.HasFlag(DcOption.Flags.media_only) == true) pqInnerData.dc = -pqInnerData.dc;
byte[] encrypted_data = null;
{
//4.1) RSA_PAD(data, server_public_key)