From 1e9dab821cbaf39f0962ee8a938d404e8fb759b6 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 31 Jan 2020 13:20:11 +0800 Subject: [PATCH] Allow pre-set IP type in config.xml --- src/config/user_config.hpp | 4 ++++ src/network/network_config.cpp | 6 ++++++ src/network/network_config.hpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index b1c4702d9..dcf85a481 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -825,6 +825,10 @@ namespace UserConfigParams PARAM_PREFIX IntUserConfigParam m_timer_sync_difference_tolerance PARAM_DEFAULT(IntUserConfigParam(5, "timer-sync-difference-tolerance", &m_network_group, "Max time difference tolerance (in ms) to synchronize timer with server.")); + PARAM_PREFIX IntUserConfigParam m_default_ip_type + PARAM_DEFAULT(IntUserConfigParam(0, "default-ip-type", + &m_network_group, "Default IP type of this machine, " + "0 detect every time, 1 IPv4, 2 IPv6, 3 IPv6 NAT64, 4 Dual stack.")); // ---- Gamemode setup PARAM_PREFIX UIntToUIntUserConfigParam m_num_karts_per_gamemode diff --git a/src/network/network_config.cpp b/src/network/network_config.cpp index ccbb68ce3..9331c3635 100644 --- a/src/network/network_config.cpp +++ b/src/network/network_config.cpp @@ -200,6 +200,12 @@ bool NetworkConfig::roundValuesNow() const void NetworkConfig::detectIPType() { m_nat64_prefix_data.fill(-1); + if (UserConfigParams::m_default_ip_type != IP_NONE) + { + int ip_type = UserConfigParams::m_default_ip_type; + m_ip_type.store((IPType)ip_type); + return; + } #ifdef ENABLE_IPV6 ENetAddress eaddr; eaddr.host = STKHost::HOST_ANY; diff --git a/src/network/network_config.hpp b/src/network/network_config.hpp index d5c028652..153ca396f 100644 --- a/src/network/network_config.hpp +++ b/src/network/network_config.hpp @@ -49,7 +49,7 @@ class PlayerProfile; class NetworkConfig : public NoCopy { public: - enum IPType : uint8_t + enum IPType : int { IP_NONE, IP_V4, IP_V6, IP_V6_NAT64, IP_DUAL_STACK };