From f6e14c7499dc8901ab06f3a5e55ccb367cbe3387 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Fri, 21 Jan 2022 15:22:21 +0100 Subject: [PATCH] Maintain AddressFamily when migrating DCs --- README.md | 2 ++ src/Client.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b0fcc8..7292629 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ ## _a Telegram Client API library written 100% in C# and .NET Standard_ +This ReadMe is a quick but important tutorial to learn the fundamentals about this library. Please read it all. + # How to use >⚠️ This library relies on asynchronous C# programming (`async/await`) so make sure you are familiar with this advanced topic before proceeding. diff --git a/src/Client.cs b/src/Client.cs index 6d5f8fb..5d6418d 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -354,7 +354,9 @@ namespace WTelegram { _dcSession.DataCenter = _session.DcOptions.Where(dc => dc.id == TLConfig.this_dc) .OrderByDescending(dc => dc.ip_address == endpoint?.Address.ToString()) - .ThenByDescending(dc => dc.port == endpoint?.Port).First(); + .ThenByDescending(dc => dc.port == endpoint?.Port) + .ThenByDescending(dc => dc.flags == (endpoint?.AddressFamily == AddressFamily.InterNetworkV6 ? DcOption.Flags.ipv6 : 0)) + .First(); _session.DCSessions[TLConfig.this_dc] = _dcSession; } if (_session.MainDC == 0) _session.MainDC = TLConfig.this_dc;