NetPlay: Limit ENet's MTU to 1392 as a workaround for dropped packets over VPN via WireGuard, see https://github.com/lsalzman/enet/issues/132

This commit is contained in:
Admiral H. Curtiss 2023-04-02 17:21:26 +02:00
parent 324777406c
commit 1e1041f299
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
4 changed files with 7 additions and 0 deletions

View File

@ -333,6 +333,7 @@ bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 liste
g_MainNetHost.reset(); g_MainNetHost.reset();
return false; return false;
} }
host->mtu = std::min(host->mtu, NetPlay::MAX_ENET_MTU);
g_MainNetHost.reset(host); g_MainNetHost.reset(host);
g_TraversalClient.reset(new TraversalClient(g_MainNetHost.get(), server, server_port)); g_TraversalClient.reset(new TraversalClient(g_MainNetHost.get(), server, server_port));
} }

View File

@ -144,6 +144,8 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay
return; return;
} }
m_client->mtu = std::min(m_client->mtu, NetPlay::MAX_ENET_MTU);
ENetAddress addr; ENetAddress addr;
enet_address_set_host(&addr, address.c_str()); enet_address_set_host(&addr, address.c_str());
addr.port = port; addr.port = port;

View File

@ -220,6 +220,7 @@ enum class SyncCodeID : u8
constexpr u32 MAX_NAME_LENGTH = 30; constexpr u32 MAX_NAME_LENGTH = 30;
constexpr size_t CHUNKED_DATA_UNIT_SIZE = 16384; constexpr size_t CHUNKED_DATA_UNIT_SIZE = 16384;
constexpr u32 MAX_ENET_MTU = 1392; // see https://github.com/lsalzman/enet/issues/132
enum : u8 enum : u8
{ {

View File

@ -151,7 +151,10 @@ NetPlayServer::NetPlayServer(const u16 port, const bool forward_port, NetPlayUI*
serverAddr.port = port; serverAddr.port = port;
m_server = enet_host_create(&serverAddr, 10, CHANNEL_COUNT, 0, 0); m_server = enet_host_create(&serverAddr, 10, CHANNEL_COUNT, 0, 0);
if (m_server != nullptr) if (m_server != nullptr)
{
m_server->mtu = std::min(m_server->mtu, NetPlay::MAX_ENET_MTU);
m_server->intercept = ENetUtil::InterceptCallback; m_server->intercept = ENetUtil::InterceptCallback;
}
SetupIndex(); SetupIndex();
} }