Added experimental settings to prefer ipv6 when it is available

This commit is contained in:
bitxer 2024-12-19 18:11:18 +08:00 committed by John Preston
parent e33ca9d316
commit 0f283c484d
3 changed files with 14 additions and 1 deletions

View file

@ -5,6 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "base/options.h"
#include "mtproto/session_private.h"
#include "mtproto/details/mtproto_bound_key_creator.h"
@ -138,8 +139,16 @@ void WrapInvokeAfter(
return different;
}
base::options::toggle OptionPreferIPv6({
.id = kOptionPreferIPv6,
.name = "Prefer IPv6",
.description = "Prefer IPv6 if it is available",
});
} // namespace
const char kOptionPreferIPv6[] = "prefer-ipv6";
SessionPrivate::SessionPrivate(
not_null<Instance*> instance,
not_null<QThread*> thread,
@ -187,7 +196,7 @@ void SessionPrivate::appendTestConnection(
const bytes::vector &protocolSecret) {
QWriteLocker lock(&_stateMutex);
const auto priority = (qthelp::is_ipv6(ip) ? 0 : 1)
const auto priority = (qthelp::is_ipv6(ip) ? (OptionPreferIPv6.value() ? 2 : 0) : 1)
+ (protocol == DcOptions::Variants::Tcp ? 1 : 0)
+ (protocolSecret.empty() ? 0 : 1);
_testConnections.push_back({

View file

@ -240,5 +240,7 @@ private:
};
extern const char kOptionPreferIPv6[];
} // namespace details
} // namespace MTP

View file

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "media/player/media_player_instance.h"
#include "mtproto/session_private.h"
#include "webview/webview_embed.h"
#include "window/main_window.h"
#include "window/window_peer_menu.h"
@ -156,6 +157,7 @@ void SetupExperimental(
addToggle(Core::kOptionSkipUrlSchemeRegister);
addToggle(Data::kOptionExternalVideoPlayer);
addToggle(Window::kOptionNewWindowsSizeAsFirst);
addToggle(MTP::details::kOptionPreferIPv6);
addToggle(Window::kOptionDisableTouchbar);
}