Maintain AddressFamily when migrating DCs

This commit is contained in:
Wizou 2022-01-21 15:22:21 +01:00
parent f711948da7
commit f6e14c7499
2 changed files with 5 additions and 1 deletions

View file

@ -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.

View file

@ -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;